Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

EventGeneratorBase Class Reference

A simple convenience class for event generators. More...

#include <EventGeneratorBase.h>

Inheritance diagram for EventGeneratorBase:

Detailed Description

A simple convenience class for event generators.

Note that you don't need to inherit from this class to be able to send events! Any code can send any event any time, just by calling one of the EventRouter::postEvent() functions.

Uses a BehaviorBase base class so that you can start and stop it.

Allows variable settings of the generator id and source id for outgoing events as well as automatic handling of listening/unlistening for a single optional event source. If you want something more fancy that that though, you'll have to override doStart/doStop yourself. (or extend/modify this class...)

Definition at line 22 of file EventGeneratorBase.h.

List of all members.

Public Member Functions

virtual ~EventGeneratorBase ()
 destructor - does nothing
virtual void doStart ()
 Delegate function for subclasses to be notified when the behavior starts up.
virtual void doStop ()
 Delegate function for subclasses to be notified when the behavior starts up.
virtual void processEvent (const EventBase &ev)
 if autolistening, will receive EventRouter events concerning our own listeners
Downstream Settings

These concern the events which will be thrown to listeners

virtual
EventBase::EventGeneratorID_t 
getGeneratorID () const
 return the generator ID that will be broadcast from
virtual void setGeneratorID (EventBase::EventGeneratorID_t gid)
 set the generator ID that will be broadcast from (typically it's a bad idea to call this...)
virtual size_t getSourceID () const
 return the source ID that will be broadcast on
virtual void setSourceID (size_t sid)
 set the source ID that will be broadcast on
virtual bool hasListeners () const
 return true if this generator has listeners

Protected Member Functions

virtual void addSrcListener ()
 subscribe this generator to its source
virtual void removeSrcListener ()
 unsubscribe this generator from its source
Constructors

 EventGeneratorBase (const std::string &instancename, EventBase::EventGeneratorID_t mgid, size_t msid)
 EventGeneratorBase (const std::string &instancename, EventBase::EventGeneratorID_t mgid, size_t msid, EventBase::EventGeneratorID_t srcgid)
 EventGeneratorBase (const std::string &instancename, EventBase::EventGeneratorID_t mgid, size_t msid, EventBase::EventGeneratorID_t srcgid, size_t srcsid)
 EventGeneratorBase (const std::string &instancename, EventBase::EventGeneratorID_t mgid, size_t msid, EventBase::EventGeneratorID_t srcgid, size_t srcsid, EventBase::EventTypeID_t srctype)

Protected Attributes

EventBase::EventGeneratorID_t myGenID
 the generator ID to broadcast on
size_t mySourceID
 the source ID to broadcast on
bool autoListen
 if true, will automatically start listening for EventBase(genID,sourceID) events
bool isListening
 true if listening triggered by autoListen
EventBase::EventGeneratorID_t srcGenID
 the generator ID to listen for (typically the source that this filter works on)
size_t srcSourceID
 the source ID to listen for
EventBase::EventTypeID_t srcTypeID
 the type ID to listen for
specificity_t specificity
 the level of event specificity that is being listened for, so when autoListen is triggered, we can subscribe to the right level of event stream

Upstream Settings

These help select which events will be received from other generators



enum  specificity_t { GENERATOR, SOURCE, TYPE }
 

lets you specify what level of filtering should be done

More...
virtual specificity_t getSpecificity () const
 returns the current specificity level, to modify this, call the appropriate version of setAutoListen()
virtual void setAutoListen (EventBase::EventGeneratorID_t gid)
 turns on auto listening to make it easier to set up dependancies between vision filters
virtual void setAutoListen (EventBase::EventGeneratorID_t gid, size_t sid)
 turns on auto listening to make it easier to set up dependancies between vision filters
virtual void setAutoListen (EventBase::EventGeneratorID_t gid, size_t sid, EventBase::EventTypeID_t tid)
 turns on auto listening to make it easier to set up dependancies between vision filters
virtual void unsetAutoListen ()
 turns off auto listening
virtual
EventBase::EventGeneratorID_t 
getListenGeneratorID () const
 returns the generator ID that will be listened for (not the generator of the FilterBankEvent to be created - that depends on the subclass)
virtual size_t getListenSourceID () const
 returns the source ID that will be listened for (not the source of the FilterBankEvent to be created - that depends on the subclass)
virtual EventBase::EventTypeID_t getListenTypeID () const
 returns the type ID that will be listened for (not the type of the FilterBankEvent to be created - that depends on the subclass)

Member Enumeration Documentation

lets you specify what level of filtering should be done

Enumerator:
GENERATOR 

only the generator needs to match, select all sources and types

SOURCE 

both generator and source need to match, select all types

TYPE 

explicit event tuple; generator, source, and type must all match

Definition at line 64 of file EventGeneratorBase.h.


Constructor & Destructor Documentation

virtual EventGeneratorBase::~EventGeneratorBase (  )  [virtual]

destructor - does nothing

Definition at line 28 of file EventGeneratorBase.h.

EventGeneratorBase::EventGeneratorBase ( const std::string &  instancename,
EventBase::EventGeneratorID_t  mgid,
size_t  msid 
) [protected]

Definition at line 93 of file EventGeneratorBase.h.

EventGeneratorBase::EventGeneratorBase ( const std::string &  instancename,
EventBase::EventGeneratorID_t  mgid,
size_t  msid,
EventBase::EventGeneratorID_t  srcgid 
) [protected]

Definition at line 96 of file EventGeneratorBase.h.

EventGeneratorBase::EventGeneratorBase ( const std::string &  instancename,
EventBase::EventGeneratorID_t  mgid,
size_t  msid,
EventBase::EventGeneratorID_t  srcgid,
size_t  srcsid 
) [protected]

Definition at line 99 of file EventGeneratorBase.h.

EventGeneratorBase::EventGeneratorBase ( const std::string &  instancename,
EventBase::EventGeneratorID_t  mgid,
size_t  msid,
EventBase::EventGeneratorID_t  srcgid,
size_t  srcsid,
EventBase::EventTypeID_t  srctype 
) [protected]

Definition at line 102 of file EventGeneratorBase.h.


Member Function Documentation

void EventGeneratorBase::addSrcListener (  )  [protected, virtual]

subscribe this generator to its source

Definition at line 103 of file EventGeneratorBase.cc.

Referenced by RawCameraGenerator::doStart(), doStart(), CDTGenerator::doStart(), BufferedImageGenerator::doStart(), processEvent(), and setAutoListen().

void EventGeneratorBase::doStart (  )  [virtual]

Delegate function for subclasses to be notified when the behavior starts up.

Should be overridden by subclasses to subscribe to events, install motion commands, etc.

doStart() is basically a hook to allow subclasses to jump in and do some customization of behavior parameters while the behavior is starting. If you are writing a behavior class and do not expect further derivation, just override doStart() yourself. However, if you do expect further derivation of your class, consider using preStart() or postStart() instead, and leave doStart() for the 'leaf' classes.

Reimplemented from BehaviorBase.

Reimplemented in PitchDetector, BufferedImageGenerator, CDTGenerator, and RawCameraGenerator.

Definition at line 7 of file EventGeneratorBase.cc.

void EventGeneratorBase::doStop (  )  [virtual]

Delegate function for subclasses to be notified when the behavior starts up.

May be overridden to cleanup when the behavior is shutting down. However events will automatically be unsubscribed, and by using addMotion(), motions will automatically be removed by stop(), so you may not need any cleanup.

Reimplemented from BehaviorBase.

Reimplemented in PitchDetector.

Definition at line 17 of file EventGeneratorBase.cc.

virtual size_t EventGeneratorBase::getListenSourceID (  )  const [virtual]
virtual EventBase::EventTypeID_t EventGeneratorBase::getListenTypeID (  )  const [virtual]

returns the type ID that will be listened for (not the type of the FilterBankEvent to be created - that depends on the subclass)

Definition at line 86 of file EventGeneratorBase.h.

Referenced by addSrcListener(), and removeSrcListener().

virtual specificity_t EventGeneratorBase::getSpecificity (  )  const [virtual]

returns the current specificity level, to modify this, call the appropriate version of setAutoListen()

Definition at line 70 of file EventGeneratorBase.h.

bool EventGeneratorBase::hasListeners (  )  const [virtual]

return true if this generator has listeners

Definition at line 98 of file EventGeneratorBase.cc.

Referenced by doStart(), processEvent(), and setAutoListen().

void EventGeneratorBase::processEvent ( const EventBase ev  )  [virtual]

if autolistening, will receive EventRouter events concerning our own listeners

This will automatically reduce overhead by eliminating chains of events thrown that don't have any end listeners. However, this might mean your subclass's processEvent will be receiving the events from erouterEGID, and will need to call EventGeneratorBase::processEvent() in order to allow them to be used

Reimplemented from BehaviorBase.

Definition at line 24 of file EventGeneratorBase.cc.

void EventGeneratorBase::removeSrcListener (  )  [protected, virtual]

unsubscribe this generator from its source

Definition at line 123 of file EventGeneratorBase.cc.

Referenced by processEvent(), setAutoListen(), and unsetAutoListen().

void EventGeneratorBase::setAutoListen ( EventBase::EventGeneratorID_t  gid,
size_t  sid,
EventBase::EventTypeID_t  tid 
) [virtual]

turns on auto listening to make it easier to set up dependancies between vision filters

Definition at line 74 of file EventGeneratorBase.cc.

void EventGeneratorBase::setAutoListen ( EventBase::EventGeneratorID_t  gid,
size_t  sid 
) [virtual]

turns on auto listening to make it easier to set up dependancies between vision filters

Definition at line 57 of file EventGeneratorBase.cc.

void EventGeneratorBase::setAutoListen ( EventBase::EventGeneratorID_t  gid  )  [virtual]

turns on auto listening to make it easier to set up dependancies between vision filters

Definition at line 41 of file EventGeneratorBase.cc.

virtual void EventGeneratorBase::setGeneratorID ( EventBase::EventGeneratorID_t  gid  )  [virtual]

set the generator ID that will be broadcast from (typically it's a bad idea to call this...)

Definition at line 48 of file EventGeneratorBase.h.

virtual void EventGeneratorBase::setSourceID ( size_t  sid  )  [virtual]

set the source ID that will be broadcast on

Definition at line 53 of file EventGeneratorBase.h.

void EventGeneratorBase::unsetAutoListen (  )  [virtual]

Member Data Documentation

if true, will automatically start listening for EventBase(genID,sourceID) events

Definition at line 115 of file EventGeneratorBase.h.

Referenced by doStart(), processEvent(), setAutoListen(), and unsetAutoListen().

true if listening triggered by autoListen

Definition at line 116 of file EventGeneratorBase.h.

Referenced by addSrcListener(), doStop(), and removeSrcListener().

the generator ID to broadcast on

Definition at line 113 of file EventGeneratorBase.h.

Referenced by getGeneratorID(), and setGeneratorID().

size_t EventGeneratorBase::mySourceID [protected]

the source ID to broadcast on

Definition at line 114 of file EventGeneratorBase.h.

Referenced by BallDetectionGenerator::createEvent(), getSourceID(), and setSourceID().

the level of event specificity that is being listened for, so when autoListen is triggered, we can subscribe to the right level of event stream

Definition at line 120 of file EventGeneratorBase.h.

Referenced by addSrcListener(), getSpecificity(), removeSrcListener(), and setAutoListen().

the generator ID to listen for (typically the source that this filter works on)

Definition at line 117 of file EventGeneratorBase.h.

Referenced by getListenGeneratorID(), and setAutoListen().

size_t EventGeneratorBase::srcSourceID [protected]

the source ID to listen for

Definition at line 118 of file EventGeneratorBase.h.

Referenced by getListenSourceID(), and setAutoListen().

the type ID to listen for

Definition at line 119 of file EventGeneratorBase.h.

Referenced by getListenTypeID(), and setAutoListen().


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