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