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

exception.hh

00001 /*
00002 *  Name:      exception.hh
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   Exception class
00005 *  Date:      $Date: 2003/10/06 12:45:11 $
00006 *  Revision:  $Revision: 1.1 $
00007 *
00008 *  Copyright (C) 1994-2003  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  This program is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00026 #ifndef _MPCL_EXCEPTION__
00027 #define _MPCL_EXCEPTION__
00028 
00029 #include <string>
00030 #include "io/output_streamable.hh"
00031 
00032 
00034 namespace mpcl
00035 {
00036 
00037   using io::IOutputStreamable;
00038   using std::basic_ostream;
00039   using std::string;
00040 
00050   class TException: public IOutputStreamable<>
00051   {
00052 
00053     protected:
00054 
00056       string   ySynopsis;
00057 
00059       string   yRationale;
00060 
00062       string   yFileName;
00063 
00065       int   iLineNumber;
00066 
00067 
00068     public:
00069 
00070       //
00071       //  C O N S T R U C T O R S
00072       //
00073  
00078       TException (void)         :
00079         IOutputStreamable<> ()  ,
00080         ySynopsis           ()  ,
00081         yRationale          ()  ,
00082         yFileName           ()  ,
00083         iLineNumber         (0) {}
00084 
00093       TException ( const string& rkySYNOPSYS              ,
00094                    const string& rkyRATIONALE  = string() ,
00095                    const string& rkyFILE_NAME  = string() ,
00096                    const int     kiLINE_NUMBER = 0        ) :
00097         IOutputStreamable<> ()                              ,
00098         ySynopsis           (rkySYNOPSYS)                   ,
00099         yRationale          (rkyRATIONALE)                  ,
00100         yFileName           (rkyFILE_NAME)                  ,
00101         iLineNumber         (kiLINE_NUMBER)                 {}
00102 
00108       TException (const TException& rktSOURCE_EXCEPTION) :
00109         IOutputStreamable<> ()                                ,
00110         ySynopsis           (rktSOURCE_EXCEPTION.ySynopsis)   ,
00111         yRationale          (rktSOURCE_EXCEPTION.yRationale)  ,
00112         yFileName           (rktSOURCE_EXCEPTION.yFileName)   ,
00113         iLineNumber         (rktSOURCE_EXCEPTION.iLineNumber) {}
00114 
00115 
00116     public:
00117 
00118       //
00119       //  S E L E C T O R S
00120       //
00121 
00126       const string& generalDescription (void) const throw()
00127       {
00128         return ySynopsis;
00129       }
00130 
00135       const string& specificDescription (void) const throw()
00136       {
00137         return yRationale;
00138       }
00139 
00144       const string& fileName (void) const throw()
00145       {
00146         return yFileName;
00147       }
00148 
00153       int lineNumber (void) const throw()
00154       {
00155         return iLineNumber;
00156       }
00157 
00162       virtual const string what (void) const;
00163 
00164 
00165     protected:
00166 
00167       //
00168       //  S E L E C T O R S
00169       //
00170       
00175       void write (basic_ostream<char_type, traits_type>& rtOUTPUT_OSTREAM) const
00176       {
00177         rtOUTPUT_OSTREAM << what() << std::endl;
00178       }
00179 
00180   };  // class TException
00181 
00182 }  // namespace mpcl
00183 
00184 
00185 #endif  // not _MPCL_EXCEPTION__

Generated on Mon Oct 13 02:35:23 2003 for MPCL by doxygen1.2.18