3 $Date: 2010/08/19 13:42:30 $
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.
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.
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
28 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
33 $Date: 2010/08/19 13:42:30 $
44 #include "stg_logger.h"
45 #include "module_settings.h"
47 //-----------------------------------------------------------------------------
48 enum DETAIL_STAT_PERIOD {
54 //-----------------------------------------------------------------------------
56 class DOTCONFDocumentNode;
57 //-----------------------------------------------------------------------------
61 SETTINGS(const std::string &);
62 SETTINGS(const SETTINGS &);
64 int Reload() { return ReadSettings(); }
67 std::string GetStrError() const { return strError; }
69 int GetExecMsgKey() const { return stgExecMsgKey; }
70 unsigned GetExecutersNum() const { return executersNum; }
71 const std::string & GetDirName(int num) const { return dirName[num]; };
72 const std::string & GetConfDir() const { return confDir; }
73 const std::string & GetScriptDir() const { return scriptDir; }
74 const std::string & GetRulesFileName() const { return rules; }
75 const std::string & GetLogFileName() const { return logFile; }
76 const std::string & GetPIDFileName() const { return pidFile; }
77 unsigned GetDetailStatWritePeriod() const
78 { return detailStatWritePeriod; };
79 unsigned GetStatWritePeriod() const { return statWritePeriod * 60; }
80 unsigned GetDayFee() const { return dayFee; }
81 bool GetFullFee() const { return fullFee; }
82 unsigned GetDayResetTraff() const { return dayResetTraff; }
83 bool GetSpreadFee() const { return spreadFee; }
84 bool GetFreeMbAllowInet() const { return freeMbAllowInet; }
85 bool GetDayFeeIsLastDay() const { return dayFeeIsLastDay; }
86 bool GetWriteFreeMbTraffCost() const
87 { return writeFreeMbTraffCost; };
88 bool GetShowFeeInCash() const { return showFeeInCash; }
89 const std::string & GetMonitorDir() const { return monitorDir; }
90 bool GetMonitoring() const { return monitoring; }
91 unsigned GetMessageTimeout() const { return messageTimeout * 3600 * 24; }
93 const std::string & GetModulesPath() const { return modulesPath; }
94 const MODULE_SETTINGS & GetStoreModuleSettings() const
95 { return storeModuleSettings; }
96 const std::vector<MODULE_SETTINGS> & GetModulesSettings() const
97 { return modulesSettings; }
101 int ParseInt(const std::string & value, int * val);
102 int ParseUnsigned(const std::string & value, unsigned * val);
103 int ParseIntInRange(const std::string & value, int min, int max, int * val);
104 int ParseUnsignedInRange(const std::string & value, unsigned min, unsigned max, unsigned * val);
105 int ParseYesNo(const std::string & value, bool * val);
106 int ParseDetailStatWritePeriod(const std::string & detailStatPeriodStr);
108 int ParseModuleSettings(const DOTCONFDocumentNode * dirNameNode, std::vector<PARAM_VALUE> * params);
110 static void ErrorCallback(void * data, const char * buf);
112 std::string strError;
114 std::string modulesPath;
115 std::string dirName[DIR_NUM];
117 std::string scriptDir;
121 std::string monitorDir;
123 unsigned detailStatWritePeriod;
124 unsigned statWritePeriod;
126 unsigned executersNum;
128 unsigned dayFee; // ÄÅÎØ ÓÎÑÔÉÑ ÁÂÏÎÐÌÁÔÙ
129 unsigned dayResetTraff; // îÁÞÁÌÏ ÕÞÅÔÎÏÇÏ ÐÅÒÉÏÄÁ: ÄÅÎØ ÏÂÎÕÌÅÎÉÑ ÔÒÁÆÉËÁ É ÓÍÅÎÙ ÔÁÒÉÆÁ
131 bool freeMbAllowInet;
132 bool dayFeeIsLastDay; // áð ÓÎÉÍÁÅÔÓÑ × ËÏÎÃÅ ÍÅÓÑÃÁ (true) ÉÌÉ × ÎÁÞÁÌÅ (false)
133 bool writeFreeMbTraffCost; // ðÉÓÁÔØ × ÄÅÔÁÌØÎÕÀ ÓÔÁÔÉÓÔÉËÕ ÓÔÏÉÍÏÓÔØ ÔÒÁÆÉËÁ, ÅÓÌÉ ÅÝÅ ÅÓÔØ ÐÒÅÄÏÐÌÁÞÅÎÎÙÊ ÔÒÁÆÉË
134 bool showFeeInCash; // ðÏËÁÚÙ×ÁÔØ ÐÏÌØÚÏ×ÁÔÅÌÀ áð ÎÅ ÓÞÅÔÕ É ÐÏÚ×ÏÌÑÔØ ÅÅ ÉÓÐÏÌØÚÏ×ÁÔØ
135 unsigned messageTimeout; // ÷ÒÅÍÑ ÖÉÚÎÉ ÎÅÏÔÐÒÁ×ÌÅÎÎÏÇÏ ÓÏÏÂÝÅÎÉÑ × ÓÅËÕÎÄÁÈ
137 std::vector<MODULE_SETTINGS> modulesSettings;
138 MODULE_SETTINGS storeModuleSettings;
142 //-----------------------------------------------------------------------------