Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

EventTranslator Class Reference

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

#include <EventTranslator.h>

Inheritance diagram for EventTranslator:

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.

List of all members.

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

constructor

Definition at line 14 of file EventTranslator.h.

virtual EventTranslator::~EventTranslator (  )  [virtual]

destructor

Definition at line 17 of file EventTranslator.h.

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

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

virtual void EventTranslator::processEvent ( const EventBase event  )  [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 35 of file EventTranslator.h.

virtual void EventTranslator::setTrapEventValue ( bool  v  )  [virtual]

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

Definition at line 42 of file EventTranslator.h.

virtual bool EventTranslator::trapEvent ( const EventBase event  )  [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 29 of file EventTranslator.h.


Member Data Documentation

bool EventTranslator::trapRet [protected]

The value which trapEvent() should return.

Definition at line 63 of file EventTranslator.h.

Referenced by setTrapEventValue(), and trapEvent().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:07 2016 by Doxygen 1.6.3