]> git.stg.codes - stg.git/blob - stargazer/plugins/other/smux/tables.h
Public interfaces: part 1
[stg.git] / 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         virtual ~TariffUsersTable() {}
37
38         void UpdateSensors(Sensors & sensors) const;
39
40     private:
41         STG::Tariffs & tariffs;
42         STG::Users & users;
43 };
44
45 typedef std::map<std::string, TableSensor *> Tables;
46
47 #endif