Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

/home/pauldt/projects/IDEA/IDEA-ALL/IDEA-DEV/Core/Utilities/Includes/Debugging.hh

Go to the documentation of this file.
00001 // -*- Mode: c++ -*-
00002 //     File: $Source: /home/cvs/ISG-Repository/IDEA-DEV/Core/Utilities/Includes/Debugging.hh,v $
00003 //      Tag: $Name: DR_01_11_06 $
00004 //      CVS: $Id: Debugging.hh,v 1.3 2005/12/30 22:06:24 rijsman Exp $
00005 //     Info: $CVSROOT/IDEA-DEV/COPYRIGHT
00006 
00007 #ifndef DEBUGGING_TOOLS_HEADER_
00008 #define DEBUGGING_TOOLS_HEADER_
00009 
00010 #include <string>
00011 #include <iostream>
00012 #include <sstream>
00013 
00019 namespace IDEA
00020 {
00025   class Error
00026   {
00027   public:
00031     Error(const std::string& message, 
00032           const std::string& file, 
00033            int line );
00037     Error(const std::string& condition, 
00038           const std::string& msg,
00039           const std::string& file, 
00040           int line);
00041 
00045     ~Error();
00049     inline static void doThrowException()
00050     {
00051       s_Throw = true;
00052     }
00056     inline static void doNotThrowException()
00057     {
00058       s_Throw = false;
00059     }
00063     inline static bool throwEnabled() 
00064     {
00065       return s_Throw;
00066     }
00070     inline static void doDisplayErrors()
00071     {
00072       s_DisplayErrors = true;
00073     }
00077     inline static void doNotDisplayErrors()
00078     {
00079       s_DisplayErrors = false;
00080     }
00084     inline bool displayErrorsEnabled()
00085     {
00086       return s_DisplayErrors;
00087     }
00091    void print( std::ostream& os ) const;
00095     void display();
00099     void raise();
00100   private:
00101     std::string m_Condition; 
00102     std::string m_Message; 
00103     std::string m_File;
00104     int m_Line;
00105     static bool s_Throw;
00106     static bool s_DisplayErrors;
00107   };
00108 
00112 #define ERROR_MSG( msg ) { \
00113  std::stringstream sstr; \
00114  sstr << msg; \
00115  Error( sstr.str(), __FILE__, __LINE__).raise(); \
00116 }
00117 
00118 #ifdef ASSERT_ON
00119 
00120 #define ASSERT( expression )  { \
00121  if( !( expression ) ) \
00122     Error(#expression,"", __FILE__, __LINE__).raise(); \
00123 }
00124  
00125 #define ASSERT_MSG( expression, msg )  { \
00126  if( !( expression ) ) { \
00127    std::stringstream sstr; \
00128    sstr << msg; \
00129    Error(#expression, sstr.str(), __FILE__, __LINE__).raise(); } \
00130 }
00131 
00132 #else
00133 
00144 #define ASSERT( expression ) 
00145 
00156 #define ASSERT_MSG( expression, number ) 
00157 
00158 #endif  //ASSERT_ON
00159 
00160     /*
00161       }@
00162     */
00163 
00164 }
00165 
00166 #endif //DEBUGGING_TOOLS_HEADER_

Contact information
© IDEA
Generated on Fri Feb 3 17:09:41 2006 for IDEA.