Ap4DynamicCast.h
Go to the documentation of this file.00001 /***************************************************************** 00002 | 00003 | AP4 - Target Platform and Compiler Configuration 00004 | 00005 | Copyright 2002-2008 Axiomatic Systems, LLC 00006 | 00007 | 00008 | This file is part of Bento4/AP4 (MP4 Atom Processing Library). 00009 | 00010 | Unless you have obtained Bento4 under a difference license, 00011 | this version of Bento4 is Bento4|GPL. 00012 | Bento4|GPL is free software; you can redistribute it and/or modify 00013 | it under the terms of the GNU General Public License as published by 00014 | the Free Software Foundation; either version 2, or (at your option) 00015 | any later version. 00016 | 00017 | Bento4|GPL is distributed in the hope that it will be useful, 00018 | but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 | GNU General Public License for more details. 00021 | 00022 | You should have received a copy of the GNU General Public License 00023 | along with Bento4|GPL; see the file COPYING. If not, write to the 00024 | Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 00025 | 02111-1307, USA. 00026 | 00027 ****************************************************************/ 00032 #ifndef _AP4_DYNAMIC_CAST_H_ 00033 #define _AP4_DYNAMIC_CAST_H_ 00034 00035 /*---------------------------------------------------------------------- 00036 | includes 00037 +---------------------------------------------------------------------*/ 00038 #include "Ap4Config.h" 00039 00040 /*---------------------------------------------------------------------- 00041 | macros 00042 +---------------------------------------------------------------------*/ 00043 #if defined(AP4_CONFIG_NO_RTTI) 00044 #define AP4_DYNAMIC_CAST(_class,_object) \ 00045 ( ((_object)==0) ? 0 : reinterpret_cast<_class*>((_object)->DynamicCast(&_class::_class_##_class)) ) 00046 #define AP4_IMPLEMENT_DYNAMIC_CAST(_class) \ 00047 static int _class_##_class; \ 00048 virtual void* DynamicCast(const void* class_anchor) { \ 00049 if (class_anchor == &_class::_class_##_class) { \ 00050 return static_cast<_class*>(this); \ 00051 } \ 00052 return NULL; \ 00053 } 00054 #define AP4_IMPLEMENT_DYNAMIC_CAST_D(_class,_superclass)\ 00055 static int _class_##_class; \ 00056 virtual void* DynamicCast(const void* class_anchor) { \ 00057 if (class_anchor == &_class::_class_##_class) { \ 00058 return static_cast<_class*>(this); \ 00059 } else { \ 00060 return _superclass::DynamicCast(class_anchor); \ 00061 } \ 00062 } 00063 #define AP4_IMPLEMENT_DYNAMIC_CAST_D2(_class,_superclass,_mixin)\ 00064 static int _class_##_class; \ 00065 virtual void* DynamicCast(const void* class_anchor) { \ 00066 if (class_anchor == &_class::_class_##_class) { \ 00067 return static_cast<_class*>(this); \ 00068 } else { \ 00069 void* sup = _superclass::DynamicCast(class_anchor); \ 00070 if (sup) return sup; \ 00071 return _mixin::DynamicCast(class_anchor); \ 00072 } \ 00073 } 00074 #define AP4_DEFINE_DYNAMIC_CAST_ANCHOR(_class) int _class::_class_##_class = 0; 00075 00076 #else 00077 00078 #define AP4_DYNAMIC_CAST(_class,_object) dynamic_cast<_class*>(_object) 00079 #define AP4_IMPLEMENT_DYNAMIC_CAST(_class) 00080 #define AP4_IMPLEMENT_DYNAMIC_CAST_D(_class,_superclass) 00081 #define AP4_IMPLEMENT_DYNAMIC_CAST_D2(_class,_superclass,_mixin) 00082 #define AP4_DEFINE_DYNAMIC_CAST_ANCHOR(_class) 00083 00084 #endif 00085 00086 #endif // _AP4_DYNAMIC_CAST_H_
Generated on Thu May 13 16:36:32 2010 for Bento4 MP4 SDK by
