#include "commonheaders.h" extern std::list services; extern boost::mutex service_list_mutex; 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()) { service_list_mutex.lock(); std::list::iterator end = services.end(); for(std::list::iterator i = services.begin(); i != end; ++i) { if(!ACE_OS::strcmp((*i)->getName(), name)) return (*i)->getService()(data); } service_list_mutex.unlock(); } return 0; } int ServiceExists(const char *name) { service_list_mutex.lock(); if(!services.empty()) { std::list::iterator end = services.end(); for(std::list::iterator i = services.begin(); i != end; ++i) if(!ACE_OS::strcmp((*i)->getName(), name)) return 1; } service_list_mutex.unlock(); return 0; } service::service(const char* name, SERVICE svc) { pService = svc; szName = ACE_OS::strdup(name); } const char* service::getName() { return szName; } const SERVICE service::getService() { return pService; } service::~service() { ACE_OS::free(szName); }