*/
-#ifndef settingsh_h
-#define settingsh_h 1
+#ifndef SETTINGS_H
+#define SETTINGS_H
-#include <sys/types.h>
+#include <string>
#include <vector>
-#include <dotconfpp.h>
#include "common.h"
-#include "base_settings.h"
#include "stg_logger.h"
-
-using namespace std;
+#include "module_settings.h"
//-----------------------------------------------------------------------------
-enum DETAIL_STAT_PERIOD
-{
+enum DETAIL_STAT_PERIOD {
dsPeriod_1,
dsPeriod_1_2,
dsPeriod_1_4,
dsPeriod_1_6,
};
//-----------------------------------------------------------------------------
-class SETTINGS
-{
+class STG_LOGGER;
+class DOTCONFDocumentNode;
+//-----------------------------------------------------------------------------
+class SETTINGS {
public:
SETTINGS();
SETTINGS(const std::string &);
SETTINGS(const SETTINGS &);
virtual ~SETTINGS();
- int Reload();
+ int Reload() { return ReadSettings(); }
int ReadSettings();
- string GetStrError() const;
-
- int GetExecMsgKey() const { return stgExecMsgKey; };
- int GetExecutersNum() const { return executersNum; };
- //int GetExecutersWaitTimeout() const;
- const string & GetDirName(int num) const { return dirName[num]; };
- const string & GetConfDir() const { return confDir; };
- const string & GetScriptDir() const { return scriptDir; };
- const string & GetRulesFileName() const { return rules; };
- const string & GetLogFileName() const { return logFile; };
- const string & GetPIDFileName() const { return pidFile; };
- int GetDetailStatWritePeriod() const
+ std::string GetStrError() const { return strError; }
+
+ int GetExecMsgKey() const { return stgExecMsgKey; }
+ unsigned GetExecutersNum() const { return executersNum; }
+ const std::string & GetDirName(int num) const { return dirName[num]; };
+ const std::string & GetConfDir() const { return confDir; }
+ const std::string & GetScriptsDir() const { return scriptsDir; }
+ const std::string & GetRulesFileName() const { return rules; }
+ const std::string & GetLogFileName() const { return logFile; }
+ const std::string & GetPIDFileName() const { return pidFile; }
+ unsigned GetDetailStatWritePeriod() const
{ return detailStatWritePeriod; };
- int GetStatWritePeriod() const { return statWritePeriod * 60; };
- int GetDayFee() const { return dayFee; };
- bool GetFullFee() const { return fullFee; };
- int GetDayResetTraff() const { return dayResetTraff; };
- bool GetSpreadFee() const { return spreadFee; };
- bool GetFreeMbAllowInet() const { return freeMbAllowInet; };
- bool GetDayFeeIsLastDay() const { return dayFeeIsLastDay; };
- bool GetWriteFreeMbTraffCost() const
+ unsigned GetStatWritePeriod() const { return statWritePeriod * 60; }
+ unsigned GetDayFee() const { return dayFee; }
+ bool GetFullFee() const { return fullFee; }
+ unsigned GetDayResetTraff() const { return dayResetTraff; }
+ bool GetSpreadFee() const { return spreadFee; }
+ bool GetFreeMbAllowInet() const { return freeMbAllowInet; }
+ bool GetDayFeeIsLastDay() const { return dayFeeIsLastDay; }
+ bool GetWriteFreeMbTraffCost() const
{ return writeFreeMbTraffCost; };
- bool GetShowFeeInCash() const { return showFeeInCash; };
- const string & GetMonitorDir() const { return monitorDir; };
- bool GetMonitoring() const { return monitoring; };
+ bool GetShowFeeInCash() const { return showFeeInCash; }
+ const std::string & GetMonitorDir() const { return monitorDir; }
+ bool GetMonitoring() const { return monitoring; }
+ unsigned GetMessageTimeout() const { return messageTimeout * 3600 * 24; }
- const string & GetModulesPath() const { return modulesPath; };
- const MODULE_SETTINGS & GetStoreModuleSettings() const;
- const vector<MODULE_SETTINGS> & GetModulesSettings() const;
+ const std::string & GetModulesPath() const { return modulesPath; }
+ const MODULE_SETTINGS & GetStoreModuleSettings() const
+ { return storeModuleSettings; }
+ const std::vector<MODULE_SETTINGS> & GetModulesSettings() const
+ { return modulesSettings; }
private:
- int ParseInt(const string & value, int * val);
- int ParseIntInRange(const string & value, int min, int max, int * val);
- int ParseYesNo(const string & value, bool * val);
- int ParseDetailStatWritePeriod(const string & detailStatPeriodStr);
+ int ParseInt(const std::string & value, int * val);
+ int ParseUnsigned(const std::string & value, unsigned * val);
+ int ParseIntInRange(const std::string & value, int min, int max, int * val);
+ int ParseUnsignedInRange(const std::string & value, unsigned min, unsigned max, unsigned * val);
+ int ParseYesNo(const std::string & value, bool * val);
+ int ParseDetailStatWritePeriod(const std::string & detailStatPeriodStr);
- int ParseModuleSettings(const DOTCONFDocumentNode * dirNameNode, vector<PARAM_VALUE> * params);
+ int ParseModuleSettings(const DOTCONFDocumentNode * dirNameNode, std::vector<PARAM_VALUE> * params);
static void ErrorCallback(void * data, const char * buf);
- string strError;
+ std::string strError;
+
//////////settings
- string modulesPath;
- string dirName[DIR_NUM];
- string confDir;
- string scriptDir;
- string rules;
- string logFile;
- string pidFile;
- string monitorDir;
+ std::string modulesPath;
+ std::string dirName[DIR_NUM];
+ std::string confDir;
+ std::string scriptsDir;
+ std::string rules;
+ std::string logFile;
+ std::string pidFile;
+ std::string monitorDir;
bool monitoring;
- int detailStatWritePeriod;
- int statWritePeriod;
+ unsigned detailStatWritePeriod;
+ unsigned statWritePeriod;
int stgExecMsgKey;
- int executersNum;
- //int executersWaitTimeout;
+ unsigned executersNum;
bool fullFee;
- int dayFee; // ÄÅÎØ ÓÎÑÔÉÑ ÁÂÏÎÐÌÁÔÙ
- int dayResetTraff; // îÁÞÁÌÏ ÕÞÅÔÎÏÇÏ ÐÅÒÉÏÄÁ: ÄÅÎØ ÏÂÎÕÌÅÎÉÑ ÔÒÁÆÉËÁ É ÓÍÅÎÙ ÔÁÒÉÆÁ
+ unsigned dayFee;
+ unsigned dayResetTraff;
bool spreadFee;
bool freeMbAllowInet;
- bool dayFeeIsLastDay; // áð ÓÎÉÍÁÅÔÓÑ × ËÏÎÃÅ ÍÅÓÑÃÁ (true) ÉÌÉ × ÎÁÞÁÌÅ (false)
- bool writeFreeMbTraffCost; // ðÉÓÁÔØ × ÄÅÔÁÌØÎÕÀ ÓÔÁÔÉÓÔÉËÕ ÓÔÏÉÍÏÓÔØ ÔÒÁÆÉËÁ, ÅÓÌÉ ÅÝÅ ÅÓÔØ ÐÒÅÄÏÐÌÁÞÅÎÎÙÊ ÔÒÁÆÉË
- bool showFeeInCash; // ðÏËÁÚÙ×ÁÔØ ÐÏÌØÚÏ×ÁÔÅÌÀ áð ÎÅ ÓÞÅÔÕ É ÐÏÚ×ÏÌÑÔØ ÅÅ ÉÓÐÏÌØÚÏ×ÁÔØ
+ bool dayFeeIsLastDay;
+ bool writeFreeMbTraffCost;
+ bool showFeeInCash;
+ unsigned messageTimeout;
- vector<MODULE_SETTINGS> modulesSettings;
- MODULE_SETTINGS storeModuleSettings;
+ std::vector<MODULE_SETTINGS> modulesSettings;
+ MODULE_SETTINGS storeModuleSettings;
STG_LOGGER & logger;
};
//-----------------------------------------------------------------------------
-#endif
+#endif