Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

EventBase Class Reference

#include <EventBase.h>

Inheritance diagram for EventBase:

List of all members.


Detailed Description

Forms the basis of communication between modules/behaviors in the framework.

Events are defined by a 3-tuple:

  • The generator indicates the class of the creator of the event, and in practice also generally implies the type (i.e. subclass) of the event itself.
  • The source indicates the instance of the creator of the event, which differentiates when more than one generator is available.
  • The type indicates the role of the event among other events from the source.

Each of these is represented by an ID, the EventGeneratorID_t (EGID) and EventTypeID_t (ETID) are defined here in EventBase. Source IDs (SID) are defined separately by each generator, so the documentation in each entry of EventGeneratorID_t describes how to interpret the source field.

So for example, the button event which results from initially pressing the head button on an ERS-7 robot would be:

(EventBase::buttonEGID, ERS7Info::HeadButOffset, EventBase::activateETID)

While the button is held down, additional statusETID events are used to report varying pressure values (if the button is pressure sensitive), and an event with deactivateETID is sent when the button is released. Alternatively, an SID value from a vision detector (say visObjEGID) refers to seeing a particular object, a completely different domain, values of which may overlap with other generators' source IDs. Thus, interpreting the source field requires knowing the generator as well.

When the generator doesn't have groups of activity with a 'begin' or 'end', it will use statusETID for all of its events. (in other words, not all generators necessarily have to use activate or deactivate) For example, sensor updates are continuously occuring, so you will only ever see

(EventBase::sensorEGID,SensorSrcID::UpdatedSID,EventBase::statusETID)

The duration field is also generator specific - some may refer to the time since the last activation event (e.g. button events) where as others refer to time since last status (e.g. sensors updates)

If you want to make a new generator, all you have to do is add a new entry to the ID list (EventGeneratorID_t) and then put its name in the EventGeneratorNames[] array. Alternatively, there is an 'unlicensed spectrum' available under unknownEGID. You can send out events from that generator just like any other, but it should only be used for quick tests and hacking around...

The generator ID number is only that -- an ID number. Events can be posted to the EventRouter anywhere, anytime, and do not require anything of the sender. However, there is an EventGeneratorBase which can simplify some aspects of behaviors whose sole purpose is processing information and generating events.

If more information needs to be sent along with the event, the cleanest solution is to create a subclass of EventBase to hold the additional information. For example, you can see the existing subclasses in the inheritance diagram above. If you want to use a quick hack however, you could just pass a pointer to data as the SID if you don't need that field for something else, or use a DataEvent.

Note:
All subclasses must override getClassTypeID() and provide a unique value to allow fast polymorphic serialization for inter-process communication. Implementing the load/save functions ({load,save}BinaryBuffer and {load,save}XML) for your addtional data fields would also be necessary in order to allow your event to be sent between processes, or eventually, between robots.
See also:
EventRouter for discussion on sending and receiving of events

Tutorials:

Definition at line 75 of file EventBase.h.


LoadSave interface

Useful for serializing events to send between processes

enum  SaveFormat { BINARY, XML }
 values to pass to setSaveFormat() More...
virtual classTypeID_t getClassTypeID () const
 All subclasses should override this and return a unique ID for their class.
virtual unsigned int getBinSize () const
 should return the minimum size needed if using binary format (i.e. not XML)
virtual unsigned int loadBinaryBuffer (const char buf[], unsigned int len)
 load from binary format
virtual unsigned int saveBinaryBuffer (char buf[], unsigned int len) const
 save to binary format
virtual void loadXML (xmlNode *node)
 load from XML format
virtual void saveXML (xmlNode *node) const
 save to XML format
virtual unsigned int loadBuffer (const char buf[], unsigned int len)
 no longer need to override this -- will automatically call either loadXML() or loadBinaryBuffer() based on saveFormat
virtual unsigned int saveBuffer (char buf[], unsigned int len) const
 no longer need to override this -- will automatically call either saveXML() or saveBinaryBuffer() based on saveFormat
virtual unsigned int loadFile (const char *filename)
 automatically calls either XMLLoadSave::loadFile or LoadSave::loadFile based on saveFormat
virtual unsigned int saveFile (const char *filename) const
 automatically calls either XMLLoadSave::saveFile or LoadSave::saveFile based on saveFormat
virtual unsigned int loadFileStream (FILE *f)
 automatically calls either XMLLoadSave::loadFileStream or LoadSave::loadFileStream based on saveFormat
virtual unsigned int saveFileStream (FILE *f) const
 automatically calls either XMLLoadSave::loadFileStream or LoadSave::loadFileStream based on saveFormat
virtual void setSaveFormat (SaveFormat sf) const
 set saveFormat
virtual SaveFormat getSaveFormat () const
 return saveFormat

Methods



static bool isValidGeneratorID (unsigned int egid)
virtual const std::string & getName () const
 gets the name of the event - useful for debugging output, see also getDescription()
virtual EventBasesetName (const std::string &n)
 sets name to a given string, prevents overwriting by generated names
virtual float getMagnitude () const
 gets "strength" of event - by default 1 for activate and status events, 0 for deactivate events
virtual EventBasesetMagnitude (float m)
 sets "strength" of event - you may want to override the default values (see getMagnitude())
virtual unsigned int getTimeStamp () const
 time event was created
virtual void setTimeStamp (unsigned int t)
 resets time event was created
virtual EventGeneratorID_t getGeneratorID () const
 gets the generator ID for this event
virtual EventBasesetGeneratorID (EventGeneratorID_t gid)
 sets the generator ID for this event
virtual size_t getSourceID () const
 gets the source ID for this event
virtual EventBasesetSourceID (size_t sid)
 sets the source ID for this event
virtual EventTypeID_t getTypeID () const
 gets the type ID
virtual EventBasesetTypeID (EventTypeID_t tid)
 sets the type ID
virtual int getHostID () const
virtual EventBasesetHostID (int host)
virtual unsigned int getDuration () const
 gets the time since the beginning of this sequence (the timestamp of the activate event)
virtual EventBasesetDuration (unsigned int d)
 sets the time since the beginning of this sequence (the timestamp of the activate event)
virtual const std::string & resetName ()
 resets name to generated form, overwriting any previous name
virtual bool isCustomName () const
 returns true if not using the generated name
virtual std::string getDescription (bool showTypeSpecific=true, unsigned int verbosity=0) const
 generates a description of the event with variable verbosity
bool operator< (const EventBase &e) const
virtual bool operator== (const EventBase &eb) const
 is true if the genID, typeID, and sourceID's all match
bool sameGenSource (const EventBase &eb) const
 tests to see if events have the same generator and source IDs
bool longerThan (const EventBase &eb) const
 compares event duration and ensures same event generator, source, and type - useful for event masks
bool shorterThan (const EventBase &eb) const
 compares event duration and ensures same event generator, source, and type - useful for event masks
bool equalOrLongerThan (const EventBase &eb) const
 compares event duration and ensures same event generator, source, and type - useful for event masks
bool equalOrShorterThan (const EventBase &eb) const
 compares event duration and ensures same event generator, source, and type - useful for event masks

Public Types

enum  EventGeneratorID_t {
  unknownEGID = 0, aiEGID, audioEGID, buttonEGID,
  cameraResolutionEGID, erouterEGID, estopEGID, locomotionEGID,
  lookoutEGID, mapbuilderEGID, micOSndEGID, micRawEGID,
  micFFTEGID, micPitchEGID, motmanEGID, pilotEGID,
  powerEGID, sensorEGID, stateMachineEGID, stateSignalEGID,
  stateTransitionEGID, textmsgEGID, timerEGID, visOFbkEGID,
  visRawCameraEGID, visInterleaveEGID, visJPEGEGID, visPNGEGID,
  visSegmentEGID, visRLEEGID, visRegionEGID, visObjEGID,
  wmVarEGID, worldModelEGID, remoteStateEGID, numEGIDs
}
 Lists all possible event generator ids. More...
enum  EventTypeID_t { activateETID, statusETID, deactivateETID, numETIDs }
 an event type id is used to denote whether it's the first in a sequence (button down), in a sequence (button still down), or last (button up) More...
typedef unsigned int classTypeID_t
 type used for class ids in the type registry (see getTypeRegistry())
typedef FamilyFactory
< EventBase, classTypeID_t
registry_t
 type used for the type registry

Public Member Functions

Constructors/Destructors


 EventBase ()
 constructor
 EventBase (EventGeneratorID_t gid, size_t sid, EventTypeID_t tid, unsigned int dur=0)
 constructor
 EventBase (EventGeneratorID_t gid, size_t sid, EventTypeID_t tid, unsigned int dur, const std::string &n)
 constructor
 EventBase (EventGeneratorID_t gid, size_t sid, EventTypeID_t tid, unsigned int dur, const std::string &n, float mag)
 constructor
virtual ~EventBase ()
 destructor
virtual EventBaseclone () const
 allows a copy to be made of an event, supporting polymorphism

Static Public Member Functions

static registry_tgetTypeRegistry ()
 returns a FamilyFactory with which you can look up classTypeID_t's to make new instances from serialized data

Static Public Attributes

static const char *const EventGeneratorNames [numEGIDs]
 Holds string versions of each of the generator's names, handy for debugging so you can output the events as readable strings (you'll find this in EventBase.cc since it can't go in the header or we get multiply-defined errors during linking).
static const char *const EventTypeNames [numETIDs]
 holds string versions of EventTypeID_t
static const char *const EventTypeAbbr [numETIDs] = { "A", "S", "D" }
 holds abbreviated string versions of EventTypeID_t

Protected Member Functions

virtual void genName ()
 calls setName() with a string version of sourceID, decimal notation

Static Protected Member Functions

static unsigned int makeClassTypeID (const char *str)
 converts the first 4 characters of str to an unsigned int, should ensure consistent byte ordering across platforms

Protected Attributes

std::string stim_id
 the name of the event, use the same name consistently or else will be seen as different stimuli
float magnitude
 the current "strength" of the event/stimuli... MAKE SURE this gets set to ZERO IF event is DEACTIVATE
unsigned int timestamp
 the time the event was created - set automatically by constructor
SaveFormat saveFormat
 controls the format used during the next call to saveBuffer() (packed binary or XML)
bool nameisgen
 tracks whether the current name (stim_id) was generated by genName() (true) or setName() (false)
EventGeneratorID_t genID
 generator ID, see EventGeneratorID_t
EventTypeID_t typeID
 type ID, see EventTypeID_t
size_t sourceID
 the source ID for this event Source IDs are defined by the generator that made it. This should give authors flexibility to design their modules without having to worry about ID space collision
int hostID
unsigned int duration
 the time since this sequence started (like, how long the button has been pressed); not all generators will set this; Typically, this would be 0 for activate, (activate.timestamp-get_time()) for status and deactivate

Static Protected Attributes

static const
EventBase::classTypeID_t 
autoRegisterEventBase = getTypeRegistry().registerType<EventBase>(makeClassTypeID("BASE"))
 causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())

Member Typedef Documentation

typedef unsigned int EventBase::classTypeID_t

type used for class ids in the type registry (see getTypeRegistry())

Definition at line 138 of file EventBase.h.

type used for the type registry

Definition at line 141 of file EventBase.h.


Member Enumeration Documentation

Lists all possible event generator ids.

An event generator is a abstract source of events, used for listening to and parsing certain classes of events

IF YOU ADD AN EVENT GENERATOR, DON'T FORGET TO NAME IT (EventBase::EventGeneratorNames, actual names are in EventBase.cc)

Enumerator:
unknownEGID  default EGID, used if you forget to set it, probably not a good idea to use this for anything except errors or testing quick hacks
aiEGID  not being used, yet (might use this when AI makes decisions?)
audioEGID  Sends an event when a sound starts/ends playback, status events as chained sounds end; SID is SoundManager::Play_ID; duration is playtime.
buttonEGID  Sends activate event for button down, deactivate for button up. Status events only for when pressure sensitive buttons' reading changes. (on sensorEGID updates); SIDs are from ButtonOffset_t in the namespace of the target model (e.g. ERS210Info::ButtonOffset_t); duration is button down time.
cameraResolutionEGID  Sends a status event whenever the camera's resolution changes, such as a different camera than predicted by RobotInfo is being used, or a camera is hotswapped. SID corresponds to the visOFbkEGID for that camera.
erouterEGID  Sends activate event on first listener, deactivate on last listener, and status on other listener changes.; SID is the generator ID affected.
estopEGID  Sends an event when the estop is turned on or off; SID is the MotionManager::MC_ID of the EmergencyStopMC; duration is length of estop activation.
locomotionEGID  Sends events regarding transportation in the world; you can/should assume these will all be LocomotionEvent classes; SID is MotionManager::MC_ID of posting MotionCommand; duration is the time since last velocity change of that MC. (You could generate these for things other than walking...).
lookoutEGID  Sends an event when Lookout request is complete; SID is the id for lookout request.
mapbuilderEGID  Sends a status event when map is completed.
micOSndEGID  Sends a DataEvent<OSoundVectorData> for every audio buffer received from the system; SID and duration are always 0 (This is generated by the MainObj instantiation of MMCombo).
micRawEGID  reserved for future use
micFFTEGID  reserved for future use
micPitchEGID  Sends a PitchEvent when a particular frequency is detected; SID is a pointer to the PitchDetector, magnitude is product of amplitude and confidence.
motmanEGID  Sends events when a MotionCommand is added or removed, SID is is the MotionManager::MC_ID, duration is always 0; individual MotionCommands may throw status events to signal intermediary status.
pilotEGID  Sends events when position of agent is updated or pilot request is completed.
powerEGID  Sends events for low power warnings, temperature, etc. see PowerSrcID::PowerSourceID_t.
sensorEGID  Sends a status event when new sensor readings are available. see SensorSrcID::SensorSourceID_t.
stateMachineEGID  Sends an event upon entering and leaving a StateNode; SID is pointer to the StateNode; duration is always 0; some state will throw a status event when they have completed their task and are now idling.
stateSignalEGID  Sends a DataEvent that can be monitored by a SignalTrans for triggering a state transition.
stateTransitionEGID  Sends an event each time a transition is triggered; SID is a pointer to the transition; type is always status, duration is always 0; guaranteed to occur immediately *before* the transition actually occurs.
textmsgEGID  Sends status events when a text msg is received on console; generated by the Controller, SID is 0 if broadcast from ControllerGUI, 1 if "private" from BehaviorSwitchControl; duration is always 0 (see Controller for more information).
timerEGID  Sends timer events; you set timers explicitly, you don't have to listen as well. (See EventRouter::addTimer()) There's no cross-talk, only the listener which requested the timer will receive it; SID is whatever you requested it to be; duration is the time (since boot, in ms) that the timer was supposed to go off; these are always status.
visOFbkEGID  Sends a DataEvent < OFbkImageVectorData > for every camera image received from the system; SID and duration are always 0 (This is generated by the MainObj instantiation of MMCombo).
visRawCameraEGID  Sends a FilterBankEvent when new raw camera images are available; SID is whatever value you gave during setup (typically in StartupBehavior_SetupVision.cc), duration is always 0.
visInterleaveEGID  Sends a FilterBankEvent when new interleaved images are available; SID is whatever value you gave during setup (typically in StartupBehavior_SetupVision.cc), duration is always 0.
visJPEGEGID  Sends a FilterBankEvent when JPEG compressed images are available; SID is whatever value you gave during setup (typically in StartupBehavior_SetupVision.cc), duration is always 0.
visPNGEGID  Sends a FilterBankEvent when PNG compressed images are available; SID is whatever value you gave during setup (typically in StartupBehavior_SetupVision.cc), duration is always 0.
visSegmentEGID  Sends a SegmentedColorFilterBankEvent when color segmentated images are available; SID is whatever value you gave during setup (typically in StartupBehavior_SetupVision.cc), duration is always 0.
visRLEEGID  Sends a SegmentedColorFilterBankEvent when RLE encoded color segmentated images are available; SID is whatever value you gave during setup (typically in StartupBehavior_SetupVision.cc), duration is always 0.
visRegionEGID  Sends a SegmentedColorFilterBankEvent when color regions are available; SID is whatever value you gave during setup (typically in StartupBehavior_SetupVision.cc), duration is always 0.
visObjEGID  Sends VisionObjectEvents for objects detected in camera images; SID is whatever value you gave during setup (typically in StartupBehavior_SetupVision.cc), duration is always 0.
wmVarEGID  Sends an event when a watched memory is changed; source id is pointer to WMEntry.
worldModelEGID  not being used, yet (for when objects are detected/lost?)
remoteStateEGID  Sent when remote state is updated.
numEGIDs  the number of generators available

Definition at line 81 of file EventBase.h.

an event type id is used to denote whether it's the first in a sequence (button down), in a sequence (button still down), or last (button up)

Enumerator:
activateETID  Start of an event sequence, e.g. button down.
statusETID  Indicates a value has changed, e.g. new sensor readings.
deactivateETID  Last of a series of events, e.g. button up.
numETIDs  the number of different event types

Definition at line 124 of file EventBase.h.

values to pass to setSaveFormat()

Enumerator:
BINARY  saves will be in packed binary, loads will try binary first
XML  saves will be in xml, loads will try xml first

Definition at line 265 of file EventBase.h.


Constructor & Destructor Documentation

EventBase::EventBase (  ) 

constructor

See also:
EventRouter::postEvent()

Definition at line 67 of file EventBase.cc.

Referenced by clone().

EventBase::EventBase ( EventGeneratorID_t  gid,
size_t  sid,
EventTypeID_t  tid,
unsigned int  dur = 0 
)

constructor

See also:
EventRouter::postEvent()

Definition at line 75 of file EventBase.cc.

EventBase::EventBase ( EventGeneratorID_t  gid,
size_t  sid,
EventTypeID_t  tid,
unsigned int  dur,
const std::string &  n 
)

constructor

See also:
EventRouter::postEvent()

Definition at line 85 of file EventBase.cc.

EventBase::EventBase ( EventGeneratorID_t  gid,
size_t  sid,
EventTypeID_t  tid,
unsigned int  dur,
const std::string &  n,
float  mag 
)

constructor

See also:
EventRouter::postEvent()

Definition at line 95 of file EventBase.cc.

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

destructor

Definition at line 153 of file EventBase.h.


Member Function Documentation

EventBase::registry_t & EventBase::getTypeRegistry (  )  [static]

returns a FamilyFactory with which you can look up classTypeID_t's to make new instances from serialized data

Definition at line 62 of file EventBase.cc.

Referenced by EventTranslator::decodeEvent(), and DataEvent< T, TID >::registerDataType().

virtual EventBase* EventBase::clone (  )  const [inline, virtual]

allows a copy to be made of an event, supporting polymorphism

Must be overridden by all subclasses to allow this to happen

I would like to switch this over to the cloneable interface once the compiler gets updated out of the 3.3 branch... see Cloneable::clone() for a discussion of the issue and implementation notes.

Reimplemented in DataEvent< T, TID >, FilterBankEvent, LocomotionEvent, LookoutPointAtEvent, LookoutSketchEvent, LookoutIREvent, LookoutScanEvent, PitchEvent, SegmentedColorFilterBankEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent.

Definition at line 162 of file EventBase.h.

EventBase & EventBase::setName ( const std::string &  n  )  [virtual]

sets name to a given string, prevents overwriting by generated names

Definition at line 102 of file EventBase.cc.

Referenced by BallDetectionGenerator::createEvent(), EventBase(), genName(), and loadXML().

virtual float EventBase::getMagnitude (  )  const [inline, virtual]

gets "strength" of event - by default 1 for activate and status events, 0 for deactivate events

Definition at line 169 of file EventBase.h.

Referenced by getDescription(), and Controller::trapEvent().

virtual EventBase& EventBase::setMagnitude ( float  m  )  [inline, virtual]

sets "strength" of event - you may want to override the default values (see getMagnitude())

Definition at line 170 of file EventBase.h.

Referenced by EventBase().

virtual void EventBase::setTimeStamp ( unsigned int  t  )  [inline, virtual]

resets time event was created

Definition at line 173 of file EventBase.h.

virtual EventGeneratorID_t EventBase::getGeneratorID (  )  const [inline, virtual]

gets the generator ID for this event

See also:
EventGeneratorID_t

Definition at line 175 of file EventBase.h.

Referenced by EventRouter::addListener(), EventRouter::addRemoteListener(), EventRouter::addTrapper(), getDescription(), EventRouter::EventMapper::getMapping(), EventRouter::hasListeners(), EventRouter::isListening(), EventRouter::isTrapping(), TorqueCalibrate::TakeMeasurementControl::processEvent(), TimeOutTrans::processEvent(), SensorObserverControl::processEvent(), SegmentedColorGenerator::processEvent(), SegCamBehavior::processEvent(), RLEGenerator::processEvent(), RemoteRouter::processEvent(), RegionGenerator::processEvent(), RawCameraGenerator::processEvent(), PostureEditor::processEvent(), PNGGenerator::processEvent(), PitchDetector::processEvent(), MotionSequenceNode< SIZE >::processEvent(), MicrophoneServer::processEvent(), LostTargetTrans::processEvent(), JPEGGenerator::processEvent(), InterleavedYUVGenerator::processEvent(), FreeMemReportControl::processEvent(), FilterBankGenerator::processEvent(), EventProxy::processEvent(), EventGeneratorBase::processEvent(), DeadReckoningBehavior< ParticleT >::processEvent(), CDTGenerator::processEvent(), CameraStreamBehavior::processEvent(), BufferedImageGenerator::processEvent(), BatteryMonitorBehavior::processEvent(), BallDetectionGenerator::processEvent(), AutoGetupBehavior::processEvent(), EventLogger::processStateMachineEvent(), EventRouter::removeListener(), EventRouter::removeRemoteListener(), EventRouter::removeTimer(), EventRouter::removeTrapper(), EventRouter::EventMapper::verifyMapping(), RawCamBehavior::writeColor(), and RawCamBehavior::writeSingleChannel().

virtual EventBase& EventBase::setGeneratorID ( EventGeneratorID_t  gid  )  [inline, virtual]

sets the generator ID for this event

See also:
EventGeneratorID_t

Definition at line 176 of file EventBase.h.

virtual EventBase& EventBase::setSourceID ( size_t  sid  )  [inline, virtual]

sets the source ID for this event

See also:
sourceID

Definition at line 179 of file EventBase.h.

virtual EventBase& EventBase::setTypeID ( EventTypeID_t  tid  )  [inline, virtual]

virtual int EventBase::getHostID (  )  const [inline, virtual]

Definition at line 185 of file EventBase.h.

virtual EventBase& EventBase::setHostID ( int  host  )  [inline, virtual]

Definition at line 186 of file EventBase.h.

virtual unsigned int EventBase::getDuration (  )  const [inline, virtual]

gets the time since the beginning of this sequence (the timestamp of the activate event)

See also:
duration

Definition at line 188 of file EventBase.h.

Referenced by EventRouter::addTimer(), getDescription(), and Controller::trapEvent().

virtual EventBase& EventBase::setDuration ( unsigned int  d  )  [inline, virtual]

sets the time since the beginning of this sequence (the timestamp of the activate event)

See also:
duration

Definition at line 189 of file EventBase.h.

virtual const std::string& EventBase::resetName (  )  [inline, virtual]

resets name to generated form, overwriting any previous name

Definition at line 191 of file EventBase.h.

virtual bool EventBase::isCustomName (  )  const [inline, virtual]

returns true if not using the generated name

Definition at line 192 of file EventBase.h.

std::string EventBase::getDescription ( bool  showTypeSpecific = true,
unsigned int  verbosity = 0 
) const [virtual]

generates a description of the event with variable verbosity

Parameters:
showTypeSpecific should be read by subclasses to add additional information
verbosity can be one of the following values:
  • 0 - Basic: event_name \t generator_id \t source_id \t type_id
  • 1 - Numerics: event_name \t generator_id \t source_id \t type_id
  • 2 - Timing: event_name \t generator_id \t source_id \t type_id \t duration \t timestamp
  • 3 and above - Full: event_name \t generator_id \t source_id \t type_id \t duration \t timestamp \t magnitude if showTypeSpecific, additional fields will be added after the common fields listed above.

Reimplemented in LocomotionEvent, LookoutPointAtEvent, LookoutIREvent, PitchEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent.

Definition at line 128 of file EventBase.cc.

Referenced by VisionObjectEvent::getDescription(), TimerEvent::getDescription(), TextMsgEvent::getDescription(), PitchEvent::getDescription(), LookoutPointAtEvent::getDescription(), LocomotionEvent::getDescription(), EventLogger::processEvent(), and EventLogger::processStateMachineEvent().

bool EventBase::operator< ( const EventBase e  )  const [inline]

Definition at line 204 of file EventBase.h.

virtual bool EventBase::operator== ( const EventBase eb  )  const [inline, virtual]

is true if the genID, typeID, and sourceID's all match

Definition at line 207 of file EventBase.h.

bool EventBase::sameGenSource ( const EventBase eb  )  const [inline]

tests to see if events have the same generator and source IDs

Definition at line 211 of file EventBase.h.

Referenced by Controller::trapEvent().

bool EventBase::longerThan ( const EventBase eb  )  const [inline]

compares event duration and ensures same event generator, source, and type - useful for event masks

Definition at line 213 of file EventBase.h.

bool EventBase::shorterThan ( const EventBase eb  )  const [inline]

compares event duration and ensures same event generator, source, and type - useful for event masks

Definition at line 214 of file EventBase.h.

bool EventBase::equalOrLongerThan ( const EventBase eb  )  const [inline]

compares event duration and ensures same event generator, source, and type - useful for event masks

Definition at line 215 of file EventBase.h.

bool EventBase::equalOrShorterThan ( const EventBase eb  )  const [inline]

compares event duration and ensures same event generator, source, and type - useful for event masks

Definition at line 216 of file EventBase.h.

static bool EventBase::isValidGeneratorID ( unsigned int  egid  )  [inline, static]

Definition at line 218 of file EventBase.h.

virtual classTypeID_t EventBase::getClassTypeID (  )  const [inline, virtual]

All subclasses should override this and return a unique ID for their class.

All IDs corresponding to all-capital letters are reserved for future framework expansion. (Thus, user subclasses should contain at least one lower-case letter.) This code can be used when serializing to allow quick identification of the class type by the receiver.

Reimplemented in DataEvent< T, TID >, FilterBankEvent, LocomotionEvent, LookoutPointAtEvent, LookoutSketchEvent, LookoutIREvent, LookoutScanEvent, PitchEvent, SegmentedColorFilterBankEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent.

Definition at line 229 of file EventBase.h.

unsigned int EventBase::getBinSize (  )  const [virtual]

void EventBase::saveXML ( xmlNode node  )  const [virtual]

virtual unsigned int EventBase::loadBuffer ( const char  buf[],
unsigned int  len 
) [inline, virtual]

no longer need to override this -- will automatically call either loadXML() or loadBinaryBuffer() based on saveFormat

tries to be smart so if the load based on the current saveFormat fails, retries with the alternative format

Reimplemented from XMLLoadSave.

Definition at line 239 of file EventBase.h.

Referenced by EventTranslator::decodeEvent().

virtual unsigned int EventBase::saveBuffer ( char  buf[],
unsigned int  len 
) const [inline, virtual]

no longer need to override this -- will automatically call either saveXML() or saveBinaryBuffer() based on saveFormat

Reimplemented from XMLLoadSave.

Definition at line 246 of file EventBase.h.

virtual unsigned int EventBase::loadFile ( const char *  filename  )  [inline, virtual]

automatically calls either XMLLoadSave::loadFile or LoadSave::loadFile based on saveFormat

tries to be smart so if the load based on the current saveFormat fails, retries with the alternative format

Reimplemented from XMLLoadSave.

Definition at line 250 of file EventBase.h.

virtual unsigned int EventBase::saveFile ( const char *  filename  )  const [inline, virtual]

automatically calls either XMLLoadSave::saveFile or LoadSave::saveFile based on saveFormat

Reimplemented from XMLLoadSave.

Definition at line 257 of file EventBase.h.

virtual unsigned int EventBase::loadFileStream ( FILE *  f  )  [inline, virtual]

automatically calls either XMLLoadSave::loadFileStream or LoadSave::loadFileStream based on saveFormat

Reimplemented from XMLLoadSave.

Definition at line 260 of file EventBase.h.

virtual unsigned int EventBase::saveFileStream ( FILE *  f  )  const [inline, virtual]

automatically calls either XMLLoadSave::loadFileStream or LoadSave::loadFileStream based on saveFormat

Reimplemented from XMLLoadSave.

Definition at line 262 of file EventBase.h.

virtual void EventBase::setSaveFormat ( SaveFormat  sf  )  const [inline, virtual]

set saveFormat

Definition at line 269 of file EventBase.h.

Referenced by EventTranslator::decodeEvent().

virtual SaveFormat EventBase::getSaveFormat (  )  const [inline, virtual]

return saveFormat

Definition at line 270 of file EventBase.h.

static unsigned int EventBase::makeClassTypeID ( const char *  str  )  [inline, static, protected]

converts the first 4 characters of str to an unsigned int, should ensure consistent byte ordering across platforms

Definition at line 275 of file EventBase.h.

void EventBase::genName (  )  [protected, virtual]

calls setName() with a string version of sourceID, decimal notation

Definition at line 287 of file EventBase.cc.

Referenced by EventBase(), loadBinaryBuffer(), loadXML(), resetName(), setGeneratorID(), setHostID(), and setSourceID().


Member Data Documentation

const char *const EventBase::EventGeneratorNames [static]

Holds string versions of each of the generator's names, handy for debugging so you can output the events as readable strings (you'll find this in EventBase.cc since it can't go in the header or we get multiply-defined errors during linking).

Definition at line 121 of file EventBase.h.

Referenced by EventRouter::addListener(), EventRouter::addTrapper(), EventLogger::EventLogger(), loadXML(), EventRouter::removeListener(), EventRouter::removeTrapper(), saveXML(), setName(), and Controller::takeLine().

const char *const EventBase::EventTypeNames [static]

Initial value:

 {
  "activate",
  "status",
  "deactivate"
}
holds string versions of EventTypeID_t

Definition at line 132 of file EventBase.h.

Referenced by loadXML(), and Controller::takeLine().

const char *const EventBase::EventTypeAbbr = { "A", "S", "D" } [static]

holds abbreviated string versions of EventTypeID_t

Definition at line 135 of file EventBase.h.

Referenced by loadXML(), saveXML(), setName(), setTypeID(), and Controller::takeLine().

std::string EventBase::stim_id [protected]

the name of the event, use the same name consistently or else will be seen as different stimuli

Definition at line 285 of file EventBase.h.

Referenced by getBinSize(), getName(), loadBinaryBuffer(), resetName(), saveBinaryBuffer(), saveXML(), setName(), and setTypeID().

float EventBase::magnitude [protected]

the current "strength" of the event/stimuli... MAKE SURE this gets set to ZERO IF event is DEACTIVATE

Definition at line 286 of file EventBase.h.

Referenced by getBinSize(), getMagnitude(), loadBinaryBuffer(), loadXML(), saveBinaryBuffer(), saveXML(), and setMagnitude().

unsigned int EventBase::timestamp [protected]

the time the event was created - set automatically by constructor

Definition at line 287 of file EventBase.h.

Referenced by getBinSize(), getTimeStamp(), loadBinaryBuffer(), loadXML(), operator<(), saveBinaryBuffer(), saveXML(), and setTimeStamp().

bool EventBase::nameisgen [protected]

tracks whether the current name (stim_id) was generated by genName() (true) or setName() (false)

Definition at line 291 of file EventBase.h.

Referenced by genName(), getBinSize(), isCustomName(), loadBinaryBuffer(), resetName(), saveBinaryBuffer(), saveXML(), and setName().

type ID, see EventTypeID_t

Definition at line 295 of file EventBase.h.

Referenced by getTypeID(), loadBinaryBuffer(), loadXML(), operator==(), saveBinaryBuffer(), saveXML(), and setTypeID().

size_t EventBase::sourceID [protected]

the source ID for this event Source IDs are defined by the generator that made it. This should give authors flexibility to design their modules without having to worry about ID space collision

Definition at line 296 of file EventBase.h.

Referenced by genName(), getBinSize(), getSourceID(), loadBinaryBuffer(), loadXML(), operator==(), sameGenSource(), saveBinaryBuffer(), saveXML(), and setSourceID().

unsigned int EventBase::duration [protected]

the time since this sequence started (like, how long the button has been pressed); not all generators will set this; Typically, this would be 0 for activate, (activate.timestamp-get_time()) for status and deactivate

Definition at line 301 of file EventBase.h.

Referenced by equalOrLongerThan(), equalOrShorterThan(), getBinSize(), getDuration(), loadBinaryBuffer(), loadXML(), longerThan(), saveBinaryBuffer(), saveXML(), setDuration(), and shorterThan().

const EventBase::classTypeID_t EventBase::autoRegisterEventBase = getTypeRegistry().registerType<EventBase>(makeClassTypeID("BASE")) [static, protected]

causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())

Definition at line 307 of file EventBase.h.

Referenced by getClassTypeID().


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

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