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