X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/7c744ef82350aa401c61aa6f0424866a16c2ed1a..db323584230f6d5b4a6e16574fd0baadc9d465e5:/projects/stargazer/tariffs_impl.cpp?ds=sidebyside diff --git a/projects/stargazer/tariffs_impl.cpp b/projects/stargazer/tariffs_impl.cpp index ea3632cb..aee486d7 100644 --- a/projects/stargazer/tariffs_impl.cpp +++ b/projects/stargazer/tariffs_impl.cpp @@ -46,6 +46,7 @@ TARIFFS_IMPL::TARIFFS_IMPL(STORE * st) tariffs(), store(st), WriteServLog(GetStgLogger()), + mutex(), strError(), noTariff(NO_TARIFF_NAME), onAddNotifiers(), @@ -62,7 +63,7 @@ pthread_mutex_destroy(&mutex); //----------------------------------------------------------------------------- int TARIFFS_IMPL::ReadTariffs() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); vector tariffsList; if (store->GetTariffsList(&tariffsList)) @@ -71,9 +72,9 @@ if (store->GetTariffsList(&tariffsList)) WriteServLog("%s", store->GetStrError().c_str()); } -int tariffsNum = tariffsList.size(); +Tariffs::size_type tariffsNum = tariffsList.size(); -for (int i = 0; i < tariffsNum; i++) +for (Tariffs::size_type i = 0; i < tariffsNum; i++) { TARIFF_DATA td; if (store->RestoreTariff(&td, tariffsList[i])) @@ -90,7 +91,7 @@ return 0; //----------------------------------------------------------------------------- size_t TARIFFS_IMPL::Count() const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); return tariffs.size(); } //----------------------------------------------------------------------------- @@ -99,7 +100,7 @@ const TARIFF * TARIFFS_IMPL::FindByName(const string & name) const if (name == NO_TARIFF_NAME) return &noTariff; -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); list::const_iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name)); @@ -122,7 +123,7 @@ if (!priv->tariffChg) return -1; } -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); list::iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(td.tariffConf.name)); @@ -165,7 +166,7 @@ if (!priv->tariffChg) TARIFF_DATA td; { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); list::iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name)); @@ -216,7 +217,7 @@ if (!priv->tariffChg) } { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); list::iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name)); @@ -255,9 +256,9 @@ return 0; void TARIFFS_IMPL::GetTariffsData(std::list * tdl) { assert(tdl != NULL && "Tariffs data list is not null"); -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); -std::list::const_iterator it = tariffs.begin(); +Tariffs::const_iterator it = tariffs.begin(); for (; it != tariffs.end(); ++it) { tdl->push_back(it->GetTariffData()); @@ -266,25 +267,25 @@ for (; it != tariffs.end(); ++it) //----------------------------------------------------------------------------- void TARIFFS_IMPL::AddNotifierAdd(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onAddNotifiers.insert(n); } //----------------------------------------------------------------------------- void TARIFFS_IMPL::DelNotifierAdd(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onAddNotifiers.erase(n); } //----------------------------------------------------------------------------- void TARIFFS_IMPL::AddNotifierDel(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onDelNotifiers.insert(n); } //----------------------------------------------------------------------------- void TARIFFS_IMPL::DelNotifierDel(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onDelNotifiers.erase(n); } //-----------------------------------------------------------------------------