git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix debug build, use separate clang-tidy config.
[stg.git]
/
projects
/
stargazer
/
plugins
/
other
/
smux
/
tables.cpp
diff --git
a/projects/stargazer/plugins/other/smux/tables.cpp
b/projects/stargazer/plugins/other/smux/tables.cpp
index 023b90b2b1df4f6f5db8d5b818368ca03d30b072..ead98f38755bb27f82a68bbbaa4704e69d40e0cf 100644
(file)
--- a/
projects/stargazer/plugins/other/smux/tables.cpp
+++ b/
projects/stargazer/plugins/other/smux/tables.cpp
@@
-1,23
+1,48
@@
-#include
<utility>
+#include
"tables.h"
#include "stg/user_property.h"
#include "stg/user_property.h"
+#include "stg/tariffs.h"
+#include "stg/tariff_conf.h"
+#include "stg/users.h"
-#include "tables.h"
+#include <utility>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+using STG::TariffUsersTable;
+
+namespace
+{
+
+std::pair<std::string, size_t> TD2Info(const STG::TariffData & td)
+{
+ return std::make_pair(td.tariffConf.name, 0);
+}
+
+}
void TariffUsersTable::UpdateSensors(Sensors & sensors) const
{
std::map<std::string, size_t> data;
void TariffUsersTable::UpdateSensors(Sensors & sensors) const
{
std::map<std::string, size_t> data;
+std::vector<STG::TariffData> tdl;
+tariffs.GetTariffsData(&tdl);
+std::transform(tdl.begin(),
+ tdl.end(),
+ std::inserter(data, data.begin()),
+ TD2Info);
+
int handle = users.OpenSearch();
int handle = users.OpenSearch();
-if (!handle)
- return;
+assert(handle && "USERS::OpenSearch is always correct");
-
USER_PTR
user;
+
STG::User*
user;
while (!users.SearchNext(handle, &user))
{
while (!users.SearchNext(handle, &user))
{
- std::string tariffName(user->GetProperty().tariffName.ConstData());
- std::map<std::string, size_t>::iterator it;
- it = data.lower_bound(tariffName);
+ if (user->GetDeleted())
+ continue;
+ std::string tariffName(user->GetProperties().tariffName.ConstData());
+ std::map<std::string, size_t>::iterator it(data.lower_bound(tariffName));
if (it == data.end() ||
it->first != tariffName)
{
if (it == data.end() ||
it->first != tariffName)
{
@@
-37,8
+62,8
@@
OID prefixOid(prefix);
std::map<std::string, size_t>::const_iterator it(data.begin());
while (it != data.end())
{
std::map<std::string, size_t>::const_iterator it(data.begin());
while (it != data.end())
{
- sensors[prefixOid.copyWithSuffix(2,
idx
)] = new ConstSensor<std::string>(it->first);
- sensors[prefixOid.copyWithSuffix(3,
idx)] = new ConstSensor<int
>(it->second);
+ sensors[prefixOid.copyWithSuffix(2,
static_cast<unsigned int>(idx)
)] = new ConstSensor<std::string>(it->first);
+ sensors[prefixOid.copyWithSuffix(3,
static_cast<unsigned int>(idx))] = new ConstSensor<unsigned long
>(it->second);
++idx;
++it;
}
++idx;
++it;
}