00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
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       
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       
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       
00169       
00170       
00175       void write (basic_ostream<char_type, traits_type>& rtOUTPUT_OSTREAM) const
00176       {
00177         rtOUTPUT_OSTREAM << what() << std::endl;
00178       }
00179 
00180   };  
00181 
00182 }  
00183 
00184 
00185 #endif  // not _MPCL_EXCEPTION__