1 #ifndef __GTS_SETTINGS_H__
2 #define __GTS_SETTINGS_H__
6 #include <boost/noncopyable.hpp>
7 #include <boost/program_options.hpp>
9 namespace po = boost::program_options;
16 // Construction / destruction
18 Settings(const Settings & rvalue);
21 const Settings & operator=(const Settings & rvalue);
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; }
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; }
33 time_t switchSyncInterval() const throw() { return _switchSyncInterval; }
34 time_t infoSyncInterval() const throw() { return _infoSyncInterval; }
36 unsigned upProfileId() const throw() { return _upProfileId; }
37 unsigned downProfileId() const throw() { return _downProfileId; }
39 const std::string & dataURL() const throw() { return _dataURL; }
42 void setIsHelp(bool value) throw() { _isHelp = value; }
43 void setIsVersion(bool value) throw() { _isVersion = value; }
44 void setIsDebug(bool value) throw() { _isDebug = value; }
45 void setIsDaemon(bool value) throw() { _isDaemon = value; }
47 void setConfigFile(const std::string & value) throw() { _configFile = value; }
48 void setLogFile(const std::string & value) throw() { _logFile = value; }
49 void setPIDFile(const std::string & value) throw() { _PIDFile = value; }
51 void setSwitchSyncInterval(time_t value) throw() { _switchSyncInterval = value; }
52 void setInfoSyncInterval(time_t value) throw() { _infoSyncInterval = value; }
54 void setUpProfileId(unsigned value) throw() { _upProfileId = value; }
55 void setDownProfileId(unsigned value) throw() { _downProfileId = value; }
57 void setDataURL(const std::string & value) throw() { _dataURL = value; }
65 std::string _configFile;
69 time_t _switchSyncInterval;
70 time_t _infoSyncInterval;
72 unsigned _upProfileId;
73 unsigned _downProfileId;
77 friend class SettingsParser;
80 class SettingsParser : private boost::noncopyable {
85 void init(int argc, char * argv[]);
87 void printHelp() const;
89 const Settings & settings() const { return _settings; };
91 po::options_description _desc;
94 void parseFile(const std::string & fileName);
99 #include "settings.inl.h"