class Event

The basic event class

Public Classes

class Exc: public BaseExc
Exceptions for the Event Class

Public Fields

static const int _DEFAULT_PRIORITY
The default priority for an event is 8

Public Methods

Event(int p = _DEFAULT_PRIORITY)
Contructor
Event(Event &e)
Copy constructor
virtual ~Event(void)
Destructor.
void post(Tick myTime, bool disp = false) throw(Exc, BaseExc)
Insert the event into the event queue
void process(void)
Processes the event immediately
void drop(void)
Drop the event from the event queue
static inline Event* getFirst()
Returns the first event in the event queue
inline int getPriority(void)
Return the event priority
inline Tick getTime(void)
Returns the event time
inline Tick getLastTime(void)
Return the last time in which event was triggered
inline bool isDisposable(void)
Returns the value of the disposable flag Indicates if the event has to be destroyed after bein processed
inline void addStat(BaseStat *actStat)
Add a new stat probe to this event
inline void addTrace(Trace *t)
Add a new trace probe to this event
void action(void)
This method is called when the event is triggered
virtual void doit()
Must be defined for every derived class

Protected Fields

bool _disposable
Indicates if the event has to be destroyed after bein processed.

Protected Methods

void setTime(Tick actTime) throw(Exc)
Checks that the event is not queued, and set the _time field;

Documentation

The basic event class. It models an event in the simulator: contains all the basic methods for handling an event. All the derived classes need only to add specific private data and methods to set and retrieve them.
class Exc: public BaseExc
Exceptions for the Event Class

bool _disposable
Indicates if the event has to be destroyed after bein processed.

void setTime(Tick actTime) throw(Exc)
Checks that the event is not queued, and set the _time field;

static const int _DEFAULT_PRIORITY
The default priority for an event is 8. The lower this number the higher the priority.

Event(int p = _DEFAULT_PRIORITY)
Contructor.
Parameters:
f - Event source.
evtPriority - Event priority
See Also:
getSource, getEventPriority

Event(Event &e)
Copy constructor. This is defined to allow dynamic event creation using this event as a prototype. Statistics and traces are copied.

virtual ~Event(void)
Destructor.

void post(Tick myTime, bool disp = false) throw(Exc, BaseExc)
Insert the event into the event queue. If the event is already in the event queue, an exception is raised. Then, the event will be processed at time myTime. It is not possible to post an event in the past, but is possible to post an event in the present: that is, myTime must be greater than or equal to the current simulation time, otherwise an exception will be raised. If the event is marked disposable, the main simulation loop will delete it after it has been processed. Warning!! Never set disp = true for a statically declared event (i.e., an event that was not created with new) unless you want a good old core dump.
Parameters:
myTime - triggering time for the event.
disp - if the event object must be disposed.

void process(void)
Processes the event immediately. This method is similar, but not equivalent, to the post(Simulation::getTime()): by calling process(), the event is processed immediately, while by calling post(Simulation::getTime()) the event can be processed only after the current event.

void drop(void)
Drop the event from the event queue. The event is simply extracted from the queue, and hence will not be processed, but it is not destroyed.

static inline Event* getFirst()
Returns the first event in the event queue. This function is used by the main simulation engine and should never be called directly by any other object. The event is not extracted form the queue

inline int getPriority(void)
Return the event priority. It is a identifier for the event priority. In the old version, events were distinguished by their class. For simplicity we decided to introduce this identifier. We need to re-think more carefully this issue.

inline Tick getTime(void)
Returns the event time. Warning: if you try to get this field after the event has been triggered, the field could be inconsistent. Use getLastTime instead.
See Also:
getLastTime.

inline Tick getLastTime(void)
Return the last time in which event was triggered. Basically it always is the same as getTime(). However, consider that, if the event is re-posted as a consequence of the eventHandler() processing, if the statistical probe use getTime(), it could read the new posting time! This happens because statistical probes are processed AFTER the eventHandler!! lastTime is set in the action() routine to the current time of the event; the eventHandler may repost the event altering the time field, but the user may access the actual time in which event has been triggered with getLastTime().
See Also:
getTime

inline bool isDisposable(void)
Returns the value of the disposable flag Indicates if the event has to be destroyed after bein processed. In fact, if an event has been created dinamically, must be destroyed only after it has been processed. This is done by the Simulation class, only if the following flas is true.
See Also:
post

inline void addStat(BaseStat *actStat)
Add a new stat probe to this event. All the statistical objects that are related to this event will be invoked when the event is triggered, but remember, AFTER the event is processed!

inline void addTrace(Trace *t)
Add a new trace probe to this event. It is useful for defining different kinds of tracing all at the same time.

void action(void)
This method is called when the event is triggered. It contains part of the basic code of the simulation engine. For this reason, it should be overloaded only in very, very, special cases!! Do not touch if you don't know what you are doing. Also, this method should never be invoked by any entity. It can thow any type of exceptions, in principle, so I can't specify any particular type of exception in the interface

virtual void doit()
Must be defined for every derived class. This method is called from the action() method, ...


This class has no child classes.
Author:
Giuseppe Lipari, Antonino Casile, Gerardo Lamastra.
Version:
1.0

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de