

                              TOOPS
            Tool for Object Oriented Protocol Simulation
              The Class Library from the User's View



//-----------------------------------------------------------------------
// ToopsSimulation (header --> toops.h, source code --> tsim.cpp/.C)
// =================================================================
//
class ToopsSimulation
{
public:
 
// Why stopped the simulation ?
// timeStop: timeOut was reached
// regularStop: no events left, i.e all ToopsProcesses have terminated
// or are untimed waiting
// userStop: the user program called stopSimulation()
// timerOverFlowStop: (shouldn't really happen) TOOPS stopped the
// simulation, because the time exceeded SIMTIME_MAX
// (declared in portable.h)
// errorStop: a ToopsError of severity ToopsError::error occured or the /  
// user program called stopWithError()
// _next: internally used, is never returned by ToopsSimulation::start()

 enum stopReason { timeStop=1,       regularStop, userStop,
                   timeOverFlowStop, errorStop,   _next     };


 // The actual simulation time (if state() is `running'); always 0, if
 // `clear' or `notStarted', the stop time, if state() is `stopped'

 static simtime time(void) { return s_time; }


 // Start the simulation
 // stop at <end> or run until one of the other stop reasons appears

 static stopReason start(simtime end = 0);


// stop immediatly, return userStop

 static void stopSimulation (void); 


// stop immediatly, return errorStop

 static void stopWithError  (void); 
 

// Get the time the simulation is about to end.

 static simtime getTimeOut(void)


 




 // For graphical representation (and debugging): set a function, that
 // is called each time the time advances. The function must take 2
 // parameters: <now> holds the actual, <next> the next point of time.
 // Defaults to 0. Reset to 0, if function not needed.

 typedef void (*PVF2S)(simtime now, simtime next);
 static PVF2S setTimeAdvanceCallBack(PVF2S);    

// returns old value to control debug output

 enum dbgInfo { cstr=0, onStart=1, onGetNextEvent=2, dstr=4 };
 virtual void write (int depth = 0, int mode = 0) const;


protected:

// The next three function are called for all ToopsProcessors, ToopsChan-
// mels,
// ToopsTimers, ToopsSockets and ToopsProcesses at a defined point of time:

 // atStart() is called after ToopsSimulation::start(), but before any
 // any ToopsProcess starts(note: ToopsProcessor::atStart() is used inter-  
 // nally, if you want to add something, call TProcessor::atStart() in your
 // class' atStart() function, if you don't, the simulation will quit).
 // atStart() will not be called for objects set up while the simulation
 // is running.

 virtual void atStart(void) {}



 // atEnd() is called after the simulation stopped. It will not be called
 // for objects deleted while the simulation is running.

 virtual void atEnd(void) {}


 // atStateChange will be called every time, an object's state is modified.
 // note: the C++ definition allows the call of virtual functions in
 // constructors, but when virtual functions are called in a constructor,
 // the function invoked is the function defined for the constructor's
 // own class (or inherited from it's bases), but NEVER the function
 // of a derived class. So: atStateChange() never sees the status create,
 // that is defined for several classes of TOOPS (e.g. TTimer, TProcess,..)

 virtual void atStateChange(void) {}

};
//-----------------------------------------------------------------------
// ToopsProcessor (header --> procunit.h, source code -> procunit.cpp/.C)
// ======================================================================
//
class ToopsProcessor 
{
public:
 ToopsProcessor(const char *name, simtime timeForContextSwitch = 0);


 // ToopsProcessor's states are used internally to indicate whether a 
 // ToopsProcessor
 // must be activated. They do not represent real states.

 enum processorState { active, inactive };


 // Returns ToopsProcessor's time for a context change.

 simtime timeToContextSwitch(void) const { return p_timeToContextSwitch; }


 // Get a ToopsProcessor* by it's name. Returns 0, if not found.

 static ToopsProcessor* search(const char *n)

 
 // Get an array of all ToopsProcessors in the simulation. The array _must_
 // be deleted by the user. Determine the length of the array with
 // numProcessors().
 
 static ToopsProcessor** systemProcessors(void)


 // Returns the number of all ToopsProcesses on this ToopsProcessor.

 instance_counter processes(void)


 // Get an array with all ToopsProcesses on this ToopsProcessor. The array
 //_must_ be deleted by the user. Length of array obtainable via 
 //processes().

 ToopsProcess** myProcesses(void);


 protected:

 // explained in toops.h

 virtual void atEnd(void) {}


 // note: ToopsProcessor::atStart() is used internally, you may
 // use this function for your own purposes, but call
 // ToopsProcessor::atStart from your atStart() function. NEVER call
 // it from else where !!!!!!!!
 virtual void atStart(void);

 // note: since the ToopsProcessor's state are not real states, 
 // atStateChange()
 // is not called for a ToopsProcessor.


};
//-----------------------------------------------------------------------
// ToopsProcess (header --> tprocess.h, source code --> tprocess.cpp/.C)
// =====================================================================
//
class ToopsProcess
{
public:
 // ToopsProcess' basic states:
 // - ready: ToopsProcess wants to become running
 // - running: ToopsProcess is active (i.e. consuming time or the code (that
 // doesn't consume any simulation time) in behavior is active).
 // - waiting: ToopsProcess is waiting for something.
 // - terminated: ToopsProcess terminated or was terminated by another
 // ToopsProcess.
 // - create, destroy: used internally at construction and destruction
 // ( and to indicate destruction to to atStateChange())
 
 enum processState { ready   =0, running=1, waiting=2, terminated=3,
                     destroy =7 };
 processState status() const


 // Get the ToopsProcess' priority

 uint priority(void) const { return p_priority; }


 // Get the ToopsProcess' owner (a ToopsProcessor)

 ToopsProcessor *owner(void) const { return p_owner; }


 // Get a ToopsProcess* by it's name.

 inline static ToopsProcess* search(const char *n);


 // Get a list of all ToopsProcesses in the system. The list _must_ be
 // deleted by the user. Get the list's length via numProcesses();

 inline static ToopsProcess** systemProcesses(void);


 // Get the number of this ToopsProcess' ToopsTimers.

 instance_counter timers(void) const { return p_timers.len(); }

 
// Get a list of all ToopsTimers on this ToopsProcess. The list _must_ be
// deleted by the user. Length: timers().

 ToopsTimer** myTimers(void)





 // Get the number of this ToopsProcess' ToopsSockets.

 instance_counter sockets(void) const { return p_sockets.len(); }


 // Get a list of all ToopsSockets on this ToopsProcess. The list 
 //_must_be deleted by the user. Length: sockets().

 ToopsSocket** mySockets(void)


// suspend this or _another_ process on the same processor

 void suspend (callError* e=0);  


// resume _another_ process on the same prcessor

 void resume  (callError* e=0); 


// terminate this or _another_ process on the same processor

 void terminate(callError* e=0); 


protected:

 // create new processes

 ToopsProcess(ToopsProcessor *p, uint prio, const char *name);
 ToopsProcess(ToopsProcessor &p, uint prio, const char *name);


 // that's the user process

 virtual void behavior(void)=0;


 // specify the amount of time consumed by the actions of _YOUR_ tasks

 void consumeTime(simtime s);


 //  set this process waiting until time t
 // has passed. After this time the process
 // will be put in the list of runnable pro-
 // cesses and rescheduled ( at time()+t or
 // later, if there are ready processes
 // with higher priority)
 
void setWaiting(simtime t); 



 // The behaviour of the synchronize(...) function defines as follows:
 // - the function returns immediatly, if at least one of the specified
 // ToopsSockets has a ToopsMessage in it's queue.
 // - otherwise the ToopsProcess will wait until at least one ToopsMessage
 // arrives at one of the specified ToopsSockets
 // If no ToopsMessage is in the queue, the ToopsProcess (owner) will wait
 // until:
 // - a ToopsMessage arrives at one of the (specified) ToopsSockets (will
 // be retuned)
 // - a ToopsTimer wakes the ToopsProcess up (0 will be returned)


// synchronize on all ToopsSockets

 void synchronize();



 // synchronize on the specified ToopsSockets

 void synchronize(ToopsSocket *t1,   ToopsSocket *t2=0, ToopsSocket *t3=0,
                  ToopsSocket *t4=0, ToopsSocket *t5=0, ToopsSocket *t6=0);
 

 // synchronize on the ToopsSockets specified in the array. The last element
 // of the array _must_ be 0.

 void synchronize(ToopsSocket** TSarray);


 //inheriated from and explained in claas ToopsSimulation

 static simtime time(void)
 static void    stopSimulation(void); 
 static void    stopWithError(void); 
 static simtime getTimeOut(void)
 
 virtual void atStart(void) {}
 virtual void atEnd(void) {}
 virtual void atStateChange(void) {}

};
//----------------------------------------------------------------------
// ToopsChannel (header --> channel.h, source code -> channel.cpp/.C)
// ==================================================================
//
class ToopsChannel 
{

public:

 // states of a ToopsChannel
 // noConnection: 0 or 1 ToopsSockets connected, no communication possible
 // ready: 2 or more ToopsSockets connected, communication possible
 // destroy: at destruction.

 enum channelState { noConnection, ready, destroy};


 // get a ToopsChannel by it's name

 inline static ToopsChannel* search(const char* n);


 // get an array of all ToopsChannels in the system. The array _must_ be
 // deleted after use. Size: numChannels().

 inline static ToopsChannel** systemChannels(void);


 // get the number of connected ToopsSockets

 instance_counter sockets(void) const { return c_connected.len(); }


 // get an array of all connected ToopsSockets. The array _must_ be deleted
 // after use. Size: sockets().

 inline ToopsSocket** mySockets(void);


 ToopsChannel(const char *name, responsibility r=user);
 

//inheriated from and explained in claas ToopsSimulation

 ToopsObject      :: DBGout;
 ToopsNamedObject :: name;
 ToopsSimulation  :: stopReason;
 ToopsSimulation  :: time;
 ToopsSimulation  :: objects;
 ToopsSimulation  :: stopSimulation;
 ToopsSimulation  :: stopWithError;
 ToopsSimulation  :: getTimeOut;

 virtual void write(int depth=0, int mode=0 ) const;


protected:

 // This function is called before a ToopsMessage is sent. By implementing
 // this function in a derived class a variable delay time for the
 // ToopsChannel can be simulated.
 virtual simtime delay( ToopsMessage* msg, 
                        ToopsSocket* from,
                        ToopsSocket* to)


 // This function is called before a ToopsMessage is sent. By implementing
 // this function in a derived class a channel specific distortion
 // behaviour can be simulated. Return 1, if the ToopsMessage shall
 // not arrive at all.

 virtual int distort(ToopsMessage* msg, ToopsSocket* from, ToopsSocket* to)

 
 // explained in toops.h

 virtual void atStart(void) {}
 virtual void atEnd(void) {}
 virtual void atStateChange(void) {}

};


//-----------------------------------------------------------------------
// ToopsSocket (header --> socket.h, source code -> socket.cpp/.C)
// ===============================================================
//
class ToopsSocket
{
public:
 ToopsSocket(const char *name,ToopsProcess *owner,ToopsChannel *channel);
 ToopsSocket(const char *name,ToopsProcess *owner,ToopsChannel &channel);
 ToopsSocket(const char *name,ToopsProcess &owner,ToopsChannel *channel);
 ToopsSocket(const char *name,ToopsProcess &owner,ToopsChannel &channel);


 // states of a ToopsSocket
 // ready: ready for sending / receiving / synchronizing
 // inSync: synchronize or receive was called.
 // create, gotMessage, sending: ToopsSocket switches for a short time to
 // one of these states at construction, when getting a message and when
 // sending a message to inform atStateChange() (note: atStateChange()
 // never sees create, see toops.h). Immediatly after this, the state chan-
 // ges to ready again.
 // destroy: set in destructor.

 enum socketState { ready, inSync, gotMessage, sending, create, destroy };
 socketState status(void) const { return s_state; }


 // is there a message in the queue ?

 int hasMessage(void) const { return receivedMessages.len() != 0; }

 
// number of received messages

 instance_counter messages(void) const { return receivedMessages.len(); }


 // receive() returns the first ToopsMessage in the queue of received Toops-
 // Messages, if there is one.
 // If no ToopsMessage is in the queue, the ToopsProcess (owner) will wait
 // until:
 // - a ToopsMessage arrives at this ToopsSocket (will be returned) or
 // - a ToopsTimer wakes the ToopsProcess up (0 will be returned)
 // The ToopsMessage will be removed from the queue (like get() does).

 ToopsMessage* receive(void);


 // Like receive, but nothing will be returned and all ToopsMessages are
 // left in the queue.
 
 void synchronize(void);

 


// Send a ToopsMessage to all other connected ToopsSockets (connected via
// ToopsChanel). Optionally specify a delay time, that is added to the
// ToopsChannels delay (if there is one). The ToopsMessage is duplicated,
// so the sentToopsMesssage can be deleted or modified.
 
void send(ToopsMessage*, simtime delay=0);


 // Get the <num>th ToopsMessage* in the queue. The ToopsMessage will 
 // be removed from the queue. <num> starts with 0 for the first 
 // ToopsMessage.
 ToopsMessage *getMsg (instance_counter num=0)


 // Touch the <num>th ToopsMessage* in the queue. The ToopsMessage will
 // remain from the queue. <num> starts with 0 for the first ToopsMessage.

 ToopsMessage *touchMsg (instance_counter num=0)


 // Delete the <num>th ToopsMessage* in the queue.
 // <num> starts with 0 for the first ToopsMessage.

 void delMsg (instance_counter num=0)


 // Get the ToopsProcess the ToopsSocket belongs to.

 ToopsProcess* owner(void) const { return s_owner; }


 // Get the ToopsChannel the ToopsSocket is connected to.

 ToopsChannel* channel(void) const { return s_channel; }


 // Get a ToopsSocket by it's name.

 inline static ToopsSocket* search(const char *n);


 // Get an array of all ToopsSockets in the simulation. The array _must_ be
 // deleted by the user. Determine the size of the array with numSockets().

 inline static ToopsSocket** systemSockets(void);


 // used internally

 simtime nextTime(void) const







//inheriated from and explained in claas ToopsSimulation

 ToopsNamedObject::name;
 ToopsSimulation ::simstate;
 ToopsSimulation ::state;
 ToopsSimulation ::stopReason;
 ToopsSimulation ::time;
 ToopsSimulation ::stopSimulation;
 ToopsSimulation ::stopWithError;
 ToopsSimulation ::getTimeOut;
 ToopsSimulation ::numMessages;

 void virtual write(int depth=0, int mode=0) const;

protected:

 // explained in toops.h

 virtual void atStart(void) {}
 virtual void atEnd(void) {}
 virtual void atStateChange(void) {}

 instance_counter arrivingMessages(void)
 { return messagesToReceive.len(); }
};

//-----------------------------------------------------------------------
// ToopsTimer (header -->timer.h, source code -> timer.cpp/.C)
// ===========================================================
//
class ToopsTimer
{
public:
 // ToopsTimer's states:
 // - idle: ToopsTimer is stopped or not started
 // - active: ToopsTimer is started or restarted and will alert at alert-
 //   Time()
 // - expired: ToopsTimer has expired, owner() has been alerted. A Toops-
 //   Timer will
 // remain in this state until started again or isExpired() is called.
 // - destroy: used internally for removing from lists in destructor
 // - create: used internally

 enum timerState { idle, active, expired, destroy, create };
 timerState status(void) const


// Returns 1, if ToopsTimer expired and resets state to idle.

 int isExpired (void); 

 
// Create ToopsTimer named <name>, belonging to ToopsProcess <where> and
// having a default time until alert of <defPeriod>

 ToopsTimer(const char *name, ToopsProcess &where, simtime defPeriod = 0);
 ToopsTimer(const char *name, ToopsProcess *where, simtime defPeriod = 0);


 // Make a ToopsTimer alert at time() + <period> (if <period> > 0) or at
 // time() + defPeriod() (if <period> == 0).

 void start(simtime period=0);


 // ToopsTimer alerts at time() == absTime.

 void startAbs(simtime absTime);


 // Stop a ToopsTimer (status = idle), returns left time until alert.

 simtime stop(void);


// set the default period, return old value. Has no effect on an active
// ToopsTimer's expiry time !!

 simtime setDefault(simtime defPeriod); 



 // Get the ToopsTimer's owner.

 ToopsProcess *owner(void) const { return t_owner; }


 // When will the ToopsTimer alert (if active) respectively when did the
 //ToopsTimer
 // alert (if expired). Otherwise 0.
 
simtime alertTime(void) const { return t_alertTime; }


 // Returns the actual default time span.

 simtime defPeriod(void) const{ return t_defPeriod; }


 // Get a ToopsTimer* by a given name. Returns 0, if not found. Get an array
 // of all ToopsTimers. The array _must_ be deleted by the program.
 // The length of the array can be determined with 

 inline static ToopsTimer* search(const char *n);


 //inheriated from and explained in claas ToopsSimulation

 ToopsObject      ::DBGout;
 ToopsNamedObject ::name;
 ToopsSimulation  ::stopReason;
 ToopsSimulation  ::time;
 ToopsSimulation  ::stopSimulation;
 ToopsSimulation  ::stopWithError;
 ToopsSimulation  ::getTimeOut;

 virtual void write(int depth = 0, int mode = 0) const;

protected:
 // explained in toops.h
 virtual void atStart(void) {}
 virtual void atEnd(void) {}
 virtual void atStateChange(void) {}

}
//-----------------------------------------------------------------------
// ToopsMessage (header --> message.h, source code -> message.cpp)
// ===============================================================
//
// Each instance of a class derived from ToopsMessage _must_ be created
// on the heap (free store, call new). This is crucial for a correct
// ToopsMessage processing of TOOPS, because ToopsMessages will be 
// duplicated (see below) and deleted. You know maybe the effects of 
// deleting objects that have not been allocated with new.
//

class ToopsMessage
{
public:
    ToopsMessage();
    virtual ~ToopsMessage();

    // This function _must_ be implemented for each ToopsMessage derived 
    // class for processing ToopsMessages by TOOPS. It must return an exact
    // copy of a this ToopsMessage !!!!. 
    // Don't call ToopsMessage::duplicate() from your own function.

    virtual ToopsMessage* duplicate ();

    simtime receivedAt() const 

    virtual void write(int depth = 0, int mode = 0) const;
};

//----------------------------------------------------------------
// ToopsError (header --> error.h, source code -> error.cpp/.C)
// ============================================================
// (class is defined next page)
// An object of this error class is created for each error, warning,
// ...
// as a static member of class emitting the error.
// For use in your own application from TOOPS' classes create the
// appropriate
// ToopsError's as static members in your classes.
// To emit an error, a call to ToopsError::err() is required. Because an
// error
// object holds all basic informations about an error, in many cases
// no addi-
// tional information is needed for a exact description of the error
// (if more
// information has to be supplied, use err(char *xwho=0, char
// *xdesc1=0, ...)).
//
// The look of the error messages is defined as follows (2 examples):
// an error emitted with ToopsError::err()
// TOOPS fatal 1001 ToopsSimulation: start w/o ToopsProcessor defined
//                               |-> parameter desc in ToopsError(...)
//                  |-> paramter who in ToopsError(...)
//             |-> parameter errno in ToopsError(...)
//       |-> built automatically by interpreting severity s
// |-> automatically added
// an error emitted with ToopsError::err(P1", don't use search()")
// TOOPS warning xxxx ToopsProcessor P1": name is yet used don't use
// search()
//                                                      |-> par xdesc1 in err
//                                     |-> parameter desc in ToopsError(...)
//                                |-> parameter xwho in err
//                    |-> parameter who in ToopsError(...)
//               |-> parameter errno in ToopsError(...)
//       |-> built automatically by interpreting severity s
// |-> automatically added
//
// setSeverity allows a userprovided interpretation of all acessable
// error
// objects. It returns the old value.
// If no error handler exists, all output is sent to cerr.
// Default error handling:
// - fatal: immediate exit (always)
// - error: does not stop the program, but the simulation will be
//   stopped.
// - warning: the program continues normally.
// - ignore is a special case: nothing will be sent cerr or the use
//   defined
//   error handler. If some errors can be ignored for an application,
//   set
//   their severity to ignore. It is no good idea to do this with a
// fatal !!
// The userdefined error handler can be installed with setErrorHan/// ler.
// It's type should be ToopsError::ERRFUNC. (Arguments: int errornumber,
// ToopsError::severity, const char*}; the char* will be the whole error
// message,
// ATTENTION: if this string is to be buffered, copy it, because it
// will be
// deleted immediatly after the error handler's return).

//----------------------------------------------------------------
// All errors, warnings, ... created by TOOPS:
// - The error numbers are defined here to prevent problems.
// - Naming convention: TE_XXXXX_YYYYY
//                               |-> error type
//                         |-> the class or module where the error occured
//                      |-> short name for TOOPS ERROR
// - Many ToopsErrors (usually fatal errors) are declared as private, so
//   their
//   interpretation cannot be modified (labeled with [p] below).
// - The interpretation of the other ToopsErrors can be modified.
//
//  The definitions of the error numbers, each preceeded by a short
//  description:
//
// fatal [p], an attempt to allocate memory (e.g. for a new Tim
// Step, a
// ToopsProcess's context, a copy of a message, ..) failed.

#define TE_OUT_OF_MEMORY               2000


// fatal [p], ToopsSimulation::start() called, when the simulation is
// not ready
// to be started (i.e.: no TOOPS objects exist (clear), the sim is
// running
// yet  (running) or the sim is stopped, but at least one TOOPS object
// of
// the previous simulation exists still (stopped)). A simulation can 
// only
// be started, if ToopsSimulation::state() returns notStarted.

#define TE_TSIMULATION_CANNOTSTART     1000

// fatal [p], call to ToopsSimulation::start() w/o at least one ToopsProce
// sor created.
// #define TE_TSIMULATION_NOPROCESSOR     1001
// fatal [p], call to ToopsSimulation::start() w/o at least one 
// ToopsProcess created.

#define TE_TSIMULATION_NOPROCESSES     1002

// error, a ToopsNamedObject's name is empty or not unique (if search()
// is not used
// and the ToopsNamedObject's name is not needed for debugging and di
// playing,
// turn this error off by ToopsNamedObject::eName.setSeverity
// ToopsError::ignore) ).
// Note: ToopsProcessor, ToopsChannel, ... have each their own name space.
// If severity is ignore, no test for the name takes place.
#define TE_TNO_NAME                    1100

// warning, no ToopsProcess exists for this processor

#define TE_TPROCESSOR_NOPROCESS        1200

// fatal[p], destroying a ToopsProcessor with ToopsProcesses while the sim-
// lation
// is running

#define TE_TPROCESSOR_DESTROY          1201

// fatal [p], consumeTime() called from another ToopsProcess

#define TE_TPROCESS_CT_NOACCESS        1300

// fatal [p], setWaiting called from another ToopsProcess

#define TE_TPROCESS_SETWAITING_NOACCESS 1301

// warning, ToopsProcess terminated without call to terminate().

#define TE_TPROCESS_NOTERMINATE        1302

// fatal[p], destructor called in running sim for a not terminated
// ToopsProcess

#define TE_TPROCESS_DESTROY            1303

// fatal[p], a ToopsProcess cannot create another ToopsProcess with a 
// higher priority when the simulation is running

#define TE_TPROCESS_PRIORITY_TO_LOW    1304

// fatal[p], a ToopsProcess cannot create a ToopsProcess on another 
// ToopsProcesor

#define TE_TPROCESS_WRONG_OWNER        1305

// fatal[p], while the simulation is running, new ToopsProcesses can only
// be created from behavior().

#define TE_TPROCESS_CANNOT_CREATE      1306

// fatal [p], synchronize() called from another ToopsProcess

#define TE_TPROCESS_SYNC_NOACCESS      1307

// fatal [p], calling a controlling function from a ToopsProcess that is
// not the
// owner of that ToopsTimer.

#define TE_TTIMER_NOACCESS             1400

// warning, call to ToopsTimer::start() or ToopsTimer::startAbs() ignored,
// because
// the ToopsTimer's expiry time is less or equal time().
#define TE_TTIMER_IGNOREDSTART         1401

// fatal [p], calling a controlling function before simulation stated.

#define TE_TTIMER_SIMNOTSTARTED        1402

// warning, call to ToopsTimer::stop() for a not active ToopsTimer

#define TE_TTIMER_IGNOREDSTOP          1403

// warning, indicates that a setDefault on an active ToopsTimer has no
// effect on the ToopsTimer's actual expiry time.

#define TE_TTIMER_SETDEFAULT           1404

// warning, call to start() or startAbs on active ToopsTimer. 
// The ToopsTimer will be set to the new expiry time anyway.

#define TE_TTIMER_STARTACTIVE          1405

// warning, an active ToopsTimer's destructor is called (by ToopsTimer
// going out of scope or delete'ing it). The ToopsTimer will be destroyed,
// the alert will be cancelled.

#define TE_TTIMER_DESTROYACTIVE        1406

// fatal[p], trying to create a ToopsSocket from a ToopsProcess not beeing
// the owner or to create a ToopsSocket from anywhere but not 
// ToopsProcess::behavior() when the simulation is running. Occurs
// also, when calling send, receive or synchronize from anywhere but
// owner()->behavior.

#define TE_TSOCKET_NOACCESS            1500

// fatal [p], calling a controlling function before simulation stated.

#define TE_TSOCKET_SIMNOTSTARTED       1501

// fatal [p], deleting a ToopsChannel with connected ToopsSockets

#define TE_TCHANNEL_DESTROY            1600

// fatal [p], instantiating a ToopsMessage before the simulation started.

#define TE_TMESSAGE_SIMNOTSTARTED      1700

// fatal [p], ToopsMessage::duplicate must be overridden.

#define TE_TMESSAGE_NODUPLICATE        1701

#endif // if  !defined(ERROR_H)




//----------------------------------------------------------------
// ToopsError (header --> error.h, source code -> error.cpp/.C)
// ============================================================
// Documentation: see error.h (the error numbers for all TOOPS classes
// are also defined there)

class ToopsError
{
public:
 enum    severity { fatal, error, warning, ignore };

 typedef void (*ERRFUNC) (int, ToopsError::severity, const char*);

 ToopsError (int errno, severity s, const char *who, const char *desc);

 static void setErrorHandler(ERRFUNC);

 severity setSeverity (severity newSeverity);

 severity getSeverity (void) const { return sev; }

 void err (const char *xwho = 0, const char *xdesc1 = 0,

 const char *xdesc2 = 0, const char *xdesc3 = 0,

 const char *xdesc4 = 0, const char *xdesc5 = 0 );

};
