]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/configuration/sgconfig2/stgconfig.h
Добавление исходников
[stg.git] / projects / stargazer / plugins / configuration / sgconfig2 / stgconfig.h
1 #include <pthread.h>
2
3 #include <string>
4 #include <list>
5
6 #include "base_plugin.h"
7 #include "base_store.h"
8 #include "configproto.h"
9
10 using namespace std;
11
12 extern "C" BASE_PLUGIN * GetPlugin();
13
14 class STG_CONFIG;
15
16 //-----------------------------------------------------------------------------
17 class STG_CONFIG_SETTINGS
18 {
19 public:
20                     STG_CONFIG_SETTINGS();
21     virtual         ~STG_CONFIG_SETTINGS(){};
22     const string &  GetStrError() const;
23     int             ParseSettings(const MODULE_SETTINGS & s);
24     uint16_t        GetPort();
25 private:
26     int     ParseIntInRange(const string & str, int min, int max, int * val);
27     string  errorStr;
28     int     port;
29 };
30 //-----------------------------------------------------------------------------
31 class STG_CONFIG: public BASE_PLUGIN
32 {
33 public:
34     STG_CONFIG();
35     virtual ~STG_CONFIG(){};
36
37     void                SetUsers(USERS * u) { users = u; };
38     void                SetTariffs(TARIFFS * t) { tariffs = t; };
39     void                SetAdmins(ADMINS * a) { admins = a; };
40     void                SetStore(BASE_STORE * s) { store = s; };
41     void                SetTraffcounter(TRAFFCOUNTER *) {};
42     void                SetStgSettings(const SETTINGS * s) { stgConfigSettings = s; };
43     void                SetSettings(const MODULE_SETTINGS & s) { settings = s; };
44     int                 ParseSettings();
45
46     int                 Start();
47     int                 Stop();
48     int                 Reload() { return 0; };
49     bool                IsRunning() { return running; };
50
51     const string      & GetStrError() const { return errorStr; };
52     string              GetVersion() const;
53     uint16_t            GetStartPosition() const;
54     uint16_t            GetStopPosition() const;
55
56 private:
57     static void *       Run(void *);
58     void                RealRun();
59     bool                PrepareNetwork();
60     bool                FinalizeNetwork();
61     void                AcceptConnection();
62
63     mutable string      errorStr;
64     STG_CONFIG_SETTINGS stgConfigSettings;
65     pthread_t           thread;
66     bool                running;
67     bool                stopped;
68     CONFIGPROTO         config;
69     USERS *             users;
70     ADMINS *            admins;
71     TARIFFS *           tariffs;
72     BASE_STORE *        store;
73     MODULE_SETTINGS     settings;
74     const SETTINGS *    stgSettings;
75
76     std::list<ConnectionThread *> connections;
77
78     int                 sd;
79 };
80 //-----------------------------------------------------------------------------