Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

EventTranslator Class Reference

#include <EventTranslator.h>

Inheritance diagram for EventTranslator:

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 10 of file EventTranslator.h.


Public Member Functions

 EventTranslator ()
 constructor
virtual ~EventTranslator ()
 destructor
virtual void encodeEvent (const EventBase &event, bool onlyReady=false)
 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.

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, bool onlyReady)=0
 Called by encodeEvent() after serialization is complete for communication to other processes.

Protected Attributes

bool trapRet
 The value which trapEvent() should return.

Private Member Functions

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

Constructor & Destructor Documentation

EventTranslator::EventTranslator (  )  [inline]

constructor

Definition at line 13 of file EventTranslator.h.

virtual EventTranslator::~EventTranslator (  )  [inline, virtual]

destructor

Definition at line 16 of file EventTranslator.h.

EventTranslator::EventTranslator ( const EventTranslator  )  [private]

don't call


Member Function Documentation

void EventTranslator::encodeEvent ( const EventBase event,
bool  onlyReady = false 
) [virtual]

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

Parameters:
event the event to serialize and send
onlyReady if true, only send the event to observers which do not have any message backlog (if supported by transfer mechanism)

Reimplemented in NoOpEventTranslator, and IPCEventTranslator.

Definition at line 20 of file EventTranslator.cc.

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

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 28 of file EventTranslator.h.

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 34 of file EventTranslator.h.

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 46 of file EventTranslator.cc.

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 41 of file EventTranslator.h.

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().

virtual void EventTranslator::post ( const char *  buf,
unsigned int  size,
bool  onlyReady 
) [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
onlyReady if true, only send the event to observers which do not have any message backlog (if supported by transfer mechanism)
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().

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

don't call


Member Data Documentation

bool EventTranslator::trapRet [protected]

The value which trapEvent() should return.

Definition at line 62 of file EventTranslator.h.

Referenced by setTrapEventValue(), and trapEvent().


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

Tekkotsu v4.0
Generated Thu Nov 22 00:58:20 2007 by Doxygen 1.5.4