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 }StructFunctionStorage;
00074
00082 class Plugin {
00083 protected:
00085 string author;
00087 string description;
00089 string version;
00091 string name;
00093 vector<StructFunctionStorage> funcs;
00095 void * handle;
00097 vector<string> requirements;
00098 public:
00100 Plugin();
00102 virtual ~Plugin();
00104 vector<StructFunctionStorage> getFunctions();
00106 string getAuthor();
00108 string getDescription();
00110 string getVersion();
00112 string getName();
00114 bool checkMembers();
00116 void bindFunction(string,func_type,string,time_t,unsigned int);
00118 void * getHandle();
00120 void setHandle(void*);
00122 void addRequirement(string);
00124 vector<string> getRequirements();
00126 bool requires(string);
00127 };
00128 #endif