SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
PluginManager.cpp
Go to the documentation of this file.
1
17/*
18 * PluginManager.cpp
19 *
20 * Created on: Jul 28, 2016
21 * Author: mschefer
22 */
23
25
26#include <iostream>
27#include <string>
28#include <fstream>
29
30#if USE_BOOST_DLL
31#include <boost/dll/import.hpp>
32#endif
33#include <boost/filesystem.hpp>
34#include <boost/filesystem/fstream.hpp>
35
36#include "ElementsKernel/Logging.h"
37#include "Configuration/ConfigManager.h"
38
40
41namespace SourceXtractor {
42
44
46
47#if USE_BOOST_DLL
48std::vector<boost::dll::shared_library> PluginManager::s_loaded_plugins;
49#endif
50
52 // load staticly registered plugins
53 for (auto& static_plugin : s_static_plugins) {
54 static_plugin->registerPlugin(*this);
55 }
56
57#if USE_BOOST_DLL
58 typedef std::shared_ptr<Plugin> (pluginapi_create_t)();
59
60 // load dynamic plugins
61 auto load_mode = boost::dll::load_mode::append_decorations | boost::dll::load_mode::search_system_folders;
62 for (auto& plugin_name : m_plugin_list) {
63 boost::dll::shared_library lib;
64
65 // Try on the explicit path first
66 if (!m_plugin_path.empty()) {
67 auto full_path = m_plugin_path / plugin_name;
68 try {
69 lib.load(full_path, load_mode);
70 } catch (const boost::system::system_error&) {
71 // ignore
72 }
73 }
74 // Try on the system path. This time, propagate the failure
75 if (!lib.is_loaded()) {
76 lib.load(plugin_name, load_mode);
77 }
78
79 auto creator = lib.get_alias<pluginapi_create_t>("create_plugin");
80 auto plugin = creator();
81 auto id_string = plugin->getIdString();
82 logger.info() << "Registering plugin " << id_string;
83 plugin->registerPlugin(*this);
84 s_loaded_plugins.push_back(lib);
85 }
86
87#endif
88}
89
90}
static Logging getLogger(const std::string &name="")
std::vector< std::string > m_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 Elements::Logging logger