summaryrefslogtreecommitdiff
path: root/src/configurator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/configurator.hpp')
-rw-r--r--src/configurator.hpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/configurator.hpp b/src/configurator.hpp
new file mode 100644
index 0000000..7187aad
--- /dev/null
+++ b/src/configurator.hpp
@@ -0,0 +1,125 @@
+/**
+ * @file configurator.hpp
+ *
+ * @brief settingsd configuration manager header.
+ *
+ * @author Ossama Othman @<ossama.othman@@intel.com@>
+ *
+ * @copyright @par
+ * Copyright 2012, 2013 Intel Corporation All Rights Reserved.
+ * @par
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ * @par
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * @par
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * @note This is an internal header.
+ */
+
+#ifndef IVI_SETTINGS_CONFIGURATOR_HPP
+#define IVI_SETTINGS_CONFIGURATOR_HPP
+
+#include <string>
+#include <boost/program_options.hpp>
+
+
+namespace ivi {
+ namespace settings{
+ /**
+ * @class configurator
+ *
+ * @brief Settingsd configuration manager
+ *
+ * The @c configurator class parses command line and file based
+ * settingsd configuration options.
+ */
+ class configurator
+ {
+ public:
+
+ /// Constructor.
+ configurator(int & argc, char * argv[], char const * logger_name);
+
+ /// Get directory containing the settings plugins.
+ std::string settings_dir() const;
+
+ /// The port on which the web socket server should listen.
+ int websocket_port() const;
+
+
+ /// Websocket server SSL certificate file.
+ char const * ssl_cert_file() const;
+
+ /// Websocket server SSL private key file.
+ char const * ssl_private_key_file() const;
+
+ /// Websocket server SSL CA certificate file.
+ char const * ssl_ca_file() const;
+
+ private:
+
+ /**
+ * @name Prevent copying
+ */
+ //@{
+ configurator(configurator const &) = delete;
+ configurator & operator=(configurator const &) = delete;
+ //@}
+
+ /**
+ * @brief Parse the settingsd configuration.
+ *
+ * Configuration options are obtained from the command line, the
+ * user configuration file and the system configuration file, in
+ * order of decreasing precedence.
+ */
+ void parse_config(int & argc, char * argv[]);
+
+ /// Display settingsd's version and copyright notices.
+ void display_version_info() const;
+
+ /// Configure the underlying logger.
+ void configure_logger(char const * logger_name);
+
+ /// Set the log level in the underlying logger.
+ void set_log_level();
+
+ /**
+ * libwebsockets wants a @c nullptr for SSL certificate/key
+ * paths if they won't be used.
+ *
+ * @param[in] option SSL certificate relate program option.
+ *
+ * @returns C string if @a option is not empty, @c nullptr
+ * otherwise.
+ */
+ char const * libwebsocket_ssl_filepath(
+ std::string const & option) const;
+
+ private:
+
+ /// Map of settingsd program options.
+ boost::program_options::variables_map vm_;
+
+ };
+ }
+}
+
+#endif /* IVI_SETTINGS_CONFIGURATOR_HPP */
+
+
+// Local Variables:
+// mode:c++
+// c-basic-offset:2
+// indent-tabs-mode: nil
+// End: