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.
48 template<class T>
49 static 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 
62 DERIVED_CAST_IMPL(ModuleScriptNode, XN_NODE_TYPE_SCRIPT)
64 DERIVED_CAST_IMPL(ModuleUserGenerator, XN_NODE_TYPE_USER)
65 DERIVED_CAST_IMPL(ModuleHandsGenerator, XN_NODE_TYPE_HANDS)
66 DERIVED_CAST_IMPL(ModuleGestureGenerator, XN_NODE_TYPE_GESTURE)
67 DERIVED_CAST_IMPL(ModuleAudioGenerator, XN_NODE_TYPE_AUDIO)
69 DERIVED_CAST_IMPL(ModuleDepthGenerator, XN_NODE_TYPE_DEPTH)
70 DERIVED_CAST_IMPL(ModuleImageGenerator, XN_NODE_TYPE_IMAGE)
71 DERIVED_CAST_IMPL(ModuleIRGenerator, XN_NODE_TYPE_IR)
72 DERIVED_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
XN_NODE_TYPE_USER
Definition: XnTypes.h:117
XN_NODE_TYPE_SCENE
Definition: XnTypes.h:129
XN_NODE_TYPE_SCRIPT
Definition: XnTypes.h:141
XN_NODE_TYPE_CODEC
Definition: XnTypes.h:135
XN_NODE_TYPE_DEPTH
Definition: XnTypes.h:105
XN_NODE_TYPE_IR
Definition: XnTypes.h:114
XN_NODE_TYPE_RECORDER
Definition: XnTypes.h:120
XN_NODE_TYPE_MAP_GENERATOR
Definition: XnTypes.h:140
XN_NODE_TYPE_DEVICE
Definition: XnTypes.h:102
XN_NODE_TYPE_GESTURE
Definition: XnTypes.h:126
XN_NODE_TYPE_IMAGE
Definition: XnTypes.h:108
XN_NODE_TYPE_AUDIO
Definition: XnTypes.h:111
XN_NODE_TYPE_HANDS
Definition: XnTypes.h:132
XN_NODE_TYPE_GENERATOR
Definition: XnTypes.h:139
DERIVED_CAST_IMPL
#define DERIVED_CAST_IMPL(T, enm)
Definition: XnDerivedCast.h:49
XN_NODE_TYPE_PLAYER
Definition: XnTypes.h:123