D:/WorkDir/SugoiProjects/SugoiTools/include/SugoiTools/exceptions.h

00001 //==========================================================
00002 // Exception.h
00003 //
00004 // Exceptions définies par le moteur
00005 //
00006 //==========================================================
00007 #ifndef EXCEPTION_H
00008 #define EXCEPTION_H
00009 
00010 //==========================================================
00011 // En-têtes
00012 //==========================================================
00013 #include "SugoiTools\config.h"
00014 #include <exception>
00015 
00016 namespace SGE{
00017 
00018 //==========================================================
00019 // Classe de base pour les exceptions
00020 //==========================================================
00021 class _SG_TLS_EXPORT CException : public std::exception
00022 {
00023 public :
00024 
00025     //----------------------------------------------------------
00026     // Constructeur
00027     //----------------------------------------------------------
00028     CException(const std::string& Message = "");
00029 
00030     //----------------------------------------------------------
00031     // Destructeur
00032     //----------------------------------------------------------
00033     virtual ~CException();
00034 
00035     //----------------------------------------------------------
00036     // Renvoie le message associé à l'exception
00037     //----------------------------------------------------------
00038     virtual const char* what() const;
00039 
00040           std::string GetLastErrorMsg();
00041 
00042 protected :
00043 
00044     //----------------------------------------------------------
00045     // Données membres
00046     //----------------------------------------------------------
00047     std::string m_Message; // Message associé à l'exception
00048 };
00049 
00050 //==========================================================
00051 // Exception lancée si une condition n'est pas vérifiée
00052 //==========================================================
00053 struct _SG_TLS_EXPORT CAssertException : public CException
00054 {
00055     CAssertException(const std::string& File, int Line, const std::string& Message);
00056 };
00057 
00058 
00059 
00060 //==========================================================
00061 // Anomalie d'allocation mémoire
00062 //==========================================================
00063 struct _SG_TLS_EXPORT CBadDelete : public CException
00064 {
00065     CBadDelete(const std::string& File, int Line, const void* Ptr, bool NewArray);
00066 };
00067 
00068 
00069 //==========================================================
00070 // Exception lancée lors d'erreur de chargement de fichiers
00071 //==========================================================
00072 struct _SG_TLS_EXPORT CLoadingFailed : public CException
00073 {
00074     CLoadingFailed(const std::string& File, int Line, const std::string& FileName, const std::string& Message);
00075 };
00076 
00077 //==========================================================
00078 // Exception lancée lors de saturations de mémoire
00079 //==========================================================
00080 struct _SG_TLS_EXPORT COutOfMemory : public CException
00081 {
00082     COutOfMemory(const std::string& File, int Line, const std::string& Message);
00083 };
00084 
00085 };//namespace
00086 
00087 namespace SGE{
00088 
00089 _SG_TLS_EXPORT inline void DoNothing(bool) {}
00090 
00091 #if 1//def _DEBUG, ???restore it later....
00092 #   define SG_Assert(condition, msg)                                            if (!(condition)) throw SGE::CAssertException     (__FILE__, __LINE__, #msg  "\n" #condition)
00093 #   define SG_AssertFile(condition, filename, msg)                    if (!(condition)) throw SGE::CLoadingFailed                 (__FILE__, __LINE__, filename, msg "\n" #condition )
00094 #   define SG_AssertMemory(condition, msg)                                      if (!(condition)) throw SGE::COutOfMemory                   (__FILE__, __LINE__, #msg "\n" #condition )
00095 #   define SG_AssertAlloc(condition, msg, ptr, _ARRAY_)     if (!(condition)) throw SGE::CBadDelete                     (__FILE__, __LINE__, ptr, _ARRAY_)
00096 #else
00097 #   define SG_Assert(condition, msg)                                                      SGE::DoNothing(!(condition))
00098 #   define SG_AssertFile(condition, filename, msg)                    SGE::DoNothing(!(condition))
00099 #         define SG_AssertMemory(condition, msg)                                SGE::DoNothing(!(condition))
00100 #   define SG_AssertAlloc(condition, msg, ptr, _ARRAY_)     SGE::DoNothing(!(condition))
00101 #endif
00102 
00103 };//namespace SGE
00104 
00105 #endif // EXCEPTION_H

Generated on Mon Mar 19 23:15:11 2007 for SugoiTools by  doxygen 1.4.6-NO