![]() |
OpenNI 1.5.7
|
00001 /***************************************************************************** 00002 * * 00003 * OpenNI 1.x Alpha * 00004 * Copyright (C) 2012 PrimeSense Ltd. * 00005 * * 00006 * This file is part of OpenNI. * 00007 * * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); * 00009 * you may not use this file except in compliance with the License. * 00010 * You may obtain a copy of the License at * 00011 * * 00012 * http://www.apache.org/licenses/LICENSE-2.0 * 00013 * * 00014 * Unless required by applicable law or agreed to in writing, software * 00015 * distributed under the License is distributed on an "AS IS" BASIS, * 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00017 * See the License for the specific language governing permissions and * 00018 * limitations under the License. * 00019 * * 00020 *****************************************************************************/ 00021 /**************************************************************************** 00022 * * 00023 * OpenNI 1.1 Alpha * 00024 * Copyright (C) 2011 PrimeSense Ltd. * 00025 * * 00026 * This file is part of OpenNI. * 00027 * * 00028 * OpenNI is free software: you can redistribute it and/or modify * 00029 * it under the terms of the GNU Lesser General Public License as published * 00030 * by the Free Software Foundation, either version 3 of the License, or * 00031 * (at your option) any later version. * 00032 * * 00033 * OpenNI is distributed in the hope that it will be useful, * 00034 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00035 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00036 * GNU Lesser General Public License for more details. * 00037 * * 00038 * You should have received a copy of the GNU Lesser General Public License * 00039 * along with OpenNI. If not, see <http://www.gnu.org/licenses/>. * 00040 * * 00041 ****************************************************************************/\ 00042 00043 #ifndef __XN_DERIVED_CAST_H__ 00044 #define __XN_DERIVED_CAST_H__ 00045 00046 // derived_cast Acts as dynamic_cast without the need for RTTI. used in platforms that not implement RTTI well like Linux-Arm. 00047 template<class T> 00048 static T derived_cast(ModuleProductionNode* pPrdNode); 00049 00050 #define DERIVED_CAST_IMPL(T, enm) \ 00051 template<> \ 00052 T* derived_cast<T*>(ModuleProductionNode* pPrdNode) \ 00053 { \ 00054 return (T*)pPrdNode->m_aInterfaces[enm]; \ 00055 } 00056 00057 DERIVED_CAST_IMPL(ModuleDevice, XN_NODE_TYPE_DEVICE) 00058 DERIVED_CAST_IMPL(ModuleRecorder, XN_NODE_TYPE_RECORDER) 00059 DERIVED_CAST_IMPL(ModulePlayer, XN_NODE_TYPE_PLAYER) 00060 DERIVED_CAST_IMPL(ModuleCodec, XN_NODE_TYPE_CODEC) 00061 DERIVED_CAST_IMPL(ModuleScriptNode, XN_NODE_TYPE_SCRIPT) 00062 DERIVED_CAST_IMPL(ModuleGenerator, XN_NODE_TYPE_GENERATOR) 00063 DERIVED_CAST_IMPL(ModuleUserGenerator, XN_NODE_TYPE_USER) 00064 DERIVED_CAST_IMPL(ModuleHandsGenerator, XN_NODE_TYPE_HANDS) 00065 DERIVED_CAST_IMPL(ModuleGestureGenerator, XN_NODE_TYPE_GESTURE) 00066 DERIVED_CAST_IMPL(ModuleAudioGenerator, XN_NODE_TYPE_AUDIO) 00067 DERIVED_CAST_IMPL(ModuleMapGenerator, XN_NODE_TYPE_MAP_GENERATOR) 00068 DERIVED_CAST_IMPL(ModuleDepthGenerator, XN_NODE_TYPE_DEPTH) 00069 DERIVED_CAST_IMPL(ModuleImageGenerator, XN_NODE_TYPE_IMAGE) 00070 DERIVED_CAST_IMPL(ModuleIRGenerator, XN_NODE_TYPE_IR) 00071 DERIVED_CAST_IMPL(ModuleSceneAnalyzer, XN_NODE_TYPE_SCENE) 00072 00073 #ifdef dynamic_cast 00074 #undef dynamic_cast 00075 #endif 00076 00077 #define dynamic_cast derived_cast 00078 00079 #endif