Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# OgreException.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004 (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    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( Ogre::Exception( num, desc, src, __FILE__, __LINE__ ) )
    00034
    00035 // Stack unwinding options
    00036 // OgreUnguard and OgreUnguardRet are deprecated
    00037 #if OGRE_STACK_UNWINDING == 1
    00038 #   if OGRE_COMPILER != COMPILER_BORL
    00039 #       define OgreGuard( a ) Ogre::AutomaticGuardUnguard _auto_guard_object( (a) )
    00040 #   else
    00041 #       define OgreGuard( a ) Ogre::AutomaticGuardUnguard _auto_guard_object( __FUNC__ )
    00042 #   endif
    00043
    00044 #   define OgreUnguard()
    00045 #   define OgreUnguardRet( a ) return a
    00046
    00047 #else
    00048 #   define OgreGuard( a )
    00049 #   define OgreUnguard()
    00050 #   define OgreUnguardRet( a ) return a
    00051
    00052 #endif
    00053
    00054 // Backwards compatibility with old assert mode definitions
    00055 #if OGRE_RELEASE_ASSERT == 1
    00056 #   define OGRE_ASSERT_MODE 1
    00057 #endif
    00058
    00059 // Check for OGRE assert mode
    00060
    00061 // RELEASE_EXCEPTIONS mode
    00062 #if OGRE_ASSERT_MODE == 1
    00063 #   ifdef _DEBUG
    00064 #       define OgreAssert( a, b ) assert( (a) && (b) )
    00065
    00066 #   else
    00067 #       if OGRE_COMP != COMPILER_BORL
    00068 #           define OgreAssert( a, b ) if( !(a) ) Except( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
    00069 #       else
    00070 #           define OgreAssert( a, b ) if( !(a) ) Except( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
    00071 #       endif
    00072
    00073 #   endif
    00074
    00075 // EXCEPTIONS mode
    00076 #elif OGRE_ASSERT_MODE == 2
    00077 #   if OGRE_COMP != COMPILER_BORL
    00078 #       define OgreAssert( a, b ) if( !(a) ) Except( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
    00079 #   else
    00080 #       define OgreAssert( a, b ) if( !(a) ) Except( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
    00081 #   endif
    00082
    00083 // STANDARD mode
    00084 #else
    00085 #   define OgreAssert( a, b ) assert( (a) && (b) )
    00086
    00087 #endif
    00088
    00089 #define OGRE_CALL_STACK_DEPTH 512
    00090
    00091 namespace Ogre {
    00105     class _OgreExport Exception
    00106     {
    00107     protected:
    00108         long line;
    00109         int number;
    00110         String description;
    00111         String source;
    00112         String file;
    00113         ushort stackDepth;
    00114         static Exception* last;
    00115
    00116         static OgreChar msFunctionStack[ OGRE_CALL_STACK_DEPTH ][ 256 ];
    00117         static ushort   msStackDepth;
    00118     public:
    00124         enum ExceptionCodes {
    00125             UNIMPLEMENTED_FEATURE,
    00126             ERR_CANNOT_WRITE_TO_FILE,
    00127             ERR_NO_RENDERSYSTEM_SELECTED,
    00128             ERR_DIALOG_OPEN_ERROR,
    00129             ERR_INVALIDPARAMS,
    00130             ERR_RENDERINGAPI_ERROR,
    00131             ERR_DUPLICATE_ITEM,
    00132             ERR_ITEM_NOT_FOUND,
    00133             ERR_FILE_NOT_FOUND,
    00134             ERR_INTERNAL_ERROR,
    00135             ERR_RT_ASSERTION_FAILED
    00136         };
    00137
    00140         Exception( int number, const String& description, const String& source );
    00141
    00144         Exception( int number, const String& description, const String& source, char* file, long line );
    00145
    00148         Exception(const Exception& rhs);
    00149
    00152         void operator = (const Exception& rhs);
    00153
    00164         String getFullDescription(void) const;
    00165
    00168         int getNumber(void) const throw();
    00169
    00172         String getFile() {return file; }
    00173
    00176         long getLine() {return line; }
    00177
    00178
    00181         static Exception* getLastException(void) throw();
    00182
    00185         static void _pushFunction( const String& strFuncName ) throw();
    00188         static void _popFunction() throw();
    00189
    00190
    00191     };
    00192
    00194     class _OgreExport AutomaticGuardUnguard {
    00195     public:
    00196         AutomaticGuardUnguard(const String& funcName) throw()
    00197         {
    00198             Exception::_pushFunction(funcName);
    00199         }
    00200         ~AutomaticGuardUnguard() throw()
    00201         {
    00202             Exception::_popFunction();
    00203         }
    00204     };
    00205
    00206 } // Namespace Ogre
    00207 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:24 2004