]> git.stg.codes - stg.git/blob - projects/stargazer/settings_impl.h
Allow to have multi-leveled module settings.
[stg.git] / projects / stargazer / settings_impl.h
1 /*
2  *    This program is free software; you can redistribute it and/or modify
3  *    it under the terms of the GNU General Public License as published by
4  *    the Free Software Foundation; either version 2 of the License, or
5  *    (at your option) any later version.
6  *
7  *    This program is distributed in the hope that it will be useful,
8  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *    GNU General Public License for more details.
11  *
12  *    You should have received a copy of the GNU General Public License
13  *    along with this program; if not, write to the Free Software
14  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19  */
20
21 #ifndef SETTINGS_IMPL_H
22 #define SETTINGS_IMPL_H
23
24 #include <string>
25 #include <vector>
26
27 #include "stg/settings.h"
28 #include "stg/module_settings.h"
29 #include "stg/ref.h"
30
31 //-----------------------------------------------------------------------------
32 enum DETAIL_STAT_PERIOD {
33     dsPeriod_1,
34     dsPeriod_1_2,
35     dsPeriod_1_4,
36     dsPeriod_1_6
37 };
38 //-----------------------------------------------------------------------------
39 class STG_LOGGER;
40 class DOTCONFDocumentNode;
41 //-----------------------------------------------------------------------------
42 class SETTINGS_IMPL : public SETTINGS {
43 public:
44     SETTINGS_IMPL(const std::string &);
45     virtual ~SETTINGS_IMPL() {}
46     int Reload() { return ReadSettings(); }
47     int ReadSettings();
48
49     std::string GetStrError() const { return strError; }
50
51     int                 GetExecMsgKey() const { return stgExecMsgKey; }
52     unsigned            GetExecutersNum() const { return executersNum; }
53     const std::string & GetDirName(size_t num) const { return dirName[num]; }
54     const std::string & GetConfDir() const { return confDir; }
55     const std::string & GetScriptsDir() const { return scriptsDir; }
56     const std::string & GetRulesFileName() const { return rules; }
57     const std::string & GetLogFileName() const { return logFile; }
58     const std::string & GetPIDFileName() const { return pidFile; }
59     unsigned            GetDetailStatWritePeriod() const
60         { return detailStatWritePeriod; }
61     unsigned            GetStatWritePeriod() const { return statWritePeriod * 60; }
62     unsigned            GetDayFee() const { return dayFee; }
63     bool                GetFullFee() const { return fullFee; }
64     unsigned            GetDayResetTraff() const { return dayResetTraff; }
65     bool                GetSpreadFee() const { return spreadFee; }
66     bool                GetFreeMbAllowInet() const { return freeMbAllowInet; }
67     bool                GetDayFeeIsLastDay() const { return dayFeeIsLastDay; }
68     bool                GetWriteFreeMbTraffCost() const
69         { return writeFreeMbTraffCost; }
70     bool                GetShowFeeInCash() const { return showFeeInCash; }
71     const std::string & GetMonitorDir() const { return monitorDir; }
72     bool                GetMonitoring() const { return monitoring; }
73     unsigned            GetMessageTimeout() const { return messageTimeout * 3600 * 24; }
74     unsigned            GetFeeChargeType() const { return feeChargeType; }
75     bool                GetReconnectOnTariffChange() const { return reconnectOnTariffChange; }
76
77     const std::string & GetModulesPath() const { return modulesPath; }
78     const MODULE_SETTINGS & GetStoreModuleSettings() const
79         { return storeModuleSettings; }
80     const std::vector<MODULE_SETTINGS> & GetModulesSettings() const
81         { return modulesSettings; }
82     const std::vector<std::string> & GetScriptParams() const { return scriptParams; }
83
84 private:
85
86     static void ErrorCallback(void * data, const char * buf);
87
88     std::string strError;
89
90     //////////settings
91     std::string modulesPath;
92     std::vector<std::string> dirName;
93     std::string confDir;
94     std::string scriptsDir;
95     std::string rules;
96     std::string logFile;
97     std::string pidFile;
98     std::string monitorDir;
99     std::vector<std::string> scriptParams;
100     bool        monitoring;
101     unsigned    detailStatWritePeriod;
102     unsigned    statWritePeriod;
103     int         stgExecMsgKey;
104     unsigned    executersNum;
105     bool        fullFee;
106     unsigned    dayFee;
107     unsigned    dayResetTraff;
108     bool        spreadFee;
109     bool        freeMbAllowInet;
110     bool        dayFeeIsLastDay;
111     bool        writeFreeMbTraffCost;
112     bool        showFeeInCash;
113     unsigned    messageTimeout;
114     unsigned    feeChargeType;
115     bool        reconnectOnTariffChange;
116
117     std::vector<MODULE_SETTINGS> modulesSettings;
118     MODULE_SETTINGS storeModuleSettings;
119     STG::RefWrapper<STG_LOGGER> logger;
120 };
121 //-----------------------------------------------------------------------------
122
123 #endif