diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-15 08:53:21 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-15 08:53:21 +0300 |
commit | 7890dccf61ba5e92d76e79c121b926ac515d6747 (patch) | |
tree | 52b74bdb31abbf0e18fde416683fe57e3a79807c /core/services.cpp | |
parent | 076c9cfcf33e06218805ad0412a806005c3c63f7 (diff) |
services
Diffstat (limited to 'core/services.cpp')
-rw-r--r-- | core/services.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/core/services.cpp b/core/services.cpp new file mode 100644 index 0000000..56ee05e --- /dev/null +++ b/core/services.cpp @@ -0,0 +1,54 @@ +#include "commonheaders.h" + +extern std::list<service*> services; + +int ServiceExists(const char *name); +void CreateServiceFunction(const char* name, SERVICE svc) +{ + if(!ServiceExists(name)) + services.push_back(new service(name, svc)); +} + +void* CallService(const char *name,void* data) +{ + if(!services.empty()) + { + std::list<service*>::iterator end = services.end(); + for(std::list<service*>::iterator i = services.begin(); i != end; ++i) + { + if(!strcmp((*i)->getName(), name)) + return (*i)->getService()(data); + } + } + return 0; +} +int ServiceExists(const char *name) +{ + if(!services.empty()) + { + std::list<service*>::iterator end = services.end(); + for(std::list<service*>::iterator i = services.begin(); i != end; ++i) + if(!strcmp((*i)->getName(), name)) + return 1; + } + return 0; +} + +service::service(const char* name, SERVICE svc) +{ + pService = svc; + szName = strdup(name); +} + +const char* service::getName() +{ + return szName; +} +const SERVICE service::getService() +{ + return pService; +} +service::~service() +{ + free(szName); +} |