OpenNI 1.5.4
XnDerivedCast.h
Go to the documentation of this file.
1/****************************************************************************
2* *
3* OpenNI 1.x Alpha *
4* Copyright (C) 2011 PrimeSense Ltd. *
5* *
6* This file is part of OpenNI. *
7* *
8* OpenNI is free software: you can redistribute it and/or modify *
9* it under the terms of the GNU Lesser General Public License as published *
10* by the Free Software Foundation, either version 3 of the License, or *
11* (at your option) any later version. *
12* *
13* OpenNI is distributed in the hope that it will be useful, *
14* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16* GNU Lesser General Public License for more details. *
17* *
18* You should have received a copy of the GNU Lesser General Public License *
19* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
20* *
21****************************************************************************/
22/****************************************************************************
23* *
24* OpenNI 1.1 Alpha *
25* Copyright (C) 2011 PrimeSense Ltd. *
26* *
27* This file is part of OpenNI. *
28* *
29* OpenNI is free software: you can redistribute it and/or modify *
30* it under the terms of the GNU Lesser General Public License as published *
31* by the Free Software Foundation, either version 3 of the License, or *
32* (at your option) any later version. *
33* *
34* OpenNI is distributed in the hope that it will be useful, *
35* but WITHOUT ANY WARRANTY; without even the implied warranty of *
36* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
37* GNU Lesser General Public License for more details. *
38* *
39* You should have received a copy of the GNU Lesser General Public License *
40* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
41* *
42****************************************************************************/\
43
44#ifndef __XN_DERIVED_CAST_H__
45#define __XN_DERIVED_CAST_H__
46
47// derived_cast Acts as dynamic_cast without the need for RTTI. used in platforms that not implement RTTI well like Linux-Arm.
48template<class T>
49static T derived_cast(ModuleProductionNode* pPrdNode);
50
51#define DERIVED_CAST_IMPL(T, enm) \
52 template<> \
53 T* derived_cast<T*>(ModuleProductionNode* pPrdNode) \
54 { \
55 return (T*)pPrdNode->m_aInterfaces[enm]; \
56 }
57
64DERIVED_CAST_IMPL(ModuleUserGenerator, XN_NODE_TYPE_USER)
65DERIVED_CAST_IMPL(ModuleHandsGenerator, XN_NODE_TYPE_HANDS)
66DERIVED_CAST_IMPL(ModuleGestureGenerator, XN_NODE_TYPE_GESTURE)
67DERIVED_CAST_IMPL(ModuleAudioGenerator, XN_NODE_TYPE_AUDIO)
69DERIVED_CAST_IMPL(ModuleDepthGenerator, XN_NODE_TYPE_DEPTH)
70DERIVED_CAST_IMPL(ModuleImageGenerator, XN_NODE_TYPE_IMAGE)
71DERIVED_CAST_IMPL(ModuleIRGenerator, XN_NODE_TYPE_IR)
72DERIVED_CAST_IMPL(ModuleSceneAnalyzer, XN_NODE_TYPE_SCENE)
73
74#ifdef dynamic_cast
75#undef dynamic_cast
76#endif
77
78#define dynamic_cast derived_cast
79
80#endif
#define DERIVED_CAST_IMPL(T, enm)
Definition: XnDerivedCast.h:51
@ XN_NODE_TYPE_PLAYER
Definition: XnTypes.h:124
@ XN_NODE_TYPE_DEPTH
Definition: XnTypes.h:106
@ XN_NODE_TYPE_HANDS
Definition: XnTypes.h:133
@ XN_NODE_TYPE_MAP_GENERATOR
Definition: XnTypes.h:141
@ XN_NODE_TYPE_SCRIPT
Definition: XnTypes.h:142
@ XN_NODE_TYPE_DEVICE
Definition: XnTypes.h:103
@ XN_NODE_TYPE_IR
Definition: XnTypes.h:115
@ XN_NODE_TYPE_IMAGE
Definition: XnTypes.h:109
@ XN_NODE_TYPE_AUDIO
Definition: XnTypes.h:112
@ XN_NODE_TYPE_CODEC
Definition: XnTypes.h:136
@ XN_NODE_TYPE_GENERATOR
Definition: XnTypes.h:140
@ XN_NODE_TYPE_GESTURE
Definition: XnTypes.h:127
@ XN_NODE_TYPE_RECORDER
Definition: XnTypes.h:121
@ XN_NODE_TYPE_USER
Definition: XnTypes.h:118
@ XN_NODE_TYPE_SCENE
Definition: XnTypes.h:130