plugin.h

Go to the documentation of this file.
00001 /*
00002 #########################################################################
00003 #
00004 #  This file is part of trustyRC.
00005 #
00006 #  trustyRC, fully modular IRC robot 
00007 #  Copyright (C) 2006-2008 Nicoleau Fabien 
00008 #
00009 #  trustyRC is free software: you can redistribute it and/or modify
00010 #  it under the terms of the GNU General Public License as published by
00011 #  the Free Software Foundation, either version 3 of the License, or
00012 #  (at your option) any later version.
00013 #
00014 #  trustyRC is distributed in the hope that it will be useful,
00015 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 #  GNU General Public License for more details.
00018 #
00019 #  You should have received a copy of the GNU General Public License
00020 #  along with trustyRC.  If not, see <http://www.gnu.org/licenses/>.
00021 #
00022 #########################################################################
00023 */
00024 
00029 #ifndef PLUGIN_H
00030 #define PLUGIN_H
00031 
00032 #include "message.h"
00033 #include <time.h>
00034 #include <vector>
00035 #include <string>
00036 using namespace std;
00037 class Plugin;
00038 class BotKernel;
00039 
00041 typedef enum {
00042         IN_LOOP,IN_COMMAND_HANDLER,IN_FREE_COMMAND_HANDLER,IN_TYPE_HANDLER,IN_BEFORE_TREATMENT,IN_ALL_MSGS,IN_FIRST_WORD,COUNTDOWN,OUT_ALL_MSGS
00043 } func_type;
00044 
00046 typedef bool (*plugin_function)(Message*,Plugin *,BotKernel*);
00048 typedef Plugin *(*plugin_constructor)(BotKernel*);
00050 typedef void (*plugin_destructor)(Plugin*);
00051 
00053 typedef struct 
00054 {
00055         string name;
00056         void * handle;
00057         Plugin* object;
00058         plugin_constructor creator;
00059         plugin_destructor destructor;
00060 } pPlugin;
00061 
00063 typedef struct 
00064 {
00065         void * handle;
00066         string highlightedWord;
00067         Plugin* object;
00068         func_type type;
00069         string symbole;
00070         plugin_function function ;
00071         time_t lastExec;
00072         unsigned int timeout;
00073    bool back;
00074 }StructFunctionStorage;
00075 
00083 class Plugin {
00084 protected:
00086         string author;
00088         string description;
00090         string version;
00092         string name;
00094    vector<StructFunctionStorage> funcs;
00096    void * handle;
00098    vector<string> requirements;
00099 public:
00101    Plugin();
00103    virtual ~Plugin();
00105         vector<StructFunctionStorage> getFunctions();
00107         string getAuthor();
00109         string getDescription();
00111         string getVersion();
00113         string getName();
00115         bool checkMembers();
00117    void bindFunction(string,func_type,string,time_t,unsigned int);
00119    void * getHandle();
00121    void setHandle(void*);
00123    void addRequirement(string);
00125    vector<string> getRequirements();
00127    bool requires(string);
00128 };
00129 #endif

Generated on Sun Aug 16 15:28:27 2009 for trustyRC by  doxygen 1.5.8