SourceXtractorPlusPlus  0.11
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PluginManager.h
Go to the documentation of this file.
1 
17 /*
18  * PluginManager.h
19  *
20  * Created on: Jul 27, 2016
21  * Author: mschefer
22  */
23 
24 #ifndef _SEFRAMEWORK_PLUGIN_PLUGINMANAGER_H_
25 #define _SEFRAMEWORK_PLUGIN_PLUGINMANAGER_H_
26 
27 #include <boost/version.hpp>
28 #define USE_BOOST_DLL BOOST_VERSION >= 105500
29 
30 #if USE_BOOST_DLL
31 #include <boost/dll/shared_library.hpp>
32 #endif
33 #include <boost/filesystem/path.hpp>
34 
35 #include <memory>
36 #include <vector>
37 
41 
42 namespace SourceXtractor {
43 
44 class Plugin;
45 
53 class PluginManager : public PluginAPI {
54 public:
55 
56  virtual ~PluginManager() = default;
57 
59  std::shared_ptr<OutputRegistry> output_registry,
60  long config_manager_id,
61  std::string plugin_path,
62  std::vector<std::string> plugin_list) :
63  m_plugin_path(plugin_path),
64  m_plugin_list(plugin_list),
65  m_task_factory_registry(task_factory_registry),
66  m_output_registry(output_registry),
67  m_config_manager_id(config_manager_id) {}
68 
70  void loadPlugins();
71 
72  // PluginAPI implementation
73  virtual TaskFactoryRegistry& getTaskFactoryRegistry() const override {
75  }
76 
77  virtual OutputRegistry& getOutputRegistry() const override {
78  return *m_output_registry;
79  }
80 
83  }
84 
86  template<typename T>
87  static void registerStaticPlugin() {
88  s_static_plugins.emplace_back(new T);
89  }
90 
91 private:
92  boost::filesystem::path m_plugin_path;
94 
98 
99 #if USE_BOOST_DLL
100  static std::vector<boost::dll::shared_library> s_loaded_plugins;
109 #endif
111 };
112 
113 }
114 
115 #endif /* _SEFRAMEWORK_PLUGIN_PLUGINMANAGER_H_ */
void loadPlugins()
loads all the available plugins. Both those linked at compile-time and those loaded at run-time ...
std::shared_ptr< OutputRegistry > m_output_registry
Definition: PluginManager.h:96
std::shared_ptr< TaskFactoryRegistry > m_task_factory_registry
Definition: PluginManager.h:95
static ConfigManager & getInstance(long id)
Euclid::Configuration::ConfigManager & getConfigManager() const override
Definition: PluginManager.h:81
std::vector< std::string > m_plugin_list
Definition: PluginManager.h:93
STL class.
boost::filesystem::path m_plugin_path
Definition: PluginManager.h:92
This interface is given to the plugin to let it access object instances from the framework.
Definition: PluginAPI.h:39
virtual ~PluginManager()=default
static void registerStaticPlugin()
registers a plugin, this is used to register plugins linked at compile-time
Definition: PluginManager.h:87
virtual TaskFactoryRegistry & getTaskFactoryRegistry() const override
Definition: PluginManager.h:73
virtual OutputRegistry & getOutputRegistry() const override
Definition: PluginManager.h:77
static std::vector< std::unique_ptr< Plugin > > s_static_plugins
PluginManager(std::shared_ptr< TaskFactoryRegistry > task_factory_registry, std::shared_ptr< OutputRegistry > output_registry, long config_manager_id, std::string plugin_path, std::vector< std::string > plugin_list)
Definition: PluginManager.h:58
static long config_manager_id
PluginManager handles the loading of plugins and calls their registration function, providing them with with a PluginAPI implementation.
Definition: PluginManager.h:53