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