22 #ifndef __XN_MODULE_CPP_REGISTRATION_H__
23 #define __XN_MODULE_CPP_REGISTRATION_H__
37 #define _XN_MODULE_INST g_pTheModule
39 #define _CONCAT(a,b) a##b
46 #define __XN_EXPORT_NODE_COMMON(ExportedClass, ExportedName, Type) \
48 static ExportedClass* ExportedName = new ExportedClass(); \
50 void XN_CALLBACK_TYPE _CONCAT(ExportedClass,GetDescription)(XnProductionNodeDescription* pDescription) \
52 ExportedName->GetDescription(pDescription); \
55 XnStatus XN_CALLBACK_TYPE _CONCAT(ExportedClass,EnumerateProductionTrees) \
56 (XnContext* pContext, XnNodeInfoList* pTreesList, XnEnumerationErrors* pErrors) \
58 Context context(pContext); \
59 NodeInfoList list(pTreesList); \
60 EnumerationErrors errors(pErrors); \
61 return ExportedName->EnumerateProductionTrees(context, list, pErrors == NULL ? NULL : &errors); \
64 XnStatus XN_CALLBACK_TYPE _CONCAT(ExportedClass,Create)(XnContext* pContext, \
65 const XnChar* strInstanceName, \
66 const XnChar* strCreationInfo, \
67 XnNodeInfoList* pNeededTrees, \
68 const XnChar* strConfigurationDir, \
69 XnModuleNodeHandle* phInstance) \
71 xn::NodeInfoList* pNeeded = NULL; \
72 if (pNeededTrees != NULL) \
74 pNeeded = XN_NEW(xn::NodeInfoList, pNeededTrees); \
76 ModuleProductionNode* pNode; \
77 Context context(pContext); \
78 XnStatus nRetVal = ExportedName->Create(context, strInstanceName, strCreationInfo, \
79 pNeeded, strConfigurationDir, &pNode); \
80 if (nRetVal != XN_STATUS_OK) \
85 *phInstance = __ModuleNodeToHandle(pNode); \
87 return (XN_STATUS_OK); \
90 void XN_CALLBACK_TYPE _CONCAT(ExportedClass,Destroy)(XnModuleNodeHandle hInstance) \
92 ModuleProductionNode* pNode = (ModuleProductionNode*)hInstance; \
93 ExportedName->Destroy(pNode); \
96 void XN_CALLBACK_TYPE _CONCAT(ExportedClass,GetExportedInterface)( \
97 XnModuleExportedProductionNodeInterface* pInterface) \
99 pInterface->GetDescription = _CONCAT(ExportedClass,GetDescription); \
100 pInterface->EnumerateProductionTrees = _CONCAT(ExportedClass,EnumerateProductionTrees); \
101 pInterface->Create = _CONCAT(ExportedClass,Create); \
102 pInterface->Destroy = _CONCAT(ExportedClass,Destroy); \
103 pInterface->GetInterface.General = __ModuleGetGetInterfaceFunc(Type); \
106 static XnStatus _CONCAT(ExportedClass,RegisterResult) = \
107 _XN_MODULE_INST->AddExportedNode(_CONCAT(ExportedClass,GetExportedInterface));
109 #define _XN_EXPORT_NODE_COMMON(ExportedClass, Type) \
110 __XN_EXPORT_NODE_COMMON(ExportedClass, _g_##ExportedClass, Type)
182 #if XN_PLATFORM_SUPPORTS_DYNAMIC_LIBS
183 #define XN_EXPORT_MODULE(ModuleClass) \
185 ModuleClass __moduleInstance; \
186 Module* _XN_MODULE_INST = &__moduleInstance;
188 #define XN_EXPORT_MODULE(ModuleClass) \
190 static ModuleClass __moduleInstance; \
191 static Module* _XN_MODULE_INST = &__moduleInstance;
195 #define XN_EXPORT_NODE(ExportedClass, nodeType) \
196 _XN_EXPORT_NODE_COMMON(ExportedClass, nodeType)
199 #define XN_EXPORT_DEVICE(ExportedClass) \
200 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_DEVICE)
203 #define XN_EXPORT_DEPTH(ExportedClass) \
204 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_DEPTH)
207 #define XN_EXPORT_IMAGE(ExportedClass) \
208 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_IMAGE)
211 #define XN_EXPORT_IR(ExportedClass) \
212 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_IR)
214 #define XN_EXPORT_USER(ExportedClass) \
215 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_USER)
217 #define XN_EXPORT_HANDS(ExportedClass) \
218 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_HANDS)
220 #define XN_EXPORT_GESTURE(ExportedClass) \
221 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_GESTURE)
223 #define XN_EXPORT_SCENE(ExportedClass) \
224 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_SCENE)
227 #define XN_EXPORT_AUDIO(ExportedClass) \
228 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_AUDIO)
231 #define XN_EXPORT_RECORDER(ExportedClass) \
232 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_RECORDER)
235 #define XN_EXPORT_PLAYER(ExportedClass) \
236 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_PLAYER)
238 #define XN_EXPORT_CODEC(ExportedClass) \
239 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_CODEC)
241 #define XN_EXPORT_SCRIPT(ExportedClass) \
242 _XN_EXPORT_NODE_COMMON(ExportedClass, XN_NODE_TYPE_SCRIPT)
247 #if XN_PLATFORM_SUPPORTS_DYNAMIC_LIBS
249 #define XN_MODULE_FUNC_TYPE XN_C_API_EXPORT
250 extern Module* _XN_MODULE_INST;
252 #define XN_MODULE_FUNC_TYPE static
253 static Module* _XN_MODULE_INST;
260 nRetVal = _XN_MODULE_INST->Load();
268 _XN_MODULE_INST->Unload();
273 return _XN_MODULE_INST->GetExportedNodesCount();
278 return _XN_MODULE_INST->GetExportedNodes(aEntryPoints, nCount);
289 #if !XN_PLATFORM_SUPPORTS_DYNAMIC_LIBS
303 #endif // __XN_MODULE_CPP_REGISTRATION_H__