Go to the first, previous, next, last section, table of contents.


CNEvent -- Generic Event

SYNOPSIS

#include <CNCL/Event.h>

TYPE

CN_EVENT

BASE CLASSES

CNDLObject

DERIVED CLASSES

None

RELATED CLASSES

CNEventHandler, CNEventScheduler, CNSimTime

DESCRIPTION

CNEvent is a data type for events used in the simulation. Control is passed between different event handlers by sending events to each other. Events have a unique ID field, a priority, a user defined type, an issued and scheduled simulation time, an addressed event handler, a sending event handler, and a pointer to an arbitrary CNCL object.

CNEvents can only be allocated on the heap via new.

Constructors:

CNEvent();
CNEvent(CNParam *param);
CNEvent(int new_type);
CNEvent(int new_type, const CNSimTime t, int prio=0);
CNEvent(int new_type, CNEventHandler *new_to, const CNSimTime t, CNObject *new_object=NIL,
int new_prio=0);
CNEvent(int new_type, CNEventHandler *new_from, CNEventHandler *new_to, const CNSimTime t,
CNObject *new_object=NIL, int new_prio=0);
CNEvent(int new_type, CNEventHandler *new_to, CNObject *new_object=NIL, int new_prio=0);
Initializes the event, optionally setting the event type, the addressed and sending event handler, the scheduled time, the referenced object, and the priority.

Destructors:

~CNEvent();
Deletes the event. The destructor is private and may only be called from CNEvent itself or the friend class CNEventScheduler. The destructor does NOT delete the referenced object.

In addition to the member functions required by CNCL, CNEvent provides:

static void set_max_events(unsigned long n);
static unsigned long get_max_events();
Gets/Sets maximum number of events. The default value for max-event is 100. If set_max_events() changes this value, it MUST be called before ANY event is created. If more than max-event events are allocated, a warning message is printed and the simulation continues with max-event multiplied by 10.
int priority() const;
void priority(int prio);
int get_priority() const;
void set_priority(int prio);
Gets/sets the event's priority.
int type() const;
void type(int new_type);
int get_type() const;
void set_type(int new_type);
Gets/sets the event's type.
CNSimTime scheduled() const;
void scheduled(const CNSimTime new_scheduled);
CNSimTime get_scheduled() const;
void set_scheduled(const CNSimTime new_scheduled);
Gets/sets the event's scheduled simulation time.
CNSimTime issued() const;
CNSimTime get_issued() const;
Gets the event's issued simulation time.
CNEventHandler *to() const;
void to(CNEventHandler *new_to);
CNEventHandler *get_to() const;
void set_to(CNEventHandler *new_to);
Gets/sets the event's addressed event handler.
CNEventHandler *from() const;
void from(CNEventHandler *new_from);
CNEventHandler *get_from() const;
void set_from(CNEventHandler *new_from);
Gets/sets the event's sending event handler.
CNObject *object() const;
void object(CNObject *obj);
CNObject *get_object() const;
void set_object(CNObject *obj);
Gets/sets the event's referenced object.
typedef unsigned long CNEventID;
CNEventID id() const;
CNEventID get_id() const;
Returns the event's unique ID number.
static void *operator new(size_t s);
The new operator. It is allocating an event out of a pool
static void operator delete(void *p);
The delete operator.
bool after(CNEvent* e2);
Returns TRUE if *this Event is scheduled after Event e2. If both Events are scheduled at the same time, the priority is checked; after that the Event ID. This method is used by the class CNEventHeapSched.


Go to the first, previous, next, last section, table of contents.