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