6 #include "stg/user_property.h"
7 #include "stg/tariffs.h"
12 std::pair<std::string, size_t> TD2Info(const TARIFF_DATA & td);
14 void TariffUsersTable::UpdateSensors(Sensors & sensors) const
16 std::map<std::string, size_t> data;
18 std::list<TARIFF_DATA> tdl;
19 tariffs.GetTariffsData(&tdl);
20 std::transform(tdl.begin(),
22 std::inserter(data, data.begin()),
25 int handle = users.OpenSearch();
26 assert(handle && "USERS::OpenSearch is always correct");
29 while (!users.SearchNext(handle, &user))
31 std::string tariffName(user->GetProperty().tariffName.ConstData());
32 std::map<std::string, size_t>::iterator it;
33 it = data.lower_bound(tariffName);
34 if (it == data.end() ||
35 it->first != tariffName)
37 data.insert(it, std::make_pair(tariffName, 1));
45 users.CloseSearch(handle);
48 OID prefixOid(prefix);
50 std::map<std::string, size_t>::const_iterator it(data.begin());
51 while (it != data.end())
53 sensors[prefixOid.copyWithSuffix(2, idx)] = new ConstSensor<std::string>(it->first);
54 sensors[prefixOid.copyWithSuffix(3, idx)] = new ConstSensor<int>(it->second);
60 std::pair<std::string, size_t> TD2Info(const TARIFF_DATA & td)
62 return std::make_pair(td.tariffConf.name, 0);