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

LOW_exception.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           LOW_exception.h  -  description
00003                              -------------------
00004     begin                : Sat Jul 6 2002
00005     copyright            : (C) 2002 by Harald Roelle, Helmut Reiser
00006     email                : roelle@informatik.uni-muenchen.de, reiser@informatik.uni-muenchen.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef LOW_EXCEPTION_H
00019 #define LOW_EXCEPTION_H
00020 
00021   
00022 #include <string>
00023 
00024   
00025 
00026 /** Macro for easy subclassing of LOW_exception.
00027  */
00028 #define class_DERIVE_FROM_EXCEPTION(DERIVED,SUPER) \
00029   class DERIVED : public SUPER { \
00030     public: DERIVED( const std::string inMsg, const std::string inFile, const int inLine) : SUPER( inMsg, inFile, inLine) {};  \
00031             DERIVED( const int inErrNum, const std::string inMsg, const std::string inFile, const int inLine) : SUPER( inErrNum, inMsg, inFile, inLine) {}; \
00032   }
00033 
00034 
00035             
00036 /** Base class for all exception of this library.
00037 
00038     @author Harald Roelle, Helmut Reiser
00039  */
00040 class LOW_exception {
00041 
00042 //=======================================================================================
00043 public: 
00044 
00045   //=====================================================================================
00046   //
00047   // attributes
00048   //
00049   
00050   const int     errNum;   /**< OS error number. */
00051   const string  message;  /**< Descriptive message. */
00052   const string  file;     /**< File from which exception was thrown. */
00053   const int     line;     /**< Line number where exception was thrown. */
00054   
00055     
00056   //=====================================================================================
00057   //
00058   // constructors
00059   //
00060 
00061   /** Default constructor.
00062    */  
00063   LOW_exception();
00064 
00065   /** Constructor.
00066       @param  inMsg   Message describing the exception.
00067       @param  inFile  File from which exception is thrown.
00068       @param  inLine  Line number where exception is thrown.
00069    */
00070   LOW_exception( const std::string inMsg, const std::string inFile, const int inLine);
00071 
00072   /** Constructor for OS errors.
00073 
00074       The textual OS description (perror) is added automatically when exception is logged.
00075   
00076       @param  inErrNum  OS error number.
00077       @param  inMsg     Message describing the exception.
00078       @param  inFile    File from which exception is thrown.
00079       @param  inLine    Line number where exception is thrown.
00080    */
00081   LOW_exception( const int inErrNum, const std::string inMsg, const std::string inFile, const int inLine);
00082   
00083   /** Destructor.
00084    */
00085   ~LOW_exception();
00086 
00087   
00088   //=====================================================================================
00089   //
00090   // static methods
00091   //
00092 
00093   /** Set wether exceptions should be logged automatically when created.
00094       @param  inLogOnCreation   Wether exceptions should be logged automatically.
00095    */
00096   static void setLogOnCreation( const bool inLogOnCreation);
00097 
00098   /** Get wether exceptions are logged automatically when created.
00099       @return   Wether exceptions are logged automatically.
00100    */
00101   static bool getLogOnCreation();
00102   
00103   
00104   //=====================================================================================
00105   //
00106   // methods
00107   //
00108 
00109   /** Log the exception via LOW_helper_msglog::printError()
00110       @param  inPrefix  Prefix to prepend to the log message.
00111    */
00112   void logException( const std::string inPrefix = "");
00113       
00114 
00115 //=======================================================================================
00116 protected:
00117 
00118   //=====================================================================================
00119   //
00120   // static attributes
00121   //
00122 
00123   /** Inicates wether exception should be logged automatically when the are created. */
00124   static bool logOnCreation;
00125   
00126 };
00127 
00128 #endif

Generated on Sun Jan 12 21:07:43 2003 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001