diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2011-03-17 21:08:25 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2011-03-17 21:08:25 +0200 |
commit | 4c917f2e2a43ea50cd287dd322dda9d08b213b7d (patch) | |
tree | c990c65226c78a2ee6595c05a3b2be36755d5b8f | |
parent | ee695f119bbc7b3f1557ab01b7953de2ca03e00b (diff) |
modified: api/ec_pluginapi.h
modified: api/ec_services.h
modified: core/events.cpp
modified: core/events.h
modified: core/globals.h
modified: core/main.cpp
modified: core/modules.cpp
modified: core/modules.h
modified: plugins/example/main.cpp
-rw-r--r-- | api/ec_pluginapi.h | 11 | ||||
-rw-r--r-- | api/ec_services.h | 2 | ||||
-rw-r--r-- | core/events.cpp | 4 | ||||
-rw-r--r-- | core/events.h | 2 | ||||
-rw-r--r-- | core/globals.h | 2 | ||||
-rw-r--r-- | core/main.cpp | 1 | ||||
-rw-r--r-- | core/modules.cpp | 8 | ||||
-rw-r--r-- | core/modules.h | 2 | ||||
-rw-r--r-- | plugins/example/main.cpp | 10 |
9 files changed, 30 insertions, 12 deletions
diff --git a/api/ec_pluginapi.h b/api/ec_pluginapi.h index 94f7eaf..7f13634 100644 --- a/api/ec_pluginapi.h +++ b/api/ec_pluginapi.h @@ -19,9 +19,8 @@ #define PLUGINAPI_H_INCLUDED
/* - * this is genereic plugin api header, only baisc c/c++ here - * we need to support also non wxwidgets plugins - */ + * this is genereic plugin api header, only c language here + */ typedef void* (*SERVICE)(void*); @@ -31,6 +30,7 @@ typedef void* (*EVENT_HANDLER)(void*); * CreateServiceFunction should be called with service name like: PluginName/ServiceName * EC/* reserved for core services */ + typedef struct { @@ -38,14 +38,15 @@ typedef struct void* (*CallService)(const char *,void*); bool (*ServiceExists)(const char *); bool (*RegisterEventHandler)(int, EVENT_HANDLER); - void* (*RegisterEventType)(int); + int (*RegisterEventType)(int); } PLUGINLINK; typedef struct { - int size; +// int size; wchar_t *name, *description, *author, *authoremail; unsigned long version; + int pluginid; //will be set by core, neede to call some core services }PLUGININFO;
diff --git a/api/ec_services.h b/api/ec_services.h index 73f0280..171b76f 100644 --- a/api/ec_services.h +++ b/api/ec_services.h @@ -19,7 +19,7 @@ */ /* - * Core Servicec + * Core Services */ diff --git a/core/events.cpp b/core/events.cpp index d858696..b4a2396 100644 --- a/core/events.cpp +++ b/core/events.cpp @@ -55,7 +55,7 @@ bool RegisterEventHandler(int type, EVENT_HANDLER func) } return true; } -void* RegisterEventType(int type) +int RegisterEventType(int type) { if(!event_handlers.empty()) { @@ -64,7 +64,7 @@ void* RegisterEventType(int type) for(std::list<evt_handler*>::iterator i = event_handlers.begin(); i != end; ++i) { if((*i)->getType() == type) - return (void*)-1; + return -1; } } event_handlers.push_back(new evt_handler(type)); diff --git a/core/events.h b/core/events.h index 909efa7..1d968df 100644 --- a/core/events.h +++ b/core/events.h @@ -17,7 +17,7 @@ #ifndef EVENTS_H_INCLUDED #define EVENTS_H_INCLUDED bool RegisterEventHandler(int, EVENT_HANDLER); -void* RegisterEventType(int); +int RegisterEventType(int); class evt_handler{ public: diff --git a/core/globals.h b/core/globals.h index e9c94a1..a82e512 100644 --- a/core/globals.h +++ b/core/globals.h @@ -20,5 +20,5 @@ #define GLOBALS_H extern ACE_Log_Msg logger; - +extern int current_plugin_id; #endif
\ No newline at end of file diff --git a/core/main.cpp b/core/main.cpp index 9f3e25c..03b314b 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -24,6 +24,7 @@ boost::mutex service_list_mutex; std::list<evt_handler*> event_handlers; boost::mutex event_handlers_mutex; ACE_Log_Msg logger; +int current_plugin_id = 13; bool halt_requested = false; diff --git a/core/modules.cpp b/core/modules.cpp index e5e9bc7..6eaf038 100644 --- a/core/modules.cpp +++ b/core/modules.cpp @@ -123,6 +123,9 @@ plugin::plugin(ACE_DLL *lib, PLUGININFO *info, exported_functions_s *funcs) exported_funcs = funcs; else exported_funcs = NULL; + pluginid = current_plugin_id; + plugininfo->pluginid = pluginid; + ++current_plugin_id; } plugin::~plugin() @@ -142,3 +145,8 @@ const plugin::exported_functions_s* plugin::get_exported_functions() { return exported_funcs; } + +const int plugin::get_plugin_id() +{ + return pluginid; +} diff --git a/core/modules.h b/core/modules.h index 6cdd0f6..ca61aee 100644 --- a/core/modules.h +++ b/core/modules.h @@ -45,12 +45,14 @@ public: // void set_plugin();
const PLUGININFO *get_plugininfo(); const exported_functions_s *get_exported_functions(); + const int get_plugin_id(); plugin(ACE_DLL *lib, PLUGININFO *info, exported_functions_s *funcs); ~plugin(); private: ACE_DLL *plug; exported_functions_s *exported_funcs; PLUGININFO *plugininfo; + int pluginid; };
#endif // MODULE_H_INCLUDED
diff --git a/plugins/example/main.cpp b/plugins/example/main.cpp index bd1f65b..c556d47 100644 --- a/plugins/example/main.cpp +++ b/plugins/example/main.cpp @@ -7,6 +7,7 @@ PLUGINLINK *pluginLink; +extern PLUGININFO pluginInfo; #define CallService(service, param) pluginLink->CallService(service,param) @@ -27,6 +28,11 @@ bool wxPluginForEvilCore::OnInit() wxSnprintf(msg, 31, _T("Core version is %d."), core_version); wxMessageBox(msg, _T("Info"), wxOK | wxICON_INFORMATION); } + { + wxChar msg [32]; + wxSnprintf(msg, 31, _T("I have obtained special id %d from core"), pluginInfo.pluginid); //we must obtain special plugin id for calling services like raise event or so. + wxMessageBox(msg, _T("Info"), wxOK | wxICON_INFORMATION); + } return true; } @@ -41,12 +47,12 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) / PLUGININFO pluginInfo = { - sizeof(PLUGININFO), //size of structure +// sizeof(PLUGININFO), //size of structure (wchar_t*)L"example plugin", //name 0, //description 0, //author 0, //author email - 0x00010101 //version 0.1.1.1 + 0x0001010d //version 0.1.1.13 }; #ifdef _WIN32 |