@@ -49,6 +49,24 @@ plugin_manager_impl::~plugin_manager_impl() {
49
49
plugins_.clear ();
50
50
}
51
51
52
+ #ifdef VSOMEIP_STATIC_PLUGINS
53
+ plugin_init_func plugin_manager_impl::get_static_init_func (const std::string &library_)
54
+ {
55
+ if (library_ == VSOMEIP_CFG_LIBRARY) {
56
+ return plugin_manager_impl_init_hook_cfg;
57
+ }
58
+ else if (library_ == VSOMEIP_SD_LIBRARY) {
59
+ return plugin_manager_impl_init_hook_sd;
60
+ }
61
+ else if (library_ == VSOMEIP_E2E_LIBRARY) {
62
+ return plugin_manager_impl_init_hook_e2e;
63
+ }
64
+ else {
65
+ return nullptr ;
66
+ }
67
+ }
68
+ #endif
69
+
52
70
void plugin_manager_impl::load_plugins () {
53
71
{
54
72
std::lock_guard<std::mutex> its_lock_start_stop (loader_mutex_);
@@ -72,9 +90,18 @@ void plugin_manager_impl::load_plugins() {
72
90
std::lock_guard<std::recursive_mutex> its_lock_start_stop (plugins_mutex_);
73
91
// Load plug-in info from libraries parsed before
74
92
for (const auto & plugin_name : plugins) {
75
- void * handle = load_library (plugin_name);
76
- plugin_init_func its_init_func = reinterpret_cast <plugin_init_func>(
77
- load_symbol (handle, VSOMEIP_PLUGIN_INIT_SYMBOL));
93
+ void * handle;
94
+ plugin_init_func its_init_func;
95
+ #ifdef VSOMEIP_STATIC_PLUGINS
96
+ handle = nullptr ;
97
+ its_init_func = get_static_init_func (plugin_name);
98
+ if (!its_init_func)
99
+ #endif
100
+ {
101
+ handle = load_library (plugin_name);
102
+ its_init_func = reinterpret_cast <plugin_init_func>(
103
+ load_symbol (handle, VSOMEIP_PLUGIN_INIT_SYMBOL));
104
+ }
78
105
if (its_init_func) {
79
106
create_plugin_func its_create_func = (*its_init_func)();
80
107
if (its_create_func) {
@@ -126,9 +153,18 @@ std::shared_ptr<plugin> plugin_manager_impl::get_plugin(plugin_type_e _type,
126
153
127
154
std::shared_ptr<plugin> plugin_manager_impl::load_plugin (const std::string& _library,
128
155
plugin_type_e _type, uint32_t _version) {
129
- void * handle = load_library (_library);
130
- plugin_init_func its_init_func = reinterpret_cast <plugin_init_func>(
131
- load_symbol (handle, VSOMEIP_PLUGIN_INIT_SYMBOL));
156
+ void * handle;
157
+ plugin_init_func its_init_func;
158
+ #ifdef VSOMEIP_STATIC_PLUGINS
159
+ handle = nullptr ;
160
+ its_init_func = get_static_init_func (_library);
161
+ if (!its_init_func)
162
+ #endif
163
+ {
164
+ handle = load_library (_library);
165
+ its_init_func = reinterpret_cast <plugin_init_func>(
166
+ load_symbol (handle, VSOMEIP_PLUGIN_INIT_SYMBOL));
167
+ }
132
168
if (its_init_func) {
133
169
create_plugin_func its_create_func = (*its_init_func)();
134
170
if (its_create_func) {
@@ -154,6 +190,9 @@ bool plugin_manager_impl::unload_plugin(plugin_type_e _type) {
154
190
const auto found_handle = handles_.find (_type);
155
191
if (found_handle != handles_.end ()) {
156
192
for (const auto & its_name : found_handle->second ) {
193
+ if (!its_name.second ) { // Skip statically linked plugins
194
+ continue ;
195
+ }
157
196
#ifdef _WIN32
158
197
FreeLibrary ((HMODULE)its_name.second );
159
198
#else
0 commit comments