#ifndef __SSMD_SETTINGS_H__ #define __SSMD_SETTINGS_H__ #include #include #include namespace po = boost::program_options; namespace SSMD { class SettingsParser; class Settings { public: // Construction / destruction Settings(); Settings(const Settings & rvalue); ~Settings(); const Settings & operator=(const Settings & rvalue); // Accessors bool isHelp() const throw() { return _isHelp; } bool isVersion() const throw() { return _isVersion; } bool isDebug() const throw() { return _isDebug; } bool isDaemon() const throw() { return _isDaemon; } const std::string & configFile() const throw() { return _configFile; } const std::string & logFile() const throw() { return _logFile; } const std::string & PIDFile() const throw() { return _PIDFile; } time_t switchSyncInterval() const throw() { return _switchSyncInterval; } time_t infoSyncInterval() const throw() { return _infoSyncInterval; } unsigned upProfileId() const throw() { return _upProfileId; } unsigned downProfileId() const throw() { return _downProfileId; } size_t maxACLPerPDU() const throw() { return _maxACLPerPDU; } const std::string & dataURL() const throw() { return _dataURL; } const std::string & scriptBase() const throw() { return _scriptBase; } bool dumpScripts() const throw() { return _dumpScripts; } // Setters void setIsHelp(bool value) throw() { _isHelp = value; } void setIsVersion(bool value) throw() { _isVersion = value; } void setIsDebug(bool value) throw() { _isDebug = value; } void setIsDaemon(bool value) throw() { _isDaemon = value; } void setConfigFile(const std::string & value) throw() { _configFile = value; } void setLogFile(const std::string & value) throw() { _logFile = value; } void setPIDFile(const std::string & value) throw() { _PIDFile = value; } void setSwitchSyncInterval(time_t value) throw() { _switchSyncInterval = value; } void setInfoSyncInterval(time_t value) throw() { _infoSyncInterval = value; } void setUpProfileId(unsigned value) throw() { _upProfileId = value; } void setDownProfileId(unsigned value) throw() { _downProfileId = value; } void setMaxACLPerPDU(size_t value) throw() { _maxACLPerPDU = value; } void setDataURL(const std::string & value) throw() { _dataURL = value; } private: bool _isHelp; bool _isVersion; bool _isDebug; bool _isDaemon; std::string _configFile; std::string _logFile; std::string _PIDFile; time_t _switchSyncInterval; time_t _infoSyncInterval; unsigned _upProfileId; unsigned _downProfileId; size_t _maxACLPerPDU; std::string _dataURL; std::string _scriptBase; bool _dumpScripts; friend class SettingsParser; }; class SettingsParser : private boost::noncopyable { public: SettingsParser(); ~SettingsParser(); void init(int argc, char * argv[]); void reloadConfig(); void printHelp() const; const Settings & settings() const { return _settings; }; private: po::options_description _desc; Settings _settings; void parseFile(const std::string & fileName); }; } #include "settings.inl.h" #endif