00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://ogre.sourceforge.net/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #ifndef __Exception_H_ 00026 #define __Exception_H_ 00027 00028 // Precompiler options 00029 #include "OgrePrerequisites.h" 00030 00031 #include "OgreString.h" 00032 00033 #define Except( num, desc, src ) throw( Exception( num, desc, src, __FILE__, __LINE__ ) ) 00034 00035 // Stack unwinding options 00036 #if OGRE_STACK_UNWINDING == 1 00037 # if OGRE_COMPILER != COMPILER_BORL 00038 # define OgreGuard( a ) Exception::_pushFunction( (a) ) 00039 # else 00040 # define OgreGuard( a ) Exception::_pushFunction( __FUNC__ ) 00041 # endif 00042 00043 # define OgreUnguard() Exception::_popFunction() 00044 # define OgreUnguardRet( a ) { Exception::_popFunction(); return a; } 00045 00046 #else 00047 # define OgreGuard( a ) 00048 # define OgreUnguard() 00049 # define OgreUnguardRet( a ) return a; 00050 00051 #endif 00052 00053 // Release asserts - throw exceptions 00054 #if OGRE_RELEASE_ASSERT == 1 00055 # ifdef _DEBUG 00056 # define OgreAssert( a, b ) assert( (a) && (b) ) 00057 00058 # else 00059 # if OGRE_COMP != COMP_BORL 00060 # define OgreAssert( a, b ) if( !(a) ) Except( Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info" ) 00061 # else 00062 # define OgreAssert( a, b ) if( !(a) ) Except( Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ ) 00063 # endif 00064 00065 # endif 00066 00067 #else 00068 # define OgreAssert( a, b ) assert( (a) && (b) ) 00069 00070 #endif 00071 00072 #define OGRE_CALL_STACK_DEPTH 512 00073 00074 namespace Ogre { 00088 class _OgreExport Exception 00089 { 00090 protected: 00091 long line; 00092 int number; 00093 String description; 00094 String source; 00095 String file; 00096 static Exception* last; 00097 00098 static OgreChar msFunctionStack[ OGRE_CALL_STACK_DEPTH ][ 256 ]; 00099 static ushort msStackDepth; 00100 public: 00106 enum ExceptionCodes { 00107 UNIMPLEMENTED_FEATURE, 00108 ERR_CANNOT_WRITE_TO_FILE, 00109 ERR_NO_RENDERSYSTEM_SELECTED, 00110 ERR_DIALOG_OPEN_ERROR, 00111 ERR_INVALIDPARAMS, 00112 ERR_RENDERINGAPI_ERROR, 00113 ERR_DUPLICATE_ITEM, 00114 ERR_ITEM_NOT_FOUND, 00115 ERR_FILE_NOT_FOUND, 00116 ERR_INTERNAL_ERROR, 00117 ERR_RT_ASSERTION_FAILED 00118 }; 00119 00122 Exception( int number, const String& description, const String& source ); 00123 00126 Exception( int number, const String& description, const String& source, char* file, long line ); 00127 00130 Exception(const Exception& rhs); 00131 00134 void operator = (const Exception& rhs); 00135 00146 String getFullDescription(void) const; 00147 00150 int getNumber(void) throw(); 00151 00154 static Exception* getLastException(void) throw(); 00155 00158 static void _pushFunction( const String& strFuncName ) throw(); 00161 static void _popFunction() throw(); 00162 00163 }; 00164 } // Namespace Ogre 00165 #endif
Copyright © 2002 by The OGRE Team