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