]> git.stg.codes - ssmd.git/blob - include/settings.h
041453a9a3bb1cd86b2d7a21d839fc5185a40667
[ssmd.git] / include / settings.h
1 #ifndef __SSMD_SETTINGS_H__
2 #define __SSMD_SETTINGS_H__
3
4 #include <string>
5
6 #include <boost/noncopyable.hpp>
7 #include <boost/program_options.hpp>
8
9 namespace po = boost::program_options;
10
11 namespace SSMD {
12
13 class SettingsParser;
14 class Settings {
15     public:
16         // Construction / destruction
17         Settings();
18         Settings(const Settings & rvalue);
19         ~Settings();
20
21         const Settings & operator=(const Settings & rvalue);
22         
23         // Accessors
24         bool isHelp() const throw() { return _isHelp; }
25         bool isVersion() const throw() { return _isVersion; }
26         bool isDebug() const throw() { return _isDebug; }
27         bool isDaemon() const throw() { return _isDaemon; }
28
29         const std::string & configFile() const throw() { return _configFile; }
30         const std::string & logFile() const throw() { return _logFile; }
31         const std::string & PIDFile() const throw() { return _PIDFile; }
32
33         time_t switchSyncInterval() const throw() { return _switchSyncInterval; }
34         time_t infoSyncInterval() const throw() { return _infoSyncInterval; }
35
36         unsigned upProfileId() const throw() { return _upProfileId; }
37         unsigned downProfileId() const throw() { return _downProfileId; }
38
39         size_t maxACLPerPDU() const throw() { return _maxACLPerPDU; }
40
41         const std::string & dataURL() const throw() { return _dataURL; }
42
43         const std::string & scriptBase() const throw() { return _scriptBase; }
44         bool dumpScripts() const throw() { return _dumpScripts; }
45
46         // Setters
47         void setIsHelp(bool value) throw() { _isHelp = value; }
48         void setIsVersion(bool value) throw() { _isVersion = value; }
49         void setIsDebug(bool value) throw() { _isDebug = value; }
50         void setIsDaemon(bool value) throw() { _isDaemon = value; }
51
52         void setConfigFile(const std::string & value) throw() { _configFile = value; }
53         void setLogFile(const std::string & value) throw() { _logFile = value; }
54         void setPIDFile(const std::string & value) throw() { _PIDFile = value; }
55
56         void setSwitchSyncInterval(time_t value) throw() { _switchSyncInterval = value; }
57         void setInfoSyncInterval(time_t value) throw() { _infoSyncInterval = value; }
58
59         void setUpProfileId(unsigned value) throw() { _upProfileId = value; }
60         void setDownProfileId(unsigned value) throw() { _downProfileId = value; }
61
62         void setMaxACLPerPDU(size_t value) throw() { _maxACLPerPDU = value; }
63
64         void setDataURL(const std::string & value) throw() { _dataURL = value; }
65
66     private:
67         bool _isHelp;
68         bool _isVersion;
69         bool _isDebug;
70         bool _isDaemon;
71
72         std::string _configFile;
73         std::string _logFile;
74         std::string _PIDFile;
75
76         time_t _switchSyncInterval;
77         time_t _infoSyncInterval;
78
79         unsigned _upProfileId;
80         unsigned _downProfileId;
81
82         size_t _maxACLPerPDU;
83
84         std::string _dataURL;
85
86         std::string _scriptBase;
87         bool _dumpScripts;
88
89         friend class SettingsParser;
90 };
91
92 class SettingsParser : private boost::noncopyable {
93     public:
94         SettingsParser();
95         ~SettingsParser();
96
97         void init(int argc, char * argv[]);
98         void reloadConfig();
99         void printHelp() const;
100
101         const Settings & settings() const { return _settings; };
102     private:
103         po::options_description _desc;
104         Settings _settings;
105
106         void parseFile(const std::string & fileName);
107 };
108
109 }
110
111 #include "settings.inl.h"
112
113 #endif