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

exceptions.hh

00001 /*
00002 *  Name:      exceptions.hh
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   INVARIANT exceptions
00005 *  Date:      $Date: 2003/10/06 12:45:11 $
00006 *  Revision:  $Revision: 1.2 $
00007 *
00008 *  Copyright (C) 1994-2002  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_INVARIANT_EXCEPTIONS__
00027 #define _MPCL_INVARIANT_EXCEPTIONS__
00028 
00029 #include <iostream>
00030 #include "../error_exception.hh"
00031 #include "../exception.hh"
00032 
00033 
00035 namespace mpcl
00036 {
00037 
00039   namespace invariant
00040   {
00041 
00042     using std::basic_ostream;
00043 
00045     class TException : public virtual mpcl::TException {};
00046 
00048     class TViolationException         :
00049       public virtual mpcl::TException ,
00050       public         TErrorException  ,
00051       public         TException
00052     {
00053 
00054       private:
00055 
00057         static const char*   _pkcSynopsis;
00058 
00060         const int   iViolatedConformanceLevel;
00061 
00062 
00063       protected:
00064 
00065         //
00066         //  S E L E C T O R S
00067         //
00068 
00069         void write (basic_ostream<char>& rtTARGET_OSTREAM) const
00070         {
00071           if ( !fileName().empty() )
00072           {
00073             rtTARGET_OSTREAM << fileName() << ":" << lineNumber() << ":";
00074           }
00075           rtTARGET_OSTREAM << generalDescription() << iViolatedConformanceLevel << "; ";
00076           if ( !specificDescription().empty() )
00077           {
00078             rtTARGET_OSTREAM << specificDescription();
00079           }
00080           rtTARGET_OSTREAM << std::endl;
00081         }
00082 
00083 
00084       public:
00085 
00086         //
00087         //  C O N S T R U C T O R S
00088         //
00089         
00098         TViolationException ( int           iVIOLATED_CONFORMANCE_LEVEL ,
00099                               const string& rkyRATIONALE  = string()    ,
00100                               const string& rkyFILE_NAME  = string()    ,
00101                               const int     kiLINE_NUMBER = 0           )                     :
00102           mpcl::TException          (_pkcSynopsis, rkyRATIONALE, rkyFILE_NAME, kiLINE_NUMBER) ,
00103           TErrorException           ()                                                        ,
00104           TException                ()                                                        ,
00105           iViolatedConformanceLevel (iVIOLATED_CONFORMANCE_LEVEL)                             {}
00106 
00107 
00108       public:
00109 
00110         //
00111         //  S E L E C T O R S
00112         //
00113 
00114         int violatedConformanceLevel (void) const
00115         {
00116           return iViolatedConformanceLevel;
00117         }
00118 
00119     };  // class TViolationException
00120     
00121   }  // namespace invariant
00122 
00123 }  // namespace mpcl
00124 
00125 
00126 #endif  // not _MPCL_INVARIANT_EXCEPTIONS__

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