SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
PluginManager.h
Go to the documentation of this file.
1/*
2 * Copyright © 2019-2022 Université de Genève, LMU Munich - Faculty of Physics, IAP-CNRS/Sorbonne Université
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 3.0 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18/*
19 * PluginManager.h
20 *
21 * Created on: Jul 27, 2016
22 * Author: mschefer
23 */
24
25#ifndef _SEFRAMEWORK_PLUGIN_PLUGINMANAGER_H_
26#define _SEFRAMEWORK_PLUGIN_PLUGINMANAGER_H_
27
28#include <boost/version.hpp>
29#define USE_BOOST_DLL BOOST_VERSION >= 105500
30
31#if USE_BOOST_DLL
32#include <boost/dll/shared_library.hpp>
33#endif
34#include <boost/filesystem/path.hpp>
35
36#include <memory>
37#include <vector>
38
42
43namespace SourceXtractor {
44
45class Plugin;
46
52
53
54class PluginManager : public PluginAPI {
55public:
56
57 ~PluginManager() override = default;
58
60 std::shared_ptr<OutputRegistry> output_registry,
61 std::string plugin_path,
62 std::vector<std::string> plugin_list) :
63 m_plugin_path(plugin_path),
64 m_plugin_list(std::move(plugin_list)),
65 m_task_factory_registry(std::move(task_factory_registry)),
66 m_output_registry(std::move(output_registry)) {}
67
69 void loadPlugins();
70
71 // PluginAPI implementation
75
77 return *m_output_registry;
78 }
79
81 template<typename T>
82 static void registerStaticPlugin() {
83 s_static_plugins.emplace_back(new T);
84 }
85
86private:
87 boost::filesystem::path m_plugin_path;
89
92
93#if USE_BOOST_DLL
102 static std::vector<boost::dll::shared_library> s_loaded_plugins;
103#endif
105};
106
107}
108
109#endif /* _SEFRAMEWORK_PLUGIN_PLUGINMANAGER_H_ */
This interface is given to the plugin to let it access object instances from the framework.
Definition PluginAPI.h:40
TaskFactoryRegistry & getTaskFactoryRegistry() const override
~PluginManager() override=default
std::vector< std::string > m_plugin_list
OutputRegistry & getOutputRegistry() const override
std::shared_ptr< OutputRegistry > m_output_registry
PluginManager(std::shared_ptr< TaskFactoryRegistry > task_factory_registry, std::shared_ptr< OutputRegistry > output_registry, std::string plugin_path, std::vector< std::string > plugin_list)
static std::vector< std::unique_ptr< Plugin > > s_static_plugins
boost::filesystem::path m_plugin_path
void loadPlugins()
loads all the available plugins. Both those linked at compile-time and those loaded at run-time
static void registerStaticPlugin()
registers a plugin, this is used to register plugins linked at compile-time
std::shared_ptr< TaskFactoryRegistry > m_task_factory_registry
T move(T... args)
STL namespace.