]> git.stg.codes - stg.git/blob - projects/stargazer/settings.h
711b43e6c4dbc679c7424c9ceda572017034555e
[stg.git] / projects / stargazer / settings.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_H
38 #define SETTINGS_H
39
40 #include <vector>
41
42 #include "common.h"
43 #include "base_settings.h"
44
45 using namespace std;
46
47 //-----------------------------------------------------------------------------
48 enum DETAIL_STAT_PERIOD
49 {
50 dsPeriod_1,
51 dsPeriod_1_2,
52 dsPeriod_1_4,
53 dsPeriod_1_6,
54 };
55 //-----------------------------------------------------------------------------
56 class STG_LOGGER;
57 class DOTCONFDocumentNode;
58 //-----------------------------------------------------------------------------
59 class SETTINGS
60 {
61 public:
62     SETTINGS();
63     SETTINGS(const std::string &);
64     SETTINGS(const SETTINGS &);
65     virtual ~SETTINGS();
66     int Reload() { return ReadSettings(); };
67     int ReadSettings();
68
69     string GetStrError() const { return strError; };
70
71     int             GetExecMsgKey() const { return stgExecMsgKey; };
72     unsigned        GetExecutersNum() const { return executersNum; };
73     const string &  GetDirName(int num) const { return dirName[num]; };
74     const string &  GetConfDir() const { return confDir; };
75     const string &  GetScriptDir() const { return scriptDir; };
76     const string &  GetRulesFileName() const { return rules; };
77     const string &  GetLogFileName() const { return logFile; };
78     const string &  GetPIDFileName() const { return pidFile; };
79     unsigned        GetDetailStatWritePeriod() const 
80         { return detailStatWritePeriod; };
81     unsigned        GetStatWritePeriod() const { return statWritePeriod * 60; };
82     unsigned        GetDayFee() const { return dayFee; };
83     bool            GetFullFee() const { return fullFee; };
84     unsigned        GetDayResetTraff() const { return dayResetTraff; };
85     bool            GetSpreadFee() const { return spreadFee; };
86     bool            GetFreeMbAllowInet() const { return freeMbAllowInet; };
87     bool            GetDayFeeIsLastDay() const { return dayFeeIsLastDay; };
88     bool            GetWriteFreeMbTraffCost() const
89         { return writeFreeMbTraffCost; };
90     bool            GetShowFeeInCash() const { return showFeeInCash; };
91     const string  & GetMonitorDir() const { return monitorDir; };
92     bool            GetMonitoring() const { return monitoring; };
93     unsigned        GetMessageTimeout() const { return messageTimeout * 3600 * 24; };
94
95     const string &  GetModulesPath() const { return modulesPath; };
96     const MODULE_SETTINGS         & GetStoreModuleSettings() const
97         { return storeModuleSettings; };
98     const vector<MODULE_SETTINGS> & GetModulesSettings() const
99         { return modulesSettings; };
100
101 private:
102
103     int ParseInt(const string & value, int * val);
104     int ParseUnsigned(const string & value, unsigned * val);
105     int ParseIntInRange(const string & value, int min, int max, int * val);
106     int ParseUnsignedInRange(const string & value, unsigned min, unsigned max, unsigned * val);
107     int ParseYesNo(const string & value, bool * val);
108     int ParseDetailStatWritePeriod(const string & detailStatPeriodStr);
109
110     int ParseModuleSettings(const DOTCONFDocumentNode * dirNameNode, vector<PARAM_VALUE> * params);
111
112     static void ErrorCallback(void * data, const char * buf);
113
114     string      strError;
115     //////////settings
116     string      modulesPath;
117     string      dirName[DIR_NUM];
118     string      confDir;
119     string      scriptDir;
120     string      rules;
121     string      logFile;
122     string      pidFile;
123     string      monitorDir;
124     bool        monitoring;
125     unsigned    detailStatWritePeriod;
126     unsigned    statWritePeriod;
127     int         stgExecMsgKey;
128     unsigned    executersNum;
129     bool        fullFee;
130     unsigned    dayFee;        // ÄÅÎØ ÓÎÑÔÉÑ ÁÂÏÎÐÌÁÔÙ
131     unsigned    dayResetTraff; // îÁÞÁÌÏ ÕÞÅÔÎÏÇÏ ÐÅÒÉÏÄÁ: ÄÅÎØ ÏÂÎÕÌÅÎÉÑ ÔÒÁÆÉËÁ É ÓÍÅÎÙ ÔÁÒÉÆÁ
132     bool        spreadFee;
133     bool        freeMbAllowInet;
134     bool        dayFeeIsLastDay; // áð ÓÎÉÍÁÅÔÓÑ × ËÏÎÃÅ ÍÅÓÑÃÁ (true) ÉÌÉ × ÎÁÞÁÌÅ (false)
135     bool        writeFreeMbTraffCost; // ðÉÓÁÔØ × ÄÅÔÁÌØÎÕÀ ÓÔÁÔÉÓÔÉËÕ ÓÔÏÉÍÏÓÔØ ÔÒÁÆÉËÁ, ÅÓÌÉ ÅÝÅ ÅÓÔØ ÐÒÅÄÏÐÌÁÞÅÎÎÙÊ ÔÒÁÆÉË
136     bool        showFeeInCash; // ðÏËÁÚÙ×ÁÔØ ÐÏÌØÚÏ×ÁÔÅÌÀ áð ÎÅ ÓÞÅÔÕ É ÐÏÚ×ÏÌÑÔØ ÅÅ ÉÓÐÏÌØÚÏ×ÁÔØ
137     unsigned    messageTimeout; // ÷ÒÅÍÑ ÖÉÚÎÉ ÎÅÏÔÐÒÁ×ÌÅÎÎÏÇÏ ÓÏÏÂÝÅÎÉÑ × ÓÅËÕÎÄÁÈ
138
139     vector<MODULE_SETTINGS> modulesSettings;
140     MODULE_SETTINGS         storeModuleSettings;
141
142     STG_LOGGER & logger;
143 };
144 //-----------------------------------------------------------------------------
145 #endif