plugin.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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