HMSBEAGLE
1.0.0
|
00001 00008 #ifndef __PLUGIN_H__ 00009 #define __PLUGIN_H__ 00010 00011 #ifdef HAVE_CONFIG_H 00012 #include "libhmsbeagle/config.h" 00013 #endif 00014 00015 #include "libhmsbeagle/platform.h" 00016 #include "libhmsbeagle/BeagleImpl.h" 00017 #include "libhmsbeagle/plugin/SharedLibrary.h" 00018 #include <memory> 00019 #include <string> 00020 #include <map> 00021 #include <list> 00022 00023 namespace beagle { 00024 namespace plugin { 00025 00030 class BEAGLE_DLLEXPORT Plugin 00031 { 00032 public: 00033 Plugin() {} 00034 00035 Plugin(const char* plugin_name, const char* plugin_type) 00036 : m_plugin_name(plugin_name), m_plugin_type(plugin_type) {} 00037 00038 virtual std::string pluginName() const{ return m_plugin_name; } 00039 virtual std::string pluginType() const{ return m_plugin_type; } 00040 00041 virtual const std::list<beagle::BeagleImplFactory*>& getBeagleFactories() const{ return beagleFactories; } 00042 virtual const std::list<BeagleResource>& getBeagleResources() const{ return beagleResources; } 00043 00044 protected: 00045 std::list<beagle::BeagleImplFactory*> beagleFactories; 00046 std::list<BeagleResource> beagleResources; 00047 std::string m_plugin_name; 00048 std::string m_plugin_type; 00049 }; 00050 00051 typedef Plugin* (*plugin_init_func)(void); 00052 00053 class BEAGLE_DLLEXPORT PluginManager 00054 { 00055 public: 00056 static PluginManager& instance(); 00057 00058 Plugin* findPlugin(const char* name) 00059 throw (SharedLibraryException); 00060 00061 private: 00062 struct PluginInfo { 00063 SharedLibrary* m_library; 00064 std::string m_library_name; 00065 Plugin* m_plugin; 00066 00067 ~PluginInfo() { delete m_plugin; delete m_library; } 00068 PluginInfo() : m_library(0), m_plugin(0) {} 00069 }; 00070 PluginManager() {} 00071 static PluginManager* ms_instance; 00072 std::map<std::string,PluginInfo* > m_plugin_map; 00073 // ... 00074 }; 00075 00076 } // namespace plugin 00077 } // namespace beagle 00078 00079 #endif // __PLUGIN_H__