From: Maxim Mamontov Date: Thu, 1 Sep 2011 10:59:54 +0000 (+0300) Subject: Make tariff table based on tariff list X-Git-Tag: 2.408-alpha~6 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/f47613c7f556160a73003a09797750c58cc3fc74 Make tariff table based on tariff list --- diff --git a/projects/stargazer/plugins/other/smux/tables.cpp b/projects/stargazer/plugins/other/smux/tables.cpp index 023b90b2..962c91a8 100644 --- a/projects/stargazer/plugins/other/smux/tables.cpp +++ b/projects/stargazer/plugins/other/smux/tables.cpp @@ -1,16 +1,29 @@ +#include #include +#include +#include #include "stg/user_property.h" +#include "stg/tariffs.h" +#include "stg/users.h" #include "tables.h" +std::pair TD2Info(const TARIFF_DATA & td); + void TariffUsersTable::UpdateSensors(Sensors & sensors) const { std::map data; +std::list tdl; +tariffs.GetTariffsData(&tdl); +std::transform(tdl.begin(), + tdl.end(), + std::inserter(data, data.begin()), + TD2Info); + int handle = users.OpenSearch(); -if (!handle) - return; +assert(handle && "USERS::OpenSearch is always correct"); USER_PTR user; while (!users.SearchNext(handle, &user)) @@ -43,3 +56,8 @@ while (it != data.end()) ++it; } } + +std::pair TD2Info(const TARIFF_DATA & td) +{ +return std::make_pair(td.tariffConf.name, 0); +} diff --git a/projects/stargazer/plugins/other/smux/tables.h b/projects/stargazer/plugins/other/smux/tables.h index ad3b55a3..ea0bc627 100644 --- a/projects/stargazer/plugins/other/smux/tables.h +++ b/projects/stargazer/plugins/other/smux/tables.h @@ -6,6 +6,9 @@ #include "sensors.h" +class TARIFFS; +class USERS; + class TableSensor { public: TableSensor(const std::string & p) : prefix(p) {} @@ -21,8 +24,10 @@ class TableSensor { class TariffUsersTable : public TableSensor { public: TariffUsersTable(const std::string & p, + TARIFFS & t, USERS & u) : TableSensor(p), + tariffs(t), users(u) {} virtual ~TariffUsersTable() {} @@ -30,6 +35,7 @@ class TariffUsersTable : public TableSensor { void UpdateSensors(Sensors & sensors) const; private: + TARIFFS & tariffs; USERS & users; };