]> git.stg.codes - stg.git/blob - projects/stargazer/settings_impl.h
Use std::lock_guard instead of STG_LOCKER.
[stg.git] / projects / stargazer / settings_impl.h
1 /*
2  *    This program is free software; you can redistribute it and/or modify
3  *    it under the terms of the GNU General Public License as published by
4  *    the Free Software Foundation; either version 2 of the License, or
5  *    (at your option) any later version.
6  *
7  *    This program is distributed in the hope that it will be useful,
8  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *    GNU General Public License for more details.
11  *
12  *    You should have received a copy of the GNU General Public License
13  *    along with this program; if not, write to the Free Software
14  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16
17 /*
18  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19  */
20
21 #pragma once
22
23 #include "stg/settings.h"
24 #include "stg/common.h"
25 #include "stg/module_settings.h"
26
27 #include <string>
28 #include <vector>
29
30 class DOTCONFDocumentNode;
31
32 namespace STG
33 {
34
35 //-----------------------------------------------------------------------------
36 enum DETAIL_STAT_PERIOD {
37     dsPeriod_1,
38     dsPeriod_1_2,
39     dsPeriod_1_4,
40     dsPeriod_1_6
41 };
42 //-----------------------------------------------------------------------------
43 class SettingsImpl : public Settings {
44     public:
45         explicit SettingsImpl(const std::string &);
46
47         SettingsImpl(const SettingsImpl&) = default;
48         SettingsImpl& operator=(const SettingsImpl&) = default;
49         SettingsImpl(SettingsImpl&&) = default;
50         SettingsImpl& operator=(SettingsImpl&&) = default;
51
52         int Reload() { return ReadSettings(); }
53         int ReadSettings();
54
55         std::string GetStrError() const { return strError; }
56
57         int                 GetExecMsgKey() const { return stgExecMsgKey; }
58         unsigned            GetExecutersNum() const { return executersNum; }
59         const std::string & GetDirName(size_t num) const { return dirName[num]; }
60         const std::string & GetConfDir() const { return confDir; }
61         const std::string & GetScriptsDir() const { return scriptsDir; }
62         const std::string & GetRulesFileName() const { return rules; }
63         const std::string & GetLogFileName() const { return logFile; }
64         const std::string & GetPIDFileName() const { return pidFile; }
65         unsigned            GetDetailStatWritePeriod() const
66             { return detailStatWritePeriod; }
67         unsigned            GetStatWritePeriod() const { return statWritePeriod * 60; }
68         unsigned            GetDayFee() const { return dayFee; }
69         bool                GetFullFee() const { return fullFee; }
70         unsigned            GetDayResetTraff() const { return dayResetTraff; }
71         bool                GetSpreadFee() const { return spreadFee; }
72         bool                GetFreeMbAllowInet() const { return freeMbAllowInet; }
73         bool                GetDayFeeIsLastDay() const { return dayFeeIsLastDay; }
74         bool                GetStopOnError() const { return stopOnError; }
75         bool                GetWriteFreeMbTraffCost() const
76             { return writeFreeMbTraffCost; }
77         bool                GetShowFeeInCash() const { return showFeeInCash; }
78         const std::string & GetMonitorDir() const { return monitorDir; }
79         bool                GetMonitoring() const { return monitoring; }
80         unsigned            GetMessageTimeout() const { return messageTimeout * 3600 * 24; }
81         unsigned            GetFeeChargeType() const { return feeChargeType; }
82         bool                GetReconnectOnTariffChange() const { return reconnectOnTariffChange; }
83         bool                GetDisableSessionLog() const { return disableSessionLog; }
84         const std::vector<std::string> & GetFilterParamsLog() const { return filterParamsLog; }
85
86         const std::string & GetModulesPath() const { return modulesPath; }
87         const ModuleSettings & GetStoreModuleSettings() const
88         { return storeModuleSettings; }
89         const std::vector<ModuleSettings> & GetModulesSettings() const
90         { return modulesSettings; }
91         const std::vector<std::string> & GetScriptParams() const { return scriptParams; }
92
93     private:
94         std::string strError;
95
96         //////////settings
97         std::string modulesPath;
98         std::vector<std::string> dirName;
99         std::string confDir;
100         std::string scriptsDir;
101         std::string rules;
102         std::string logFile;
103         std::string pidFile;
104         std::string monitorDir;
105         std::vector<std::string> scriptParams;
106         bool        monitoring;
107         unsigned    detailStatWritePeriod;
108         unsigned    statWritePeriod;
109         int         stgExecMsgKey;
110         unsigned    executersNum;
111         bool        fullFee;
112         unsigned    dayFee;
113         unsigned    dayResetTraff;
114         bool        spreadFee;
115         bool        freeMbAllowInet;
116         bool        dayFeeIsLastDay;
117         bool        stopOnError;
118         bool        writeFreeMbTraffCost;
119         bool        showFeeInCash;
120         unsigned    messageTimeout;
121         unsigned    feeChargeType;
122         bool        reconnectOnTariffChange;
123         bool        disableSessionLog;
124         std::vector<std::string> filterParamsLog;
125
126         std::vector<ModuleSettings> modulesSettings;
127         ModuleSettings storeModuleSettings;
128 };
129 //-----------------------------------------------------------------------------
130
131 }