]> git.stg.codes - stg.git/blob - projects/stargazer/settings_impl.h
Merge branch 'stg-2.409' into stg-2.409-radius
[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/common.h"
29 #include "stg/module_settings.h"
30 #include "stg/ref.h"
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     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                GetWriteFreeMbTraffCost() const
73         { return writeFreeMbTraffCost; }
74     bool                GetShowFeeInCash() const { return showFeeInCash; }
75     const std::string & GetMonitorDir() const { return monitorDir; }
76     bool                GetMonitoring() const { return monitoring; }
77     unsigned            GetMessageTimeout() const { return messageTimeout * 3600 * 24; }
78     unsigned            GetFeeChargeType() const { return feeChargeType; }
79     bool                GetReconnectOnTariffChange() const { return reconnectOnTariffChange; }
80     bool                GetDisableSessionLog() const { return disableSessionLog; }
81     const std::vector<std::string> & GetFilterParamsLog() const { return filterParamsLog; }
82
83     const std::string & GetModulesPath() const { return modulesPath; }
84     const MODULE_SETTINGS & GetStoreModuleSettings() const
85         { return storeModuleSettings; }
86     const std::vector<MODULE_SETTINGS> & GetModulesSettings() const
87         { return modulesSettings; }
88     const std::vector<std::string> & GetScriptParams() const { return scriptParams; }
89
90 private:
91
92     static void ErrorCallback(void * data, const char * buf);
93
94     std::string strError;
95
96     //////////settings
97     std::string modulesPath;
98     std::vector<std::string> dirName;
99     std::string confDir;
100     std::string scriptsDir;
101     std::string rules;
102     std::string logFile;
103     std::string pidFile;
104     std::string monitorDir;
105     std::vector<std::string> scriptParams;
106     bool        monitoring;
107     unsigned    detailStatWritePeriod;
108     unsigned    statWritePeriod;
109     int         stgExecMsgKey;
110     unsigned    executersNum;
111     bool        fullFee;
112     unsigned    dayFee;
113     unsigned    dayResetTraff;
114     bool        spreadFee;
115     bool        freeMbAllowInet;
116     bool        dayFeeIsLastDay;
117     bool        writeFreeMbTraffCost;
118     bool        showFeeInCash;
119     unsigned    messageTimeout;
120     unsigned    feeChargeType;
121     bool        reconnectOnTariffChange;
122     bool        disableSessionLog;
123     std::vector<std::string> filterParamsLog;
124
125     std::vector<MODULE_SETTINGS> modulesSettings;
126     MODULE_SETTINGS storeModuleSettings;
127     STG::RefWrapper<STG_LOGGER> logger;
128 };
129 //-----------------------------------------------------------------------------
130
131 #endif