X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/f323e60831f4e1e3c35ae0ed5592e49eb485eeb6..58d030a0db2b320459ce55d5a7b7b440d873d1d1:/projects/stargazer/plugins/other/smux/tables.cpp?ds=inline diff --git a/projects/stargazer/plugins/other/smux/tables.cpp b/projects/stargazer/plugins/other/smux/tables.cpp index 25b2dd85..ead98f38 100644 --- a/projects/stargazer/plugins/other/smux/tables.cpp +++ b/projects/stargazer/plugins/other/smux/tables.cpp @@ -1,21 +1,32 @@ -#include <cassert> -#include <utility> -#include <iterator> -#include <algorithm> +#include "tables.h" #include "stg/user_property.h" #include "stg/tariffs.h" +#include "stg/tariff_conf.h" #include "stg/users.h" -#include "tables.h" +#include <utility> +#include <iterator> +#include <algorithm> +#include <cassert> -std::pair<std::string, size_t> TD2Info(const TARIFF_DATA & td); +using STG::TariffUsersTable; + +namespace +{ + +std::pair<std::string, size_t> TD2Info(const STG::TariffData & td) +{ + return std::make_pair(td.tariffConf.name, 0); +} + +} void TariffUsersTable::UpdateSensors(Sensors & sensors) const { std::map<std::string, size_t> data; -std::list<TARIFF_DATA> tdl; +std::vector<STG::TariffData> tdl; tariffs.GetTariffsData(&tdl); std::transform(tdl.begin(), tdl.end(), @@ -25,12 +36,12 @@ std::transform(tdl.begin(), int handle = users.OpenSearch(); assert(handle && "USERS::OpenSearch is always correct"); -USER_PTR user; +STG::User* user; while (!users.SearchNext(handle, &user)) { if (user->GetDeleted()) continue; - std::string tariffName(user->GetProperty().tariffName.ConstData()); + std::string tariffName(user->GetProperties().tariffName.ConstData()); std::map<std::string, size_t>::iterator it(data.lower_bound(tariffName)); if (it == data.end() || it->first != tariffName) @@ -51,14 +62,9 @@ OID prefixOid(prefix); std::map<std::string, size_t>::const_iterator it(data.begin()); while (it != data.end()) { - sensors[prefixOid.copyWithSuffix(2, idx)] = new ConstSensor<std::string>(it->first); - sensors[prefixOid.copyWithSuffix(3, idx)] = new ConstSensor<int>(it->second); + sensors[prefixOid.copyWithSuffix(2, static_cast<unsigned int>(idx))] = new ConstSensor<std::string>(it->first); + sensors[prefixOid.copyWithSuffix(3, static_cast<unsigned int>(idx))] = new ConstSensor<unsigned long>(it->second); ++idx; ++it; } } - -std::pair<std::string, size_t> TD2Info(const TARIFF_DATA & td) -{ -return std::make_pair(td.tariffConf.name, 0); -}