KeosException.h

Go to the documentation of this file.
00001 /*
00002  * This source file is part of KEOS (Free 3D Engine)
00003  * For the latest info, see http://www.keosengine.org/
00004  * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
00005  *
00006  * This program is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU Lesser General Public License as published by the Free Software
00008  * Foundation; either version 2 of the License, or (at your option) any later
00009  * version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00018  * http://www.gnu.org/copyleft/lesser.txt.
00019  *
00020  */
00021 
00022 #ifndef KEOS_EXCEPTION_H
00023 #define KEOS_EXCEPTION_H
00024 
00025 #include "KeosPrerequisites.h"
00026 
00027 #define BADDELETE_EXCEPT(p, f, l, a)    {Keos::CBadDelete except((p), (f), (l), (a)); LOG_TMP}
00028 #define LOADINGFAILED_EXCEPT(f, m, s)   {Keos::CLoadingFailed except((f), (m), (s)); LOG_TMP}
00029 #define DYNLIB_EXCEPT(f, m, s)          {Keos::CDynLibError except((f), (m), (s)); LOG_TMP}
00030 #define OUTOFMEMORY_EXCEPT( m, s)       {Keos::COutOfMemory except((m), (s)); LOG_TMP}
00031 #define UNSUPPORTED_EXCEPT( m, s)       {Keos::CUnsupported except((m), (s)); LOG_TMP}
00032 #define BADCONVERSION_EXCEPT( m, s)     {Keos::CBadConversion except((m), (s)); LOG_TMP}
00033 
00034 #define LOG_TMP except.SetFileLine(__FILE__, __LINE__); Keos::ILogger::Log("%s",except.what_short()); throw except;
00035 
00036 namespace Keos
00037 {
00038   //-----------------------------------------------------------------------
00042   class KEOS_EXPORT CException : public std::exception
00043   {
00044   public :
00045 
00049     CException(const String& strMessage = "");
00050 
00054     virtual ~CException();
00055 
00059     virtual const char* what() const;
00060 
00064     const char* what_short() const;
00065 
00068     static CException* GetLastException(void) throw();
00069 
00072     void SetFileLine(String strFile, int nLine);
00073 
00074   protected :
00075 
00077     String m_strMessage;
00079     String m_strShortMessage;
00081     static CException* ms_pLast;
00082   };
00083 
00084 
00085   //-----------------------------------------------------------------------
00089   struct KEOS_EXPORT CAssertException : public CException
00090   {
00096     CAssertException(const String& strFile, int nLine, const String& strMessage);
00097   };
00098 
00099   // Define Assert macro
00100   // allowing of generated an exception if the condition is not verified
00101 #ifdef KEOS_DEBUG_MODE
00102 #   define Assert(condition) if (!(condition)) throw CAssertException(__FILE__, __LINE__, "Unsatisfied condition\n\n" #condition)
00103 #else
00104   // In no DEBUG_MODE Assert do nothing
00105   inline void DoNothing(bool)
00106   {}
00107 #   define Assert(condition) DoNothing(!(condition))
00108 #endif
00109 
00110 
00111   //-----------------------------------------------------------------------
00115   struct KEOS_EXPORT CBadDelete : public CException
00116   {
00123     CBadDelete(const void* pPtr, const String& strFile, int nLine, bool bNewArray);
00124   };
00125 
00126 
00127   //-----------------------------------------------------------------------
00131   struct KEOS_EXPORT CLoadingFailed : public CException
00132   {
00138     CLoadingFailed(const String& strFile, const String& strMessage, const String& strSource);
00139   };
00140 
00141   //-----------------------------------------------------------------------
00145   struct KEOS_EXPORT CDynLibError : public CException
00146   {
00152     CDynLibError(const String& strFile, const String& strMessage, const String& strSource);
00153   };
00154 
00155 
00156   //-----------------------------------------------------------------------
00160   struct KEOS_EXPORT COutOfMemory : public CException
00161   {
00166     COutOfMemory(const String& strMessage, const String& strSource);
00167   };
00168 
00169   //-----------------------------------------------------------------------
00173   struct KEOS_EXPORT CUnsupported : public CException
00174   {
00179     CUnsupported(const String& strFeature, const String& strSource);
00180   };
00181 
00182   //-----------------------------------------------------------------------
00186   struct KEOS_EXPORT CBadConversion : public CException
00187   {
00192     CBadConversion(const String& strError, const String& strSource);
00193   };
00194 
00195 } // namespace Keos
00196 
00197 #endif // KEOS_EXCEPTION_H

Generated on Fri Mar 9 14:29:02 2007 for Keos by  doxygen 1.5.1-p1