]> git.stg.codes - stg.git/blob - projects/stargazer/settings_impl.h
stg-2.409 pre-merge.
[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/logger.h"
46 #include "stg/module_settings.h"
47
48 //-----------------------------------------------------------------------------
49 enum DETAIL_STAT_PERIOD {
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_IMPL : public SETTINGS {
60 public:
61     SETTINGS_IMPL(const std::string &);
62     SETTINGS_IMPL(const SETTINGS_IMPL &);
63     virtual ~SETTINGS_IMPL() {}
64     SETTINGS_IMPL & operator=(const SETTINGS_IMPL &);
65
66     int Reload() { return ReadSettings(); }
67     int ReadSettings();
68
69     std::string GetStrError() const { return strError; }
70
71     int                 GetExecMsgKey() const { return stgExecMsgKey; }
72     unsigned            GetExecutersNum() const { return executersNum; }
73     const std::string & GetDirName(size_t num) const { return dirName[num]; }
74     const std::string & GetConfDir() const { return confDir; }
75     const std::string & GetScriptsDir() const { return scriptsDir; }
76     const std::string & GetRulesFileName() const { return rules; }
77     const std::string & GetLogFileName() const { return logFile; }
78     const std::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                GetStopOnError() const { return stopOnError; }
89     bool                GetWriteFreeMbTraffCost() const
90         { return writeFreeMbTraffCost; }
91     bool                GetShowFeeInCash() const { return showFeeInCash; }
92     const std::string & GetMonitorDir() const { return monitorDir; }
93     bool                GetMonitoring() const { return monitoring; }
94     unsigned            GetMessageTimeout() const { return messageTimeout * 3600 * 24; }
95     unsigned            GetFeeChargeType() const { return feeChargeType; }
96     bool                GetReconnectOnTariffChange() const { return reconnectOnTariffChange; }
97
98     const std::string & GetModulesPath() const { return modulesPath; }
99     const MODULE_SETTINGS & GetStoreModuleSettings() const
100         { return storeModuleSettings; }
101     const std::vector<MODULE_SETTINGS> & GetModulesSettings() const
102         { return modulesSettings; }
103     const std::vector<std::string> & GetScriptParams() const { return scriptParams; }
104
105 private:
106
107     int ParseDetailStatWritePeriod(const std::string & str);
108     int ParseModuleSettings(const DOTCONFDocumentNode * dirNameNode, std::vector<PARAM_VALUE> * params);
109
110     static void ErrorCallback(void * data, const char * buf);
111
112     std::string strError;
113
114     //////////settings
115     std::string modulesPath;
116     std::vector<std::string> dirName;
117     std::string confDir;
118     std::string scriptsDir;
119     std::string rules;
120     std::string logFile;
121     std::string pidFile;
122     std::string monitorDir;
123     std::vector<std::string> scriptParams;
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;
135     bool        stopOnError;
136     bool        writeFreeMbTraffCost;
137     bool        showFeeInCash;
138     unsigned    messageTimeout;
139     unsigned    feeChargeType;
140     bool        reconnectOnTariffChange;
141
142     std::vector<MODULE_SETTINGS> modulesSettings;
143     MODULE_SETTINGS storeModuleSettings;
144     STG_LOGGER & logger;
145 };
146 //-----------------------------------------------------------------------------
147
148 #endif