Main Page Modules Class Hierarchy Compound List File List Compound Members

# cexception.h

    00001 //==========================================================================
    00002 //   CEXCEPTION.H - header for
    00003 //                             OMNeT++
    00004 //            Discrete System Simulation in C++
    00005 //
    00006 //
    00007 //  Exception class
    00008 //
    00009 //==========================================================================
    00010
    00011 /*--------------------------------------------------------------*
    00012   Copyright (C) 1992-2003 Andras Varga
    00013
    00014   This file is distributed WITHOUT ANY WARRANTY. See the file
    00015   `license' for details on this and other legal matters.
    00016 *--------------------------------------------------------------*/
    00017
    00018 #ifndef __CEXCEPTION_H
    00019 #define __CEXCEPTION_H
    00020
    00021 #include <stdarg.h>  // for va_list
    00022 #include "defs.h"
    00023 #include "util.h"
    00024
    00025 class cObject;
    00026 class cModule;
    00027
    00031 class SIM_API cException
    00032 {
    00033   protected:
    00034     int errorcode;
    00035     opp_string msg;
    00036     opp_string modulefullpath;
    00037     int moduleid;
    00038
    00044     void init(const cObject *obj, int errc, const char *fmt, va_list va);
    00045
    00046     // helper for init()
    00047     void storeCtx();
    00048
    00049   public:
    00055     cException();
    00056
    00062     cException(int errcode,...);
    00063
    00067     cException(const char *msg,...);
    00068
    00076     cException(const cObject *where, int errcode,...);
    00077
    00083     cException(const cObject *where, const char *msg,...);
    00085
    00088
    00092     int errorCode() {return errorcode;}
    00093
    00097     const char *message() {return msg;}
    00098
    00103     const char *moduleFullPath() {return modulefullpath;}
    00104
    00111     int moduleID() {return moduleid;}
    00112
    00113 //    /**
    00114 //     * Tell if this exception signalled an error or a normal termination.
    00115 //     */
    00116 //    bool isNormalTermination() const;
    00118 };
    00119
    00128 class SIM_API cTerminationException : public cException
    00129 {
    00130   public:
    00136     cTerminationException(int errcode,...);
    00137
    00141     cTerminationException(const char *msg,...);
    00142 };
    00143
    00151 class SIM_API cEndModuleException : public cException
    00152 {
    00153   private:
    00154     bool del; // if true, this module should be deleted
    00155
    00156   public:
    00160     cEndModuleException(bool moduleToBeDeleted=false) {del = moduleToBeDeleted;}
    00161
    00165     bool moduleToBeDeleted() {return del;}
    00166 };
    00167
    00168 #endif