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