]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/smux/tables.h
Use std::lock_guard instead of STG_LOCKER.
[stg.git] / projects / stargazer / plugins / other / smux / tables.h
1 #pragma once
2
3 #include "sensors.h"
4
5 #include <string>
6 #include <map>
7
8 namespace STG
9 {
10 class Tariffs;
11 class Users;
12
13 class TableSensor {
14     public:
15         explicit TableSensor(const std::string & p) : prefix(p) {}
16         virtual ~TableSensor() {}
17
18         const std::string & GetPrefix() const { return prefix; }
19         virtual void UpdateSensors(Sensors & sensors) const = 0;
20
21     protected:
22         std::string prefix;
23 };
24
25 class TariffUsersTable : public TableSensor {
26     public:
27         TariffUsersTable(const std::string & p,
28                          STG::Tariffs & t,
29                          STG::Users & u)
30             : TableSensor(p),
31               tariffs(t),
32               users(u)
33         {}
34
35         void UpdateSensors(Sensors & sensors) const override;
36
37     private:
38         STG::Tariffs & tariffs;
39         STG::Users & users;
40 };
41
42 typedef std::map<std::string, TableSensor *> Tables;
43 }