NAME
OTC_Event -
Base class for any event object.
SYNOPSIS
#include <OTC/dispatch/event.hh>
class OTC_Event
{
public:
inline void* operator new(size_t theSize);
virtual void* type() const = 0;
void deliver(OTC_EVAgent* theAgent);
void deliver(int theAgentId);
void queue(int theAgentId);
virtual OTC_Event* clone();
void destroy();
virtual void dump(ostream& outs) const = 0;
friend ostream& operator<<(
ostream& outs,
OTC_Event const& theEvent
);
protected:
virtual void cancelSource(int theAgentId);
inline void operator delete(void* theMem, size_t theSize);
inline OTC_Event();
virtual ~OTC_Event();
};
CLASS TYPE
Abstract
DESCRIPTION
OTC_Event is the base class for any event objects, which are
to be delivered to an agent.
Space for derived classes will be allocated from OTC_CommonPool.
IDENTIFICATION
virtual void* type() const = 0;
Must be redefined in a derived class
to return a void* which uniquely
identifies the event type. Normally,
a pointer to a static member variable
of a derived class would be used as the
return value.
NOTIFICATION
void deliver(OTC_EVAgent* theAgent);
Deliver the event to theAgent
immediately. No attempt should be made to
use the event object after calling this
function, as the agent probably will
have destroyed the event object.
void deliver(int theAgentId);
Deliver the event to the agent with ID
theAgentId immediately. No attempt
should be made to use the event object
after calling this function, as the agent
probably will have destroyed the event
object.
void queue(int theAgentId);
Creates a job, and schedules the job with
the dispatcher for delivery of the event
at some later time, to the agent with
ID number theAgentId.
CLONING
virtual OTC_Event* clone();
Returns an instance of the event object,
which is substitutable for this event
object. By default, this function will
increment an internal reference count and
return a pointer to the same object. If an
event contains modifiable data, the derived
class should override this function to
create an actual copy of the event object
and return the copy.
DESTRUCTION
void destroy();
Destroys the object, returning the space
it occupies back to the memory pool.
Actually, this function will only destroy
the event object if the internal reference
count, when decremented, reaches zero.
DEBUGGING
virtual void dump(ostream& outs) const = 0;
Must be redefined in a derived class to
dump to outs a representation of the
event for debugging purposes. This
function will be called to dump out
information about an event if it has to be
discarded.
friend ostream& operator<<(ostream& outs, OTC_Event const& theEvent);
Dumps a representation of theEvent
onto the stream outs.
NON DELIVERY
virtual void cancelSource(int theAgentId);
By default does nothing. Is called with
the ID agent theAgentId, when an event
is being discarded because the agent does
not exist. A derived event should override
this function to cancel the subscription
which caused the event to occur so that it
will not keep reoccuring.
SEE ALSO
OTC_CommonPool, OTC_EVAgent, OTC_Dispatcher
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED