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

Exceptions.h

00001 /*
00002  * Copyright 2003 Michael A. Marsh, Cornell University. All rights reserved.
00003  * This software is released under the modified BSD license.
00004  * See the file LICENSE in the top-level directory for details.
00005  */
00006 //
00007 // $Id: Exceptions.h,v 1.3 2004/05/19 15:56:23 mmarsh Exp $
00008 //
00009 // $Log: Exceptions.h,v $
00010 // Revision 1.3  2004/05/19 15:56:23  mmarsh
00011 // Added copyright and license statements.
00012 //
00013 // Revision 1.2  2003/11/04 22:31:45  mmarsh
00014 // *** empty log message ***
00015 //
00016 //
00017 
00018 #ifndef __CODEX_APSS_EXCEPTIONS_H__
00019 #define __CODEX_APSS_EXCEPTIONS_H__
00020 
00021 #include <string>
00022 
00023 #include "CODEX_Exceptions/ExceptionBase.h"
00024 #include "Types.h"
00025 #include "Message.h"
00026 
00027 namespace CODEX_APSS
00028 {
00032    class ExceptionBase : public CODEX_Exceptions::ExceptionBase
00033    {
00034       public :
00040          ExceptionBase( const string& fname, int line ) :
00041             CODEX_Exceptions::ExceptionBase( fname, line )
00042          {}
00043 
00045          virtual ~ExceptionBase() {}
00046 
00050          void report() const;
00051 
00052       protected :
00057          virtual void derivedMsg() const = 0;
00058 
00059    };
00060 
00062    class BadSecretNumberException : public ExceptionBase
00063    {
00064       public :
00066          BadSecretNumberException( const string& fname, int line ):
00067             ExceptionBase( fname, line )
00068          {}
00069 
00071          virtual ~BadSecretNumberException() {}
00072 
00073       protected :
00074          void derivedMsg() const;
00075    };
00076 
00078    class MissingRangeException : public ExceptionBase
00079    {
00080       public :
00082          MissingRangeException( const string& fname, int line ):
00083             ExceptionBase( fname, line )
00084          {}
00085 
00087          virtual ~MissingRangeException() {}
00088 
00089       protected :
00090          void derivedMsg() const;
00091    };
00092 
00094    class ConflictExceptionBase : public ExceptionBase
00095    {
00096       public :
00098          ConflictExceptionBase( const string& fname, int line, int offender ) :
00099             ExceptionBase( fname, line ),
00100             m_offender( offender )
00101          {}
00102 
00104          ~ConflictExceptionBase() {}
00105 
00107          int offender() const { return m_offender; }
00108 
00109       protected :
00110          void derivedMsg() const;
00111 
00116          virtual void errMsg() const = 0;
00117 
00118       private :
00119          int  m_offender;
00120    };
00121 
00123    class InitMsgConflictException : public ConflictExceptionBase
00124    {
00125       public :
00127          InitMsgConflictException( const string& fname,
00128                                    int line,
00129                                    int offender,
00130                                    const LabelType& newLabel,
00131                                    const LabelType& oldLabel ) :
00132             ConflictExceptionBase( fname, line, offender ),
00133             m_newLabel( newLabel ),
00134             m_oldLabel( oldLabel )
00135          {}
00136 
00138          ~InitMsgConflictException() {}
00139 
00141          const LabelType& newLabel() const { return m_newLabel; }
00142 
00144          const LabelType& oldLabel() const { return m_oldLabel; }
00145 
00146       protected :
00147          void errMsg() const;
00148 
00149       private :
00150          LabelType  m_newLabel;
00151          LabelType  m_oldLabel;
00152    };
00153 
00155    class EstablishMsgConflictException : public ConflictExceptionBase
00156    {
00157       public :
00159          EstablishMsgConflictException(
00160             const string& fname,
00161             int line,
00162             int offender,
00163             const SublabelType& newSublabel,
00164             const SublabelType& oldSublabel ) :
00165             ConflictExceptionBase( fname, line, offender ),
00166             m_newSublabel( newSublabel ),
00167             m_oldSublabel( oldSublabel )
00168          {}
00169 
00171          ~EstablishMsgConflictException() {}
00172 
00174          const SublabelType& newSublabel() const
00175          {
00176             return m_newSublabel;
00177          }
00178 
00180          const SublabelType& oldSublabel() const
00181          {
00182             return m_oldSublabel;
00183          }
00184 
00185       protected :
00186          void errMsg() const;
00187 
00188       private :
00189          SublabelType  m_newSublabel;
00190          SublabelType  m_oldSublabel;
00191    };
00192 
00194    class ComputeMsgConflictException : public ConflictExceptionBase
00195    {
00196       public :
00198          ComputeMsgConflictException( const string& fname,
00199                                       int line,
00200                                       int offender,
00201                                       const ComputeMsg& newMsg,
00202                                       const ComputeMsg& oldMsg ) :
00203             ConflictExceptionBase( fname, line, offender ),
00204             m_newMsg( newMsg ),
00205             m_oldMsg( oldMsg )
00206          {}
00207 
00209          ~ComputeMsgConflictException() {}
00210 
00212          const ComputeMsg& newMsg() const { return m_newMsg; }
00213 
00215          const ComputeMsg& oldMsg() const { return m_oldMsg; }
00216 
00217       protected :
00218          void errMsg() const;
00219 
00220       private :
00221          ComputeMsg  m_newMsg;
00222          ComputeMsg  m_oldMsg;
00223    };
00224 
00225 }
00226 
00227 #endif /* __CODEX_APSS_EXCEPTIONS_H__ */

Generated on Wed Jun 2 16:32:55 2004 for COrnell Data EXchange (CODEX) by doxygen1.2.18