plugin.h
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
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
#ifndef _PLUGIN_H
00038
#define _PLUGIN_H
00039
00040 #define PWLIB_PLUGIN_API_VERSION 0
00041
00043
00044
00045
00046
00047 class PPluginServiceDescriptor
00048 {
00049
public:
00050 PPluginServiceDescriptor(
unsigned (*_GetPluginAPIVersion)())
00051 :
GetPluginAPIVersion(_GetPluginAPIVersion)
00052 { }
00053
00054 unsigned (*GetPluginAPIVersion)();
00055 };
00056
00057
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 class PPluginService:
public PObject
00075 {
00076
public:
00077 PPluginService(
const PString & _serviceName,
00078
const PString & _serviceType,
00079
PPluginServiceDescriptor *_descriptor)
00080 {
00081
serviceName = _serviceName;
00082
serviceType = _serviceType;
00083
descriptor = _descriptor;
00084 }
00085
00086 PString serviceName;
00087 PString serviceType;
00088 PPluginServiceDescriptor *
descriptor;
00089 };
00090
00092
00093 #define PCREATE_PLUGIN_VERSION_DECLARE
00094
00095 #define PCREATE_STATIC_PLUGIN_VERSION_FN(serviceName, serviceType) \
00096
unsigned PPlugin_##serviceType##_##serviceName##_GetVersion() \
00097
{ return PWLIB_PLUGIN_API_VERSION; }
00098
00099 #define PCREATE_DYNAMIC_PLUGIN_VERSION_FN(serviceName, serviceType) \
00100
extern "C" unsigned PWLibPlugin_GetAPIVersion (void) \
00101
{ return PWLIB_PLUGIN_API_VERSION; }
00102
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 #define PCREATE_PLUGIN_REGISTERER(serviceName, serviceType, descriptor) \
00114
class PPlugin_##serviceType##_##serviceName##_Registration { \
00115
public: \
00116
PPlugin_##serviceType##_##serviceName##_Registration(PPluginManager * pluginMgr) \
00117
{ pluginMgr->RegisterService(#serviceName, #serviceType, descriptor); } \
00118
int kill_warning; \
00119
}; \
00120
00121
#ifdef _WIN32
00122
00123
#define PCREATE_PLUGIN_STATIC(serviceName, serviceType, descriptor) \
00124
PCREATE_PLUGIN_REGISTERER(serviceName, serviceType, descriptor) \
00125
PPlugin_##serviceType##_##serviceName##_Registration \
00126
PPlugin_##serviceType##_##serviceName##_Registration_Instance(&PPluginManager::GetPluginManager()); \
00127
00128
#define PWLIB_STATIC_LOAD_PLUGIN(cls) \
00129
class PPlugin_##cls##_Registration; \
00130
extern PPlugin_##cls##_Registration PPlugin_##cls##_Registration_Instance; \
00131
static PPlugin_##cls##_Registration * PPlugin_##cls##_Registration_Static_Library_Loader = &PPlugin_##cls##_Registration_Instance
00132
00133
#else
00134
00135 #define PCREATE_PLUGIN_STATIC(serviceName, serviceType, descriptor) \
00136
static void __attribute__ (( constructor )) PWLIB_StaticLoader_##serviceName##_##serviceType() \
00137
{ PPluginManager::GetPluginManager().RegisterService(#serviceName, #serviceType, descriptor); } \
00138
00139 #define PWLIB_STATIC_LOAD_PLUGIN(cls)
00140
00141
#endif
00142
00143 #define PCREATE_PLUGIN_DYNAMIC(serviceName, serviceType, descriptor) \
00144
PCREATE_PLUGIN_REGISTERER(serviceName, serviceType, descriptor) \
00145
extern "C" void PWLibPlugin_TriggerRegister (PPluginManager * pluginMgr) { \
00146
PPlugin_##serviceType##_##serviceName##_Registration \
00147
pplugin_##serviceType##_##serviceName##_Registration_Instance(pluginMgr); \
00148
pplugin_##serviceType##_##serviceName##_Registration_Instance.kill_warning = 0; \
00149
}
00150
00152
00153
#if defined(P_HAS_PLUGINS) && ! defined(P_FORCE_STATIC_PLUGIN)
00154
# define PCREATE_PLUGIN(serviceName, serviceType, descriptor) \
00155
PCREATE_PLUGIN_DYNAMIC(serviceName, serviceType, descriptor)
00156
00157
# define PCREATE_PLUGIN_VERSION_FN(serviceName, serviceType) \
00158
PCREATE_DYNAMIC_PLUGIN_VERSION_FN(serviceName, serviceType)
00159
00160
# define PPLUGIN_VERSION_FN(serviceName, serviceType) \
00161
PWLibPlugin_GetAPIVersion
00162
00163
#else
00164
00165 # define PCREATE_PLUGIN(serviceName, serviceType, descriptor) \
00166
PCREATE_PLUGIN_STATIC(serviceName, serviceType, descriptor)
00167
00168 # define PCREATE_PLUGIN_VERSION_FN(serviceName, serviceType) \
00169
PCREATE_STATIC_PLUGIN_VERSION_FN(serviceName, serviceType)
00170
00171 # define PPLUGIN_VERSION_FN(serviceName, serviceType) \
00172
PPlugin_##serviceType##_##serviceName##_GetVersion
00173
00174
#endif
00175
00177
00178
#endif
Generated on Sat Jul 24 15:35:56 2004 for PWLib by
1.3.7