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