]> git.stg.codes - ssmd.git/blob - include/settings.h
c88f94a6c7694f5a29ee19265390926641776d12
[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         // Setters
44         void setIsHelp(bool value) throw() { _isHelp = value; }
45         void setIsVersion(bool value) throw() { _isVersion = value; }
46         void setIsDebug(bool value) throw() { _isDebug = value; }
47         void setIsDaemon(bool value) throw() { _isDaemon = value; }
48
49         void setConfigFile(const std::string & value) throw() { _configFile = value; }
50         void setLogFile(const std::string & value) throw() { _logFile = value; }
51         void setPIDFile(const std::string & value) throw() { _PIDFile = value; }
52
53         void setSwitchSyncInterval(time_t value) throw() { _switchSyncInterval = value; }
54         void setInfoSyncInterval(time_t value) throw() { _infoSyncInterval = value; }
55
56         void setUpProfileId(unsigned value) throw() { _upProfileId = value; }
57         void setDownProfileId(unsigned value) throw() { _downProfileId = value; }
58
59         void setMaxACLPerPDU(size_t value) throw() { _maxACLPerPDU = value; }
60
61         void setDataURL(const std::string & value) throw() { _dataURL = value; }
62
63     private:
64         bool _isHelp;
65         bool _isVersion;
66         bool _isDebug;
67         bool _isDaemon;
68
69         std::string _configFile;
70         std::string _logFile;
71         std::string _PIDFile;
72
73         time_t _switchSyncInterval;
74         time_t _infoSyncInterval;
75
76         unsigned _upProfileId;
77         unsigned _downProfileId;
78
79         size_t _maxACLPerPDU;
80
81         std::string _dataURL;
82
83         friend class SettingsParser;
84 };
85
86 class SettingsParser : private boost::noncopyable {
87     public:
88         SettingsParser();
89         ~SettingsParser();
90
91         void init(int argc, char * argv[]);
92         void reloadConfig();
93         void printHelp() const;
94
95         const Settings & settings() const { return _settings; };
96     private:
97         po::options_description _desc;
98         Settings _settings;
99
100         void parseFile(const std::string & fileName);
101 };
102
103 }
104
105 #include "settings.inl.h"
106
107 #endif