SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
src
lib
Plugin
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
24
#include "
SEFramework/Plugin/PluginManager.h
"
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
39
#include "
SEFramework/Plugin/Plugin.h
"
40
41
namespace
SourceXtractor
{
42
43
std::vector<std::unique_ptr<Plugin>
>
PluginManager::s_static_plugins
;
44
45
static
Elements::Logging
logger
=
Elements::Logging::getLogger
(
"PluginManager"
);
46
47
#if USE_BOOST_DLL
48
std::vector<boost::dll::shared_library>
PluginManager::s_loaded_plugins;
49
#endif
50
51
void
PluginManager::loadPlugins
() {
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
}
PluginManager.h
Plugin.h
Elements::Logging
Elements::Logging::getLogger
static Logging getLogger(const std::string &name="")
Elements::Logging::info
void info(const std::string &logMessage)
SourceXtractor::PluginManager::m_plugin_list
std::vector< std::string > m_plugin_list
Definition
PluginManager.h:88
SourceXtractor::PluginManager::s_static_plugins
static std::vector< std::unique_ptr< Plugin > > s_static_plugins
Definition
PluginManager.h:104
SourceXtractor::PluginManager::m_plugin_path
boost::filesystem::path m_plugin_path
Definition
PluginManager.h:87
SourceXtractor::PluginManager::loadPlugins
void loadPlugins()
loads all the available plugins. Both those linked at compile-time and those loaded at run-time
Definition
PluginManager.cpp:51
std::function
Euclid::Configuration::logger
static Elements::Logging logger
SourceXtractor
Definition
Aperture.h:30
Generated by
1.10.0