OpenNI 1.5.7
XnDerivedCast.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * *
3 * OpenNI 1.x Alpha *
4 * Copyright (C) 2012 PrimeSense Ltd. *
5 * *
6 * This file is part of OpenNI. *
7 * *
8 * Licensed under the Apache License, Version 2.0 (the "License"); *
9 * you may not use this file except in compliance with the License. *
10 * You may obtain a copy of the License at *
11 * *
12 * http://www.apache.org/licenses/LICENSE-2.0 *
13 * *
14 * Unless required by applicable law or agreed to in writing, software *
15 * distributed under the License is distributed on an "AS IS" BASIS, *
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
17 * See the License for the specific language governing permissions and *
18 * limitations under the License. *
19 * *
20 *****************************************************************************/
21 /****************************************************************************
22 * *
23 * OpenNI 1.1 Alpha *
24 * Copyright (C) 2011 PrimeSense Ltd. *
25 * *
26 * This file is part of OpenNI. *
27 * *
28 * OpenNI is free software: you can redistribute it and/or modify *
29 * it under the terms of the GNU Lesser General Public License as published *
30 * by the Free Software Foundation, either version 3 of the License, or *
31 * (at your option) any later version. *
32 * *
33 * OpenNI is distributed in the hope that it will be useful, *
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
36 * GNU Lesser General Public License for more details. *
37 * *
38 * You should have received a copy of the GNU Lesser General Public License *
39 * along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
40 * *
41 ****************************************************************************/\
42 
43 #ifndef __XN_DERIVED_CAST_H__
44 #define __XN_DERIVED_CAST_H__
45 
46 // derived_cast Acts as dynamic_cast without the need for RTTI. used in platforms that not implement RTTI well like Linux-Arm.
47 template<class T>
48 static T derived_cast(ModuleProductionNode* pPrdNode);
49 
50 #define DERIVED_CAST_IMPL(T, enm) \
51  template<> \
52  T* derived_cast<T*>(ModuleProductionNode* pPrdNode) \
53  { \
54  return (T*)pPrdNode->m_aInterfaces[enm]; \
55  }
56 
61 DERIVED_CAST_IMPL(ModuleScriptNode, XN_NODE_TYPE_SCRIPT)
63 DERIVED_CAST_IMPL(ModuleUserGenerator, XN_NODE_TYPE_USER)
64 DERIVED_CAST_IMPL(ModuleHandsGenerator, XN_NODE_TYPE_HANDS)
65 DERIVED_CAST_IMPL(ModuleGestureGenerator, XN_NODE_TYPE_GESTURE)
66 DERIVED_CAST_IMPL(ModuleAudioGenerator, XN_NODE_TYPE_AUDIO)
68 DERIVED_CAST_IMPL(ModuleDepthGenerator, XN_NODE_TYPE_DEPTH)
69 DERIVED_CAST_IMPL(ModuleImageGenerator, XN_NODE_TYPE_IMAGE)
70 DERIVED_CAST_IMPL(ModuleIRGenerator, XN_NODE_TYPE_IR)
71 DERIVED_CAST_IMPL(ModuleSceneAnalyzer, XN_NODE_TYPE_SCENE)
72 
73 #ifdef dynamic_cast
74 #undef dynamic_cast
75 #endif
76 
77 #define dynamic_cast derived_cast
78 
79 #endif
Definition: XnTypes.h:114
Definition: XnTypes.h:138
Definition: XnTypes.h:129
Definition: XnTypes.h:117
Definition: XnTypes.h:135
#define DERIVED_CAST_IMPL(T, enm)
Definition: XnDerivedCast.h:50
Definition: XnTypes.h:123
Definition: XnTypes.h:143
Definition: XnTypes.h:105
Definition: XnTypes.h:144
Definition: XnTypes.h:120
Definition: XnTypes.h:111
Definition: XnTypes.h:126
Definition: XnTypes.h:142
Definition: XnTypes.h:132
Definition: XnTypes.h:108