]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/configuration/sgconfig/stgconfig.h
Реализована инициализация членов главного класса плагина конфигуратора
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / stgconfig.h
1 #include <string>
2 #include <pthread.h>
3 #include "base_plugin.h"
4 #include "base_store.h"
5 #include "configproto.h"
6 //#include "user_ips.h"
7 //#include "../../../users.h"
8
9 using namespace std;
10
11 extern "C" BASE_PLUGIN * GetPlugin();
12
13 class STG_CONFIG;
14
15 //-----------------------------------------------------------------------------
16 /*template <typename varParamType>
17 class CHG_BEFORE_NOTIFIER: public PROPERTY_NOTIFIER_BASE<varParamType>
18 {
19 public:
20     void Notify(const varParamType & oldValue, const varParamType & newValue)
21         {
22         auth->Unauthorize(user);
23         }
24     void SetUser(USER * u) { user = u; }
25     void SetAuthorizaror(const AUTH_AO * a) { auth = a; }
26
27 private:
28     USER * user;
29     const AUTH_AO * auth;
30 };
31 //-----------------------------------------------------------------------------
32 template <typename varParamType>
33 class CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE<varParamType>
34 {
35 public:
36     void Notify(const varParamType & oldValue, const varParamType & newValue)
37         {
38         auth->UpdateUserAuthorization(user);
39         }
40     void SetUser(USER * u) { user = u; }
41     void SetAuthorizaror(const AUTH_AO * a) { auth = a; }
42
43 private:
44     USER * user;
45     const AUTH_AO * auth;
46 };*/
47 //-----------------------------------------------------------------------------
48 class STG_CONFIG_SETTINGS
49 {
50 public:
51                     STG_CONFIG_SETTINGS();
52     virtual         ~STG_CONFIG_SETTINGS(){};
53     const string &  GetStrError() const;
54     int             ParseSettings(const MODULE_SETTINGS & s);
55     uint16_t        GetPort() const;
56 private:
57     int     ParseIntInRange(const string & str, int min, int max, int * val);
58     string  errorStr;
59     int     port;
60 };
61 //-----------------------------------------------------------------------------
62 class STG_CONFIG :public BASE_PLUGIN
63 {
64 public:
65     STG_CONFIG();
66     virtual ~STG_CONFIG(){};
67
68     void                SetUsers(USERS * u);
69     void                SetTariffs(TARIFFS * t);
70     void                SetAdmins(ADMINS * a);
71     void                SetStore(BASE_STORE * s);
72     void                SetTraffcounter(TRAFFCOUNTER *){};
73     void                SetStgSettings(const SETTINGS * s);
74     void                SetSettings(const MODULE_SETTINGS & s);
75     int                 ParseSettings();
76
77     int                 Start();
78     int                 Stop();
79     int                 Reload() { return 0; };
80     bool                IsRunning();
81
82     const string      & GetStrError() const;
83     const string        GetVersion() const;
84     uint16_t            GetStartPosition() const;
85     uint16_t            GetStopPosition() const;
86
87 private:
88     static void *       Run(void *);
89     mutable string      errorStr;
90     STG_CONFIG_SETTINGS stgConfigSettings;
91     pthread_t           thread;
92     bool                nonstop;
93     bool                isRunning;
94     CONFIGPROTO         config;
95     USERS *             users;
96     ADMINS *            admins;
97     TARIFFS *           tariffs;
98     BASE_STORE *        store;
99     MODULE_SETTINGS     settings;
100     const SETTINGS *    stgSettings;
101 };
102 //-----------------------------------------------------------------------------
103
104