store(st),
WriteServLog(GetStgLogger()),
searchDescriptors(),
- handle(0)
+ handle(0),
+ mutex(),
+ strError()
{
pthread_mutex_init(&mutex, NULL);
Read();
//-----------------------------------------------------------------------------
int SERVICES_IMPL::Add(const SERVICE_CONF & service, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->serviceChg)
{
- string s = admin->GetLogStr() + " Add service \'" + service.name + "\'. Access denied.";
+ std::string s = admin->GetLogStr() + " Add service \'" + service.name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
}
-srv_iter si(find(data.begin(), data.end(), service));
+iterator si(find(data.begin(), data.end(), service));
if (si != data.end())
{
return -1;
}
//-----------------------------------------------------------------------------
-int SERVICES_IMPL::Del(const string & name, const ADMIN * admin)
+int SERVICES_IMPL::Del(const std::string & name, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->serviceChg)
{
- string s = admin->GetLogStr() + " Delete service \'" + name + "\'. Access denied.";
+ std::string s = admin->GetLogStr() + " Delete service \'" + name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
}
-srv_iter si(find(data.begin(), data.end(), SERVICE_CONF(name)));
+iterator si(find(data.begin(), data.end(), SERVICE_CONF(name)));
if (si == data.end())
{
return -1;
}
-map<int, const_srv_iter>::iterator csi;
+std::map<int, const_iterator>::iterator csi;
csi = searchDescriptors.begin();
while (csi != searchDescriptors.end())
{
//-----------------------------------------------------------------------------
int SERVICES_IMPL::Change(const SERVICE_CONF & service, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->serviceChg)
{
- string s = admin->GetLogStr() + " Change service \'" + service.name + "\'. Access denied.";
+ std::string s = admin->GetLogStr() + " Change service \'" + service.name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
}
-srv_iter si(find(data.begin(), data.end(), service));
+iterator si(find(data.begin(), data.end(), service));
if (si == data.end())
{
//-----------------------------------------------------------------------------
bool SERVICES_IMPL::Read()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
-vector<string> servicesList;
+STG_LOCKER lock(&mutex);
+std::vector<std::string> servicesList;
if (store->GetServicesList(&servicesList) < 0)
{
WriteServLog(store->GetStrError().c_str());
return false;
}
//-----------------------------------------------------------------------------
-bool SERVICES_IMPL::Find(const string & name, SERVICE_CONF * service)
+bool SERVICES_IMPL::Find(const std::string & name, SERVICE_CONF * service) const
{
assert(service != NULL && "Pointer to service is not null");
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
return false;
-srv_iter si(find(data.begin(), data.end(), SERVICE_CONF(name)));
+const_iterator si(find(data.begin(), data.end(), SERVICE_CONF(name)));
if (si != data.end())
{
return true;
}
//-----------------------------------------------------------------------------
-bool SERVICES_IMPL::Exists(const string & name) const
+bool SERVICES_IMPL::Exists(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
{
printfd(__FILE__, "no admin in system!\n");
return true;
}
-const_srv_iter si(find(data.begin(), data.end(), SERVICE_CONF(name)));
+const_iterator si(find(data.begin(), data.end(), SERVICE_CONF(name)));
if (si != data.end())
return true;
//-----------------------------------------------------------------------------
int SERVICES_IMPL::OpenSearch() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
handle++;
searchDescriptors[handle] = data.begin();
return handle;
//-----------------------------------------------------------------------------
int SERVICES_IMPL::SearchNext(int h, SERVICE_CONF * service) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) == searchDescriptors.end())
{
WriteServLog("SERVICES. Incorrect search handle.");
//-----------------------------------------------------------------------------
int SERVICES_IMPL::CloseSearch(int h) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) != searchDescriptors.end())
{
searchDescriptors.erase(searchDescriptors.find(h));