21 #ifndef __XN_MODULE_CPP_REGISTRATION_H__
22 #define __XN_MODULE_CPP_REGISTRATION_H__
36 #define _XN_MODULE_INST g_pTheModule
38 #define _CONCAT(a,b) a##b
45 #define __XN_EXPORT_NODE_COMMON(ExportedClass, ExportedName, Type) \
47 static ExportedClass* ExportedName = new ExportedClass(); \
49 void XN_CALLBACK_TYPE _CONCAT(ExportedClass,GetDescription)(XnProductionNodeDescription* pDescription) \
51 ExportedName->GetDescription(pDescription); \
54 XnStatus XN_CALLBACK_TYPE _CONCAT(ExportedClass,EnumerateProductionTrees) \
55 (XnContext* pContext, XnNodeInfoList* pTreesList, XnEnumerationErrors* pErrors) \
57 Context context(pContext); \
58 NodeInfoList list(pTreesList); \
59 EnumerationErrors errors(pErrors); \
60 return ExportedName->EnumerateProductionTrees(context, list, pErrors == NULL ? NULL : &errors); \
63 XnStatus XN_CALLBACK_TYPE _CONCAT(ExportedClass,Create)(XnContext* pContext, \
64 const XnChar* strInstanceName, \
65 const XnChar* strCreationInfo, \
66 XnNodeInfoList* pNeededTrees, \
67 const XnChar* strConfigurationDir, \
68 XnModuleNodeHandle* phInstance) \
70 xn::NodeInfoList* pNeeded = NULL; \
71 if (pNeededTrees != NULL) \
73 pNeeded = XN_NEW(xn::NodeInfoList, pNeededTrees); \
75 ModuleProductionNode* pNode; \
76 Context context(pContext); \
77 XnStatus nRetVal = ExportedName->Create(context, strInstanceName, strCreationInfo, \
78 pNeeded, strConfigurationDir, &pNode); \
79 if (nRetVal != XN_STATUS_OK) \
84 *phInstance = __ModuleNodeToHandle(pNode); \
86 return (XN_STATUS_OK); \
89 void XN_CALLBACK_TYPE _CONCAT(ExportedClass,Destroy)(XnModuleNodeHandle hInstance) \
91 ModuleProductionNode* pNode = (ModuleProductionNode*)hInstance; \
92 ExportedName->Destroy(pNode); \
95 void XN_CALLBACK_TYPE _CONCAT(ExportedClass,GetExportedInterface)( \
96 XnModuleExportedProductionNodeInterface* pInterface) \
98 pInterface->GetDescription = _CONCAT(ExportedClass,GetDescription); \
99 pInterface->EnumerateProductionTrees = _CONCAT(ExportedClass,EnumerateProductionTrees); \
100 pInterface->Create = _CONCAT(ExportedClass,Create); \
101 pInterface->Destroy = _CONCAT(ExportedClass,Destroy); \
102 pInterface->GetInterface.General = __ModuleGetGetInterfaceFunc(Type); \
105 static XnStatus _CONCAT(ExportedClass,RegisterResult) = \
106 _XN_MODULE_INST->AddExportedNode(_CONCAT(ExportedClass,GetExportedInterface));
108 #define _XN_EXPORT_NODE_COMMON(ExportedClass, Type) \
109 __XN_EXPORT_NODE_COMMON(ExportedClass, _g_##ExportedClass, Type)
181 #if XN_PLATFORM_SUPPORTS_DYNAMIC_LIBS
182 #define XN_EXPORT_MODULE(ModuleClass) \
184 ModuleClass __moduleInstance; \
185 Module* _XN_MODULE_INST = &__moduleInstance;
187 #define XN_EXPORT_MODULE(ModuleClass) \
189 static ModuleClass __moduleInstance; \
190 static Module* _XN_MODULE_INST = &__moduleInstance;
194 #define XN_EXPORT_NODE(ExportedClass, nodeType) \
195 _XN_EXPORT_NODE_COMMON(ExportedClass, nodeType)
198 #define XN_EXPORT_DEVICE(ExportedClass) \
199 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_DEVICE)
202 #define XN_EXPORT_DEPTH(ExportedClass) \
203 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_DEPTH)
206 #define XN_EXPORT_IMAGE(ExportedClass) \
207 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_IMAGE)
210 #define XN_EXPORT_IR(ExportedClass) \
211 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_IR)
213 #define XN_EXPORT_USER(ExportedClass) \
214 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_USER)
216 #define XN_EXPORT_HANDS(ExportedClass) \
217 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_HANDS)
219 #define XN_EXPORT_GESTURE(ExportedClass) \
220 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_GESTURE)
222 #define XN_EXPORT_SCENE(ExportedClass) \
223 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_SCENE)
226 #define XN_EXPORT_AUDIO(ExportedClass) \
227 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_AUDIO)
230 #define XN_EXPORT_RECORDER(ExportedClass) \
231 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_RECORDER)
234 #define XN_EXPORT_PLAYER(ExportedClass) \
235 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_PLAYER)
237 #define XN_EXPORT_CODEC(ExportedClass) \
238 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_CODEC)
240 #define XN_EXPORT_SCRIPT(ExportedClass) \
241 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_SCRIPT)
246 #if XN_PLATFORM_SUPPORTS_DYNAMIC_LIBS
248 #define XN_MODULE_FUNC_TYPE XN_C_API_EXPORT
249 extern Module* _XN_MODULE_INST;
251 #define XN_MODULE_FUNC_TYPE static
252 static Module* _XN_MODULE_INST;
259 nRetVal = _XN_MODULE_INST->Load();
267 _XN_MODULE_INST->Unload();
272 return _XN_MODULE_INST->GetExportedNodesCount();
277 return _XN_MODULE_INST->GetExportedNodes(aEntryPoints, nCount);
288 #if !XN_PLATFORM_SUPPORTS_DYNAMIC_LIBS
302 #endif // __XN_MODULE_CPP_REGISTRATION_H__