diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2011-03-17 21:39:28 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2011-03-17 21:39:28 +0200 |
commit | c6ceb73febc0f5afcd01341a16dca768d5c627cd (patch) | |
tree | 98af5a8032b8d5e9dfa75f78ba92476f26c74bc3 | |
parent | 4c917f2e2a43ea50cd287dd322dda9d08b213b7d (diff) |
modified: api/ec_pluginapi.h
modified: core/events.cpp
modified: core/events.h
modified: core/globals.h
modified: core/modules.cpp
modified: core/modules.h
-rw-r--r-- | api/ec_pluginapi.h | 4 | ||||
-rw-r--r-- | core/events.cpp | 25 | ||||
-rw-r--r-- | core/events.h | 2 | ||||
-rw-r--r-- | core/globals.h | 5 | ||||
-rw-r--r-- | core/modules.cpp | 14 | ||||
-rw-r--r-- | core/modules.h | 3 |
6 files changed, 42 insertions, 11 deletions
diff --git a/api/ec_pluginapi.h b/api/ec_pluginapi.h index 7f13634..e58b55a 100644 --- a/api/ec_pluginapi.h +++ b/api/ec_pluginapi.h @@ -38,7 +38,7 @@ typedef struct void* (*CallService)(const char *,void*); bool (*ServiceExists)(const char *); bool (*RegisterEventHandler)(int, EVENT_HANDLER); - int (*RegisterEventType)(int); + int (*RegisterEventType)(int, int); //event type, special id } PLUGINLINK; typedef struct @@ -46,7 +46,7 @@ typedef struct // int size; wchar_t *name, *description, *author, *authoremail; unsigned long version; - int pluginid; //will be set by core, neede to call some core services + int pluginid; //special id will be set by core, neede to call some core services }PLUGININFO;
diff --git a/core/events.cpp b/core/events.cpp index b4a2396..4d206c8 100644 --- a/core/events.cpp +++ b/core/events.cpp @@ -16,9 +16,6 @@ #include "commonheaders.h" -extern std::list<evt_handler*> event_handlers; -extern boost::mutex event_handlers_mutex; - const int evt_handler::getType() { @@ -43,7 +40,6 @@ bool RegisterEventHandler(int type, EVENT_HANDLER func) { if(!event_handlers.empty()) { - event_handlers_mutex.lock(); std::list<evt_handler*>::iterator end = event_handlers.end(); for(std::list<evt_handler*>::iterator i = event_handlers.begin(); i != end; ++i) { @@ -55,19 +51,34 @@ bool RegisterEventHandler(int type, EVENT_HANDLER func) } return true; } -int RegisterEventType(int type) +int RegisterEventType(int type, int specialid) { + plugin *p = NULL; + if(!plugins.empty()) + { + std::list<plugin*>::iterator end = plugins.end(); + for(std::list<plugin*>::iterator i = plugins.begin(); i!= end; ++i) + { + if((*i)->get_plugin_id() == specialid) + { + p = *i; + break; + } + } + if(!p) + return 1; + } if(!event_handlers.empty()) { - event_handlers_mutex.lock(); std::list<evt_handler*>::iterator end = event_handlers.end(); for(std::list<evt_handler*>::iterator i = event_handlers.begin(); i != end; ++i) { if((*i)->getType() == type) - return -1; + return 1; } } event_handlers.push_back(new evt_handler(type)); + p->register_event(type); return 0; } diff --git a/core/events.h b/core/events.h index 1d968df..17b2497 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); -int RegisterEventType(int); +int RegisterEventType(int, int); class evt_handler{ public: diff --git a/core/globals.h b/core/globals.h index a82e512..2700403 100644 --- a/core/globals.h +++ b/core/globals.h @@ -21,4 +21,9 @@ extern ACE_Log_Msg logger; extern int current_plugin_id; + +extern std::list<evt_handler*> event_handlers; +extern boost::mutex event_handlers_mutex; + +extern std::list<plugin*> plugins; #endif
\ No newline at end of file diff --git a/core/modules.cpp b/core/modules.cpp index 6eaf038..bcdcbe6 100644 --- a/core/modules.cpp +++ b/core/modules.cpp @@ -17,7 +17,7 @@ #include "commonheaders.h" -extern std::list<plugin*> plugins; + extern PLUGINLINK pluglink; @@ -150,3 +150,15 @@ const int plugin::get_plugin_id() { return pluginid; } + +const std::list<int> plugin::get_event_list() +{ + return events; +} + + +int plugin::register_event(int type) +{ + events.push_back(type); + return 0; +}
\ No newline at end of file diff --git a/core/modules.h b/core/modules.h index ca61aee..81d2c84 100644 --- a/core/modules.h +++ b/core/modules.h @@ -46,6 +46,8 @@ public: const PLUGININFO *get_plugininfo(); const exported_functions_s *get_exported_functions(); const int get_plugin_id(); + const std::list<int> get_event_list(); + int register_event(int); plugin(ACE_DLL *lib, PLUGININFO *info, exported_functions_s *funcs); ~plugin(); private: @@ -53,6 +55,7 @@ private: exported_functions_s *exported_funcs; PLUGININFO *plugininfo; int pluginid; + std::list<int> events; };
#endif // MODULE_H_INCLUDED
|