4 * @brief Settings manager header.
6 * @author Ossama Othman @<ossama.othman@@intel.com@>
9 * Copyright 2013 Intel Corporation All Rights Reserved.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation;
14 * version 2.1 of the License.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301 USA
26 * @note This header is internal.
29 #ifndef IVI_SETTINGS_MANAGER_HPP
30 #define IVI_SETTINGS_MANAGER_HPP
34 #include <settingsd/plugin.hpp>
36 #include <libwebsockets.h>
51 * @brief The @c manager class is repository for all
54 * This class exposes the basic settings interface, and hides the
55 * underlying settings plugin details from the caller. All
56 * interaction with settings plugins is done through this class.
58 class SETTINGS_API manager
65 * @param[in] dir The settings plugin directory path.
67 manager(std::string const & dir);
72 /// Register settings plugin with the settings daemon.
73 bool register_setting(std::unique_ptr<plugin> p);
76 * Dispatch request to appropriate settings plugin.
78 * @param[in] request JSON formatted request string.
79 * @param[in] wsi Websocket through which response will be
82 void dispatch(std::string request, libwebsocket * wsi);
87 * @name Prevent copying
90 manager(manager const &) = delete;
91 manager & operator=(manager const &) = delete;
95 void load_settings(std::string const & dir);
100 * @todo A map may be overkill if only a few plugins will ever be
101 * registered. It may actually be more efficient from both
102 * a space and time point of view to simply use an array or
103 * linked list - although those alternatives would force us
104 * to explicitly prevent registration of settings plugins
105 * with duplicate names.
107 typedef std::map<std::string, std::unique_ptr<plugin>> map_type;
110 * List of settings plugin loaders.
112 * Each plugin could potentially register multiple plugins so we
113 * keep track of the loaders independently. We only keep these
114 * around so that we can gracefully close the plugins if
117 * @note This member must come before the settings plugin map,
118 * @c settings_, so that the plugins are still in memory
119 * (i.e. not @c dlclose()d) before they are destructed.
120 * Remember that the members are destroyed in the reverse
121 * order they are initialized.
123 std::vector<std::unique_ptr<loader>> loaders_;
125 /// Map of settings name to @c settings instance.
134 #endif /* IVI_SETTINGS_MANAGER_HPP */
140 // indent-tabs-mode: nil