Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00020
00021
00022
00023 #ifndef ICL_CORE_PLUGIN_PLUGIN_H_INCLUDED
00024 #define ICL_CORE_PLUGIN_PLUGIN_H_INCLUDED
00025
00026 #include "icl_core_plugin/ImportExport.h"
00027 #include "icl_core_plugin/PluginManager.h"
00028 #include "icl_core_plugin/Logging.h"
00029
00030 #include <string>
00031
00032 #if defined(_SYSTEM_WIN32_) && defined(_IC_STATIC_)
00033 #define ICL_CORE_PLUGIN_LINKAGE static
00034 #else // defined(_SYSTEM_WIN32_) && defined(_IC_STATIC_)
00035 #define ICL_CORE_PLUGIN_LINKAGE
00036 #endif // defined(_SYSTEM_WIN32_) && defined(_IC_STATIC_)
00037
00038 #define ICL_CORE_PLUGIN_DECLARE_PLUGIN_INTERFACE(name) \
00039 public: \
00040 virtual std::string Identifier() const = 0; \
00041 typedef const char* identifier(); \
00042 typedef const char* basetype(); \
00043 typedef name* load_plugin(); \
00044 typedef void unload_plugin(name*);
00045
00046 #define ICL_CORE_PLUGIN_DECLARE_PLUGIN \
00047 public: \
00048 virtual std::string Identifier() const; \
00049
00050 #define ICL_CORE_PLUGIN_REGISTER_PLUGIN(base, derived, plugin_identifier) \
00051 std::string derived::Identifier() const \
00052 { \
00053 return plugin_identifier; \
00054 } \
00055 \
00056 extern "C" ICL_CORE_PLUGIN_LINKAGE const char * identifier() \
00057 { \
00058 return plugin_identifier; \
00059 } \
00060 \
00061 extern "C" ICL_CORE_PLUGIN_LINKAGE const char * basetype() \
00062 { \
00063 return typeid(base).name(); \
00064 } \
00065 \
00066 extern "C" ICL_CORE_PLUGIN_LINKAGE base* load_plugin() \
00067 { \
00068 return new derived; \
00069 } \
00070 \
00071 extern "C" ICL_CORE_PLUGIN_LINKAGE void unload_plugin(derived* p) \
00072 { \
00073 delete p; \
00074 }
00075
00076 #define ICL_CORE_PLUGIN_MANAGER_DEFINITION(name, interface, directory) \
00077 name : public icl_core::plugin::PluginManager<interface, directory> { \
00078 name() \
00079 { \
00080 LOGGING_TRACE(icl_core::plugin::Plugin, "Using plugin search path " \
00081 << directory << icl_core::logging::endl); \
00082 } \
00083 };
00084
00085 #define ICL_CORE_PLUGIN_DECLARE_PLUGIN_MANAGER(name, interface, directory) \
00086 class ICL_CORE_PLUGIN_MANAGER_DEFINITION(name, interface, directory)
00087 #define ICL_CORE_PLUGIN_DECLARE_PLUGIN_MANAGER_IMPORT_EXPORT(decl, name, interface, directory) \
00088 class decl ICL_CORE_PLUGIN_MANAGER_DEFINITION(name, interface, directory)
00089
00090 #endif