XnDerivedCast.h
Go to the documentation of this file.
/****************************************************************************
* *
* OpenNI 1.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* OpenNI is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* OpenNI is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
* *
****************************************************************************/
/****************************************************************************
* *
* OpenNI 1.1 Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* OpenNI is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* OpenNI is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
* *
****************************************************************************/\
#ifndef __XN_DERIVED_CAST_H__
#define __XN_DERIVED_CAST_H__
// derived_cast Acts as dynamic_cast without the need for RTTI. used in platforms that not implement RTTI well like Linux-Arm.
template<class T>
static T derived_cast(ModuleProductionNode* pPrdNode);
#define DERIVED_CAST_IMPL(T, enm) \
template<> \
T* derived_cast<T*>(ModuleProductionNode* pPrdNode) \
{ \
return (T*)pPrdNode->m_aInterfaces[enm]; \
}
DERIVED_CAST_IMPL(ModuleDevice, XN_NODE_TYPE_DEVICE)
DERIVED_CAST_IMPL(ModuleRecorder, XN_NODE_TYPE_RECORDER)
DERIVED_CAST_IMPL(ModulePlayer, XN_NODE_TYPE_PLAYER)
DERIVED_CAST_IMPL(ModuleCodec, XN_NODE_TYPE_CODEC)
DERIVED_CAST_IMPL(ModuleScriptNode, XN_NODE_TYPE_SCRIPT)
DERIVED_CAST_IMPL(ModuleGenerator, XN_NODE_TYPE_GENERATOR)
DERIVED_CAST_IMPL(ModuleUserGenerator, XN_NODE_TYPE_USER)
DERIVED_CAST_IMPL(ModuleHandsGenerator, XN_NODE_TYPE_HANDS)
DERIVED_CAST_IMPL(ModuleGestureGenerator, XN_NODE_TYPE_GESTURE)
DERIVED_CAST_IMPL(ModuleAudioGenerator, XN_NODE_TYPE_AUDIO)
DERIVED_CAST_IMPL(ModuleMapGenerator, XN_NODE_TYPE_MAP_GENERATOR)
DERIVED_CAST_IMPL(ModuleDepthGenerator, XN_NODE_TYPE_DEPTH)
DERIVED_CAST_IMPL(ModuleImageGenerator, XN_NODE_TYPE_IMAGE)
DERIVED_CAST_IMPL(ModuleIRGenerator, XN_NODE_TYPE_IR)
DERIVED_CAST_IMPL(ModuleSceneAnalyzer, XN_NODE_TYPE_SCENE)
#ifdef dynamic_cast
#undef dynamic_cast
#endif
#define dynamic_cast derived_cast
#endif
DERIVED_CAST_IMPL
#define DERIVED_CAST_IMPL(T, enm)
Definition XnDerivedCast.h:51
XN_NODE_TYPE_PLAYER
@ XN_NODE_TYPE_PLAYER
Definition XnTypes.h:124
XN_NODE_TYPE_DEPTH
@ XN_NODE_TYPE_DEPTH
Definition XnTypes.h:106
XN_NODE_TYPE_HANDS
@ XN_NODE_TYPE_HANDS
Definition XnTypes.h:133
XN_NODE_TYPE_MAP_GENERATOR
@ XN_NODE_TYPE_MAP_GENERATOR
Definition XnTypes.h:141
XN_NODE_TYPE_SCRIPT
@ XN_NODE_TYPE_SCRIPT
Definition XnTypes.h:142
XN_NODE_TYPE_DEVICE
@ XN_NODE_TYPE_DEVICE
Definition XnTypes.h:103
XN_NODE_TYPE_IR
@ XN_NODE_TYPE_IR
Definition XnTypes.h:115
XN_NODE_TYPE_IMAGE
@ XN_NODE_TYPE_IMAGE
Definition XnTypes.h:109
XN_NODE_TYPE_AUDIO
@ XN_NODE_TYPE_AUDIO
Definition XnTypes.h:112
XN_NODE_TYPE_CODEC
@ XN_NODE_TYPE_CODEC
Definition XnTypes.h:136
XN_NODE_TYPE_GENERATOR
@ XN_NODE_TYPE_GENERATOR
Definition XnTypes.h:140
XN_NODE_TYPE_GESTURE
@ XN_NODE_TYPE_GESTURE
Definition XnTypes.h:127
XN_NODE_TYPE_RECORDER
@ XN_NODE_TYPE_RECORDER
Definition XnTypes.h:121
XN_NODE_TYPE_USER
@ XN_NODE_TYPE_USER
Definition XnTypes.h:118
XN_NODE_TYPE_SCENE
@ XN_NODE_TYPE_SCENE
Definition XnTypes.h:130