4 * @brief Settings plugin loader implementation.
6 * @author Ossama Othman @<ossama.othman@@intel.com@>
9 * Copyright 2012, 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
29 #include "manager.hpp"
30 #include <settingsd/plugin.hpp>
31 #include <settingsd/registrar.hpp>
38 /// We use this macro to silence @c -pedantic warnings from g++ that
39 /// there is no way to properly fix.
40 # define IVI_SETTINGS_EXTENSION __extension__
42 # define IVI_SETTINGS_EXTENSION
46 ivi::settings::loader::loader(std::string const & plugin_name,
47 ivi::settings::manager & mgr)
48 : handle_(dlopen(plugin_name.c_str(), RTLD_LAZY | RTLD_GLOBAL))
50 if (handle_ == nullptr) {
51 throw std::logic_error(dlerror());
54 // Reset any lingering dynamic linking related errors (see
58 // Retrieve the settings factory and destroyer functions.
59 typedef bool(*factory_type)(registrar &);
60 factory_type const register_settings =
61 IVI_SETTINGS_EXTENSION reinterpret_cast<factory_type>(
63 "register_settings"));
65 if (register_settings == nullptr)
66 throw std::logic_error(dlerror());
68 // Now create the underlying settings implementation.
71 if (!register_settings(r))
72 throw std::runtime_error("Unable to make \""
74 + "\" settings plugin");
77 ivi::settings::loader::~loader()
86 // indent-tabs-mode: nil