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.
47template<class T>
48static 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
63DERIVED_CAST_IMPL(ModuleUserGenerator, XN_NODE_TYPE_USER)
64DERIVED_CAST_IMPL(ModuleHandsGenerator, XN_NODE_TYPE_HANDS)
65DERIVED_CAST_IMPL(ModuleGestureGenerator, XN_NODE_TYPE_GESTURE)
66DERIVED_CAST_IMPL(ModuleAudioGenerator, XN_NODE_TYPE_AUDIO)
68DERIVED_CAST_IMPL(ModuleDepthGenerator, XN_NODE_TYPE_DEPTH)
69DERIVED_CAST_IMPL(ModuleImageGenerator, XN_NODE_TYPE_IMAGE)
70DERIVED_CAST_IMPL(ModuleIRGenerator, XN_NODE_TYPE_IR)
71DERIVED_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
#define DERIVED_CAST_IMPL(T, enm)
Definition XnDerivedCast.h:50
@ XN_NODE_TYPE_PLAYER
Definition XnTypes.h:126
@ XN_NODE_TYPE_DEPTH
Definition XnTypes.h:108
@ XN_NODE_TYPE_HANDS
Definition XnTypes.h:135
@ XN_NODE_TYPE_MAP_GENERATOR
Definition XnTypes.h:143
@ XN_NODE_TYPE_SCRIPT
Definition XnTypes.h:144
@ XN_NODE_TYPE_DEVICE
Definition XnTypes.h:105
@ XN_NODE_TYPE_IR
Definition XnTypes.h:117
@ XN_NODE_TYPE_IMAGE
Definition XnTypes.h:111
@ XN_NODE_TYPE_AUDIO
Definition XnTypes.h:114
@ XN_NODE_TYPE_CODEC
Definition XnTypes.h:138
@ XN_NODE_TYPE_GENERATOR
Definition XnTypes.h:142
@ XN_NODE_TYPE_GESTURE
Definition XnTypes.h:129
@ XN_NODE_TYPE_RECORDER
Definition XnTypes.h:123
@ XN_NODE_TYPE_USER
Definition XnTypes.h:120
@ XN_NODE_TYPE_SCENE
Definition XnTypes.h:132