X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/e7987df1fe4b07d5b8240acc98968400be12b757..0df921108f5a3240db63336eddd3ab46bf80f424:/projects/stargazer/services_impl.cpp diff --git a/projects/stargazer/services_impl.cpp b/projects/stargazer/services_impl.cpp index ac856000..90c23f81 100644 --- a/projects/stargazer/services_impl.cpp +++ b/projects/stargazer/services_impl.cpp @@ -54,7 +54,7 @@ if (!priv->serviceChg) return -1; } -iterator si(find(data.begin(), data.end(), service)); +iterator si(std::find(data.begin(), data.end(), service)); if (si != data.end()) { @@ -92,7 +92,7 @@ if (!priv->serviceChg) return -1; } -iterator si(find(data.begin(), data.end(), SERVICE_CONF(name))); +iterator si(std::find(data.begin(), data.end(), SERVICE_CONF(name))); if (si == data.end()) { @@ -136,7 +136,7 @@ if (!priv->serviceChg) return -1; } -iterator si(find(data.begin(), data.end(), service)); +iterator si(std::find(data.begin(), data.end(), service)); if (si == data.end()) { @@ -145,7 +145,9 @@ if (si == data.end()) return -1; } +printfd(__FILE__, "Old cost = %f, old pay day = %d\n", si->cost, (unsigned)si->payDay); *si = service; +printfd(__FILE__, "New cost = %f, New pay day = %d\n", si->cost, (unsigned)si->payDay); if (store->SaveService(service)) { WriteServLog("Cannot write service %s.", service.name.c_str()); @@ -190,9 +192,28 @@ assert(service != NULL && "Pointer to service is not null"); STG_LOCKER lock(&mutex); if (data.empty()) + return true; + +const_iterator si(std::find(data.begin(), data.end(), SERVICE_CONF(name))); + +if (si != data.end()) + { + *service = *si; return false; + } + +return true; +} +//----------------------------------------------------------------------------- +bool SERVICES_IMPL::Find(const std::string & name, SERVICE_CONF_RES * service) const +{ +assert(service != NULL && "Pointer to service is not null"); + +STG_LOCKER lock(&mutex); +if (data.empty()) + return true; -const_iterator si(find(data.begin(), data.end(), SERVICE_CONF(name))); +const_iterator si(std::find(data.begin(), data.end(), SERVICE_CONF(name))); if (si != data.end()) { @@ -208,11 +229,11 @@ bool SERVICES_IMPL::Exists(const std::string & name) const STG_LOCKER lock(&mutex); if (data.empty()) { - printfd(__FILE__, "no admin in system!\n"); + printfd(__FILE__, "No services in the system!\n"); return true; } -const_iterator si(find(data.begin(), data.end(), SERVICE_CONF(name))); +const_iterator si(std::find(data.begin(), data.end(), SERVICE_CONF(name))); if (si != data.end()) return true;