Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

EventTranslator Class Reference

#include <EventTranslator.h>

Inheritance diagram for EventTranslator:

Inheritance graph
[legend]
List of all members.

Detailed Description

EventTranslator receives events from EventRouters in non-Main processes and adds them into a SharedQueue for Main to pick up.

Definition at line 11 of file EventTranslator.h.

Public Member Functions

 EventTranslator ()
 constructor
virtual ~EventTranslator ()
 destructor
virtual void encodeEvent (const EventBase &event)
 Call this with events which should be forwarded to other processes.
virtual bool trapEvent (const EventBase &event)
 Call this with events which should be forwarded to other processes (redirects to encodeEvent()).
virtual void processEvent (const EventBase &event)
 Call this with events which should be forwarded to other processes (redirects to encodeEvent()).
virtual void setTrapEventValue (bool v)
 set trapRet, which can let you decide whether trapped events should be filtered or not

Static Public Member Functions

static EventBasedecodeEvent (const char *buf, unsigned int size)
 Called with buffers containing incoming events which should be reconstituted.
template<class EB>
static bool registerPrototype ()
 This should be called during initialization to register all EventBase subclasses.

Protected Types

typedef std::map< unsigned
int, FactoryBase * > 
eventLookup_t
 Shorthand for they type of eventLookup.

Protected Member Functions

virtual char * bufferRequest (unsigned int size)=0
 Called by encodeEvent() to request a buffer for serializing into, must be at least size.
virtual void post (const char *buf, unsigned int size)=0
 Called by encodeEvent() after serialization is complete for communication to other processes.

Protected Attributes

bool trapRet
 The value which trapEvent() should return.

Static Protected Attributes

static eventLookup_t eventLookup
 Allows quick lookup of event subclasses based on their EventBase::getClassTypeID().

Private Member Functions

 EventTranslator (const EventTranslator &)
 don't call
EventTranslatoroperator= (const EventTranslator &)
 don't call


Member Typedef Documentation

typedef std::map<unsigned int,FactoryBase*> EventTranslator::eventLookup_t [protected]
 

Shorthand for they type of eventLookup.

Definition at line 57 of file EventTranslator.h.


Constructor & Destructor Documentation

EventTranslator::EventTranslator  )  [inline]
 

constructor

Definition at line 14 of file EventTranslator.h.

EventTranslator::~EventTranslator  )  [virtual]
 

destructor

Definition at line 20 of file EventTranslator.cc.

EventTranslator::EventTranslator const EventTranslator  )  [private]
 

don't call


Member Function Documentation

virtual char* EventTranslator::bufferRequest unsigned int  size  )  [protected, pure virtual]
 

Called by encodeEvent() to request a buffer for serializing into, must be at least size.

This buffer will then be sent to post(), which should free it (or recycle it for usage by a later bufferRequest())

Implemented in NoOpEventTranslator, and IPCEventTranslator.

Referenced by encodeEvent().

EventBase * EventTranslator::decodeEvent const char *  buf,
unsigned int  size
[static]
 

Called with buffers containing incoming events which should be reconstituted.

Returns:
the reconstituted event, or NULL if an error occured (malformed data)

Definition at line 49 of file EventTranslator.cc.

void EventTranslator::encodeEvent const EventBase event  )  [virtual]
 

Call this with events which should be forwarded to other processes.

Reimplemented in NoOpEventTranslator.

Definition at line 27 of file EventTranslator.cc.

Referenced by MotionCommand::postEvent(), processEvent(), and trapEvent().

EventTranslator& EventTranslator::operator= const EventTranslator  )  [private]
 

don't call

virtual void EventTranslator::post const char *  buf,
unsigned int  size
[protected, pure virtual]
 

Called by encodeEvent() after serialization is complete for communication to other processes.

Parameters:
buf the data to be sent, will be a buffer previously requested from bufferRequest
size the number of bytes to send
You will always get this callback after each call to bufferRequest(), even in the event of an error during saving. If an error occured, the callback will receive 0 for size.

Implemented in NoOpEventTranslator, and IPCEventTranslator.

Referenced by encodeEvent().

virtual void EventTranslator::processEvent const EventBase event  )  [inline, virtual]
 

Call this with events which should be forwarded to other processes (redirects to encodeEvent()).

By providing an EventListener interface, you can directly register this class with an EventRouter instead of having to manually forward events (although you could do that as well)

Implements EventListener.

Definition at line 33 of file EventTranslator.h.

template<class EB>
static bool EventTranslator::registerPrototype  )  [inline, static]
 

This should be called during initialization to register all EventBase subclasses.

Returns:
true upon success, false if an event matching that prototype's EventBase::getClassTypeID() was already registered

Definition at line 42 of file EventTranslator.h.

virtual void EventTranslator::setTrapEventValue bool  v  )  [inline, virtual]
 

set trapRet, which can let you decide whether trapped events should be filtered or not

Definition at line 52 of file EventTranslator.h.

virtual bool EventTranslator::trapEvent const EventBase event  )  [inline, virtual]
 

Call this with events which should be forwarded to other processes (redirects to encodeEvent()).

By providing an EventTrapper interface, you can directly register this class with an EventRouter instead of having to manually forward events (although you could do that as well)

Returns:
trapRet, which you can set via setTrapEventValue()

Implements EventTrapper.

Definition at line 27 of file EventTranslator.h.


Member Data Documentation

EventTranslator::eventLookup_t EventTranslator::eventLookup [static, protected]
 

Allows quick lookup of event subclasses based on their EventBase::getClassTypeID().

Definition at line 60 of file EventTranslator.h.

Referenced by decodeEvent(), registerPrototype(), and ~EventTranslator().

bool EventTranslator::trapRet [protected]
 

The value which trapEvent() should return.

Definition at line 77 of file EventTranslator.h.

Referenced by setTrapEventValue(), and trapEvent().


The documentation for this class was generated from the following files:

Tekkotsu v2.4.1
Generated Tue Aug 16 16:35:01 2005 by Doxygen 1.4.4