]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/smux/tables.cpp
New signal handling infrastructure. Prevent unloading running module.
[stg.git] / projects / stargazer / plugins / other / smux / tables.cpp
index 023b90b2b1df4f6f5db8d5b818368ca03d30b072..ad08c40f02acd03794aefa2b996d1ea6729ab2cd 100644 (file)
@@ -1,20 +1,35 @@
+#include <cassert>
 #include <utility>
+#include <iterator>
+#include <algorithm>
 
 #include "stg/user_property.h"
+#include "stg/tariffs.h"
+#include "stg/users.h"
 
 #include "tables.h"
 
+std::pair<std::string, size_t> TD2Info(const TARIFF_DATA & td);
+
 void TariffUsersTable::UpdateSensors(Sensors & sensors) const
 {
 std::map<std::string, size_t> data;
 
+std::list<TARIFF_DATA> 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))
     {
+    if (user->GetDeleted())
+        continue;
     std::string tariffName(user->GetProperty().tariffName.ConstData());
     std::map<std::string, size_t>::iterator it;
     it = data.lower_bound(tariffName);
@@ -43,3 +58,8 @@ while (it != data.end())
     ++it;
     }
 }
+
+std::pair<std::string, size_t> TD2Info(const TARIFF_DATA & td)
+{
+return std::make_pair(td.tariffConf.name, 0);
+}