]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/configuration/sgconfig/stgconfig.h
Fix sgconfig plugin compilation errors
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / stgconfig.h
1 #ifndef STGCONFIG_H
2 #define STGCONFIG_H
3
4 #include <pthread.h>
5
6 #include <string>
7
8 #include "stg/plugin.h"
9 #include "stg/store.h"
10 #include "configproto.h"
11
12 extern "C" PLUGIN * GetPlugin();
13
14 class STG_CONFIG;
15
16 class STG_CONFIG_SETTINGS {
17 public:
18                     STG_CONFIG_SETTINGS();
19     virtual         ~STG_CONFIG_SETTINGS() {}
20     const std::string & GetStrError() const;
21     int             ParseSettings(const MODULE_SETTINGS & s);
22     uint16_t        GetPort() const;
23 private:
24     int     ParseIntInRange(const std::string & str, int min, int max, int * val);
25     std::string errorStr;
26     int     port;
27 };
28 //-----------------------------------------------------------------------------
29 class STG_CONFIG :public PLUGIN {
30 public:
31     STG_CONFIG();
32     virtual ~STG_CONFIG(){};
33
34     void                SetUsers(USERS * u);
35     void                SetTariffs(TARIFFS * t);
36     void                SetAdmins(ADMINS * a);
37     void                SetStore(STORE * s);
38     void                SetTraffcounter(TRAFFCOUNTER *) {}
39     void                SetStgSettings(const SETTINGS * s);
40     void                SetSettings(const MODULE_SETTINGS & s);
41     int                 ParseSettings();
42
43     int                 Start();
44     int                 Stop();
45     int                 Reload() { return 0; }
46     bool                IsRunning();
47
48     const std::string & GetStrError() const;
49     const std::string   GetVersion() const;
50     uint16_t            GetStartPosition() const;
51     uint16_t            GetStopPosition() const;
52
53 private:
54     static void *       Run(void *);
55     mutable std::string errorStr;
56     STG_CONFIG_SETTINGS stgConfigSettings;
57     pthread_t           thread;
58     bool                nonstop;
59     bool                isRunning;
60     CONFIGPROTO         config;
61     USERS *             users;
62     ADMINS *            admins;
63     TARIFFS *           tariffs;
64     STORE *             store;
65     MODULE_SETTINGS     settings;
66     const SETTINGS *    stgSettings;
67 };
68 //-----------------------------------------------------------------------------
69
70 #endif