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