Go to the documentation of this file.
15 #ifndef PTLIB_PLUGIN_H
16 #define PTLIB_PLUGIN_H
25 #ifdef PWLIB_PLUGIN_API_VERSION
26 #ifdef PTLIB_PLUGIN_API_VERSION
27 #warning Ignoring PWLIB_PLUGIN_API_VERSION as PTLIB_PLUGIN_API_VERSION is defined!
28 #undef PWLIB_PLUGIN_API_VERSION
30 #define PTLIB_PLUGIN_API_VERSION PWLIB_PLUGIN_API_VERSION
33 #ifndef PTLIB_PLUGIN_API_VERSION
34 #define PTLIB_PLUGIN_API_VERSION 1
85 #define PCREATE_PLUGIN_SERVICE_EX(serviceType, BaseClass, extra) \
86 class PPlugin_##serviceType : public BaseClass { \
88 static const char * ServiceType() { return #serviceType; } \
89 virtual const char * GetServiceType() const { return ServiceType(); } \
93 #define PCREATE_PLUGIN_SERVICE(serviceType) \
94 PCREATE_PLUGIN_SERVICE_EX(serviceType, PPluginServiceDescriptor, )
96 #define PCREATE_PLUGIN_DEVICE(serviceType) \
97 PCREATE_PLUGIN_SERVICE_EX(serviceType, PPluginDeviceDescriptor, )
102 #define PCREATE_PLUGIN_ARG_5(serviceName, serviceType, InstanceClass, DescriptorClass, extra) \
103 class PPlugin_##serviceType##_##serviceName : public DescriptorClass { \
105 static const char * ServiceName() { return #serviceName; } \
106 virtual const char * GetServiceName() const { return ServiceName(); } \
107 virtual PObject * CreateInstance(P_INT_PTR) const { return new InstanceClass; } \
110 PFACTORY_CREATE(PPluginFactory, PPlugin_##serviceType##_##serviceName, #serviceType #serviceName, true)
112 #define PCREATE_PLUGIN_ARG_4(serviceName, serviceType, InstanceClass, DescriptorClass) \
113 PCREATE_PLUGIN_ARG_5(serviceName, serviceType, InstanceClass, DescriptorClass, )
115 #define PCREATE_PLUGIN_ARG_3(serviceName, serviceType, InstanceClass) \
116 PCREATE_PLUGIN_ARG_4(serviceName, serviceType, InstanceClass, PPlugin_##serviceType)
118 #define PCREATE_PLUGIN_ARG_2(serviceName, serviceType) \
119 PCREATE_PLUGIN_ARG_3(serviceName, serviceType, serviceType##_##serviceName)
121 #define PCREATE_PLUGIN_PART1(narg, args) PCREATE_PLUGIN_PART2(narg, args)
122 #define PCREATE_PLUGIN_PART2(narg, args) PCREATE_PLUGIN_ARG_##narg args
124 #define PCREATE_PLUGIN_STATIC(...) PCREATE_PLUGIN_PART1(PARG_COUNT(__VA_ARGS__), (__VA_ARGS__))
127 #define PPLUGIN_STATIC_LOAD(serviceName, serviceType) PFACTORY_LOAD(PPlugin_##serviceType##_##serviceName)
130 #if defined(_WIN32) && !defined(P_FORCE_STATIC_PLUGIN)
131 #define P_FORCE_STATIC_PLUGIN 1 // always define static plugins in Windows, since otherwise they seem not to work
134 #if defined(P_PLUGINS) && !defined(P_FORCE_STATIC_PLUGIN)
136 #define PCREATE_PLUGIN(serviceName, serviceType, ...) \
137 PCREATE_PLUGIN_STATIC(serviceName, serviceType, __VA_ARGS__) \
138 extern "C" void PWLibPlugin_TriggerRegister(PPluginManager * pluginMgr) \
139 { pluginMgr->RegisterService(#serviceType #serviceName); } \
140 extern "C" unsigned PWLibPlugin_GetAPIVersion (void) \
141 { return PTLIB_PLUGIN_API_VERSION; }
145 #define PCREATE_PLUGIN(...) \
146 PCREATE_PLUGIN_STATIC(__VA_ARGS__)
154 #endif // PTLIB_PLUGIN_H