]> git.stg.codes - stg.git/blob - stargazer/settings_impl.h
Port to CMake, get rid of os_int.h.
[stg.git] / 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 "stg/settings.h"
25 #include "stg/common.h"
26 #include "stg/module_settings.h"
27 #include "stg/ref.h"
28
29 #include <string>
30 #include <vector>
31
32 //-----------------------------------------------------------------------------
33 enum DETAIL_STAT_PERIOD {
34     dsPeriod_1,
35     dsPeriod_1_2,
36     dsPeriod_1_4,
37     dsPeriod_1_6
38 };
39 //-----------------------------------------------------------------------------
40 class STG_LOGGER;
41 class DOTCONFDocumentNode;
42 //-----------------------------------------------------------------------------
43 class SETTINGS_IMPL : public SETTINGS {
44 public:
45     explicit SETTINGS_IMPL(const std::string &);
46     SETTINGS_IMPL(const SETTINGS_IMPL & rhs);
47     virtual ~SETTINGS_IMPL() {}
48     SETTINGS_IMPL & operator=(const SETTINGS_IMPL &);
49
50     int Reload() { return ReadSettings(); }
51     int ReadSettings();
52
53     std::string GetStrError() const { return strError; }
54
55     int                 GetExecMsgKey() const { return stgExecMsgKey; }
56     unsigned            GetExecutersNum() const { return executersNum; }
57     const std::string & GetDirName(size_t num) const { return dirName[num]; }
58     const std::string & GetConfDir() const { return confDir; }
59     const std::string & GetScriptsDir() const { return scriptsDir; }
60     const std::string & GetRulesFileName() const { return rules; }
61     const std::string & GetLogFileName() const { return logFile; }
62     const std::string & GetPIDFileName() const { return pidFile; }
63     unsigned            GetDetailStatWritePeriod() const
64         { return detailStatWritePeriod; }
65     unsigned            GetStatWritePeriod() const { return statWritePeriod * 60; }
66     unsigned            GetDayFee() const { return dayFee; }
67     bool                GetFullFee() const { return fullFee; }
68     unsigned            GetDayResetTraff() const { return dayResetTraff; }
69     bool                GetSpreadFee() const { return spreadFee; }
70     bool                GetFreeMbAllowInet() const { return freeMbAllowInet; }
71     bool                GetDayFeeIsLastDay() const { return dayFeeIsLastDay; }
72     bool                GetStopOnError() const { return stopOnError; }
73     bool                GetWriteFreeMbTraffCost() const
74         { return writeFreeMbTraffCost; }
75     bool                GetShowFeeInCash() const { return showFeeInCash; }
76     const std::string & GetMonitorDir() const { return monitorDir; }
77     bool                GetMonitoring() const { return monitoring; }
78     unsigned            GetMessageTimeout() const { return messageTimeout * 3600 * 24; }
79     unsigned            GetFeeChargeType() const { return feeChargeType; }
80     bool                GetReconnectOnTariffChange() const { return reconnectOnTariffChange; }
81     bool                GetDisableSessionLog() const { return disableSessionLog; }
82     const std::vector<std::string> & GetFilterParamsLog() const { return filterParamsLog; }
83
84     const std::string & GetModulesPath() const { return modulesPath; }
85     const MODULE_SETTINGS & GetStoreModuleSettings() const
86         { return storeModuleSettings; }
87     const std::vector<MODULE_SETTINGS> & GetModulesSettings() const
88         { return modulesSettings; }
89     const std::vector<std::string> & GetScriptParams() const { return scriptParams; }
90
91 private:
92
93     static void ErrorCallback(void * data, const char * buf);
94
95     std::string strError;
96
97     //////////settings
98     std::string modulesPath;
99     std::vector<std::string> dirName;
100     std::string confDir;
101     std::string scriptsDir;
102     std::string rules;
103     std::string logFile;
104     std::string pidFile;
105     std::string monitorDir;
106     std::vector<std::string> scriptParams;
107     bool        monitoring;
108     unsigned    detailStatWritePeriod;
109     unsigned    statWritePeriod;
110     int         stgExecMsgKey;
111     unsigned    executersNum;
112     bool        fullFee;
113     unsigned    dayFee;
114     unsigned    dayResetTraff;
115     bool        spreadFee;
116     bool        freeMbAllowInet;
117     bool        dayFeeIsLastDay;
118     bool        stopOnError;
119     bool        writeFreeMbTraffCost;
120     bool        showFeeInCash;
121     unsigned    messageTimeout;
122     unsigned    feeChargeType;
123     bool        reconnectOnTariffChange;
124     bool        disableSessionLog;
125     std::vector<std::string> filterParamsLog;
126
127     std::vector<MODULE_SETTINGS> modulesSettings;
128     MODULE_SETTINGS storeModuleSettings;
129     STG::RefWrapper<STG_LOGGER> logger;
130 };
131 //-----------------------------------------------------------------------------
132
133 #endif