23 #include "ServicePool.h"
25 static map<string,Service> servicePool;
26 ServicePool::ServicePool()
31 ServicePool::~ServicePool() {
42 string ServicePool::registerService(
string name,
Service service)
47 timeinfo = localtime(&rawtime);
49 clock_gettime(CLOCK_REALTIME, &en);
51 string yr = CastUtil::lexical_cast<
string>(timeinfo->tm_year);
52 string mo = CastUtil::lexical_cast<
string>(timeinfo->tm_mon);
53 string da = CastUtil::lexical_cast<
string>(timeinfo->tm_mday);
54 string hr = CastUtil::lexical_cast<
string>(timeinfo->tm_hour);
55 string mm = CastUtil::lexical_cast<
string>(timeinfo->tm_min);
56 string ms = CastUtil::lexical_cast<
string>(((en.tv_sec * 1000000000) + en.tv_nsec)/1000000);
58 string regName = (name+yr+mo+da+hr+mm+ms);
59 servicePool[regName] = service;
63 bool ServicePool::unRegisterService(
string name)
65 map<string,Service>::iterator it;
66 if(it==servicePool.end())
68 it = servicePool.find(name);
69 servicePool.erase(it);
73 vector<string> ServicePool::getServices(
string access)
75 vector<string> services;
76 map<string,Service>::iterator it;
77 for(it=servicePool.begin();it!=servicePool.end();++it)
79 services.push_back(it->first);
84 Service ServicePool::getService(
string regName)
86 return servicePool[regName];