From f47613c7f556160a73003a09797750c58cc3fc74 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 1 Sep 2011 13:59:54 +0300 Subject: [PATCH] Make tariff table based on tariff list --- .../stargazer/plugins/other/smux/tables.cpp | 22 +++++++++++++++++-- .../stargazer/plugins/other/smux/tables.h | 6 +++++ 2 files changed, 26 insertions(+), 2 deletions(-) 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; }; -- 2.43.2