@@ -49,6 +49,24 @@ plugin_manager_impl::~plugin_manager_impl() {
4949 plugins_.clear ();
5050}
5151
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+
5270void plugin_manager_impl::load_plugins () {
5371 {
5472 std::lock_guard<std::mutex> its_lock_start_stop (loader_mutex_);
@@ -72,9 +90,18 @@ void plugin_manager_impl::load_plugins() {
7290 std::lock_guard<std::recursive_mutex> its_lock_start_stop (plugins_mutex_);
7391 // Load plug-in info from libraries parsed before
7492 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+ }
78105 if (its_init_func) {
79106 create_plugin_func its_create_func = (*its_init_func)();
80107 if (its_create_func) {
@@ -126,9 +153,18 @@ std::shared_ptr<plugin> plugin_manager_impl::get_plugin(plugin_type_e _type,
126153
127154std::shared_ptr<plugin> plugin_manager_impl::load_plugin (const std::string& _library,
128155 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+ }
132168 if (its_init_func) {
133169 create_plugin_func its_create_func = (*its_init_func)();
134170 if (its_create_func) {
@@ -154,6 +190,9 @@ bool plugin_manager_impl::unload_plugin(plugin_type_e _type) {
154190 const auto found_handle = handles_.find (_type);
155191 if (found_handle != handles_.end ()) {
156192 for (const auto & its_name : found_handle->second ) {
193+ if (!its_name.second ) { // Skip statically linked plugins
194+ continue ;
195+ }
157196#ifdef _WIN32
158197 FreeLibrary ((HMODULE)its_name.second );
159198#else
0 commit comments