]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/smux/tables.h
Various fixes of issues reported by static analyzers.
[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 class TARIFFS;
10 class USERS;
11
12 class TableSensor {
13     public:
14         explicit TableSensor(const std::string & p) : prefix(p) {}
15         virtual ~TableSensor() {}
16
17         const std::string & GetPrefix() const { return prefix; }
18         virtual void UpdateSensors(Sensors & sensors) const = 0;
19
20     protected:
21         std::string prefix;
22 };
23
24 class TariffUsersTable : public TableSensor {
25     public:
26         TariffUsersTable(const std::string & p,
27                          TARIFFS & t,
28                          USERS & u)
29             : TableSensor(p),
30               tariffs(t),
31               users(u)
32         {}
33         virtual ~TariffUsersTable() {}
34
35         void UpdateSensors(Sensors & sensors) const;
36
37     private:
38         TARIFFS & tariffs;
39         USERS & users;
40 };
41
42 typedef std::map<std::string, TableSensor *> Tables;
43
44 #endif