3 #include "stg/user_property.h"
4 #include "stg/tariffs.h"
5 #include "stg/tariff_conf.h"
13 using STG::TariffUsersTable;
18 std::pair<std::string, size_t> TD2Info(const STG::TariffData & td)
20 return std::make_pair(td.tariffConf.name, 0);
25 void TariffUsersTable::UpdateSensors(Sensors & sensors) const
27 std::map<std::string, size_t> data;
29 std::vector<STG::TariffData> tdl;
30 tariffs.GetTariffsData(&tdl);
31 std::transform(tdl.begin(),
33 std::inserter(data, data.begin()),
36 int handle = users.OpenSearch();
37 assert(handle && "USERS::OpenSearch is always correct");
40 while (!users.SearchNext(handle, &user))
42 if (user->GetDeleted())
44 std::string tariffName(user->GetProperties().tariffName.ConstData());
45 std::map<std::string, size_t>::iterator it(data.lower_bound(tariffName));
46 if (it == data.end() ||
47 it->first != tariffName)
49 data.insert(it, std::make_pair(tariffName, 1));
57 users.CloseSearch(handle);
60 OID prefixOid(prefix);
62 std::map<std::string, size_t>::const_iterator it(data.begin());
63 while (it != data.end())
65 sensors[prefixOid.copyWithSuffix(2, static_cast<unsigned int>(idx))] = new ConstSensor<std::string>(it->first);
66 sensors[prefixOid.copyWithSuffix(3, static_cast<unsigned int>(idx))] = new ConstSensor<unsigned long>(it->second);