1 // Copyright (C) 2016-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) 2 // This Source Code Form is subject to the terms of the Mozilla Public 3 // License, v. 2.0. If a copy of the MPL was not distributed with this 4 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 6 #ifndef VSOMEIP_V3_PLUGIN_MANAGER_IMPL_HPP 7 #define VSOMEIP_V3_PLUGIN_MANAGER_IMPL_HPP 8 9 #include "../include/plugin_manager.hpp" 10 11 #include <map> 12 #include <chrono> 13 #include <mutex> 14 #include <set> 15 16 #include <vsomeip/constants.hpp> 17 #include <vsomeip/export.hpp> 18 #include <vsomeip/plugin.hpp> 19 20 namespace vsomeip_v3 { 21 22 class plugin_manager_impl : public plugin_manager { 23 public: 24 VSOMEIP_EXPORT static std::shared_ptr<plugin_manager_impl> get(); 25 26 plugin_manager_impl(); 27 28 ~plugin_manager_impl(); 29 30 VSOMEIP_EXPORT void load_plugins(); 31 32 VSOMEIP_EXPORT std::shared_ptr<plugin> get_plugin(plugin_type_e _type, std::string _name); 33 34 VSOMEIP_EXPORT std::shared_ptr<plugin> load_plugin( 35 const std::string& _library, plugin_type_e _type, 36 const uint32_t _version); 37 38 VSOMEIP_EXPORT bool unload_plugin(plugin_type_e _type); 39 40 private: 41 void add_plugin(const std::shared_ptr<plugin> &_plugin, const std::string& _name); 42 43 void * load_library(const std::string &_path); 44 void * load_symbol(void * _handle, const std::string &_symbol); 45 46 bool plugins_loaded_; 47 std::mutex loader_mutex_; 48 49 std::map<plugin_type_e, std::map<std::string, std::shared_ptr<plugin> > > plugins_; 50 std::map<plugin_type_e, std::map<std::string, void*> > handles_; 51 std::recursive_mutex plugins_mutex_; 52 53 static std::shared_ptr<plugin_manager_impl> the_plugin_manager__; 54 }; 55 56 } // namespace vsomeip_v3 57 58 #endif // VSOMEIP_V3_PLUGIN_MANAGER_IMPL_HPP 59