Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

EventRouter::EventMapper Class Reference

Does the actual storage of the mapping between EventBase's and the EventListeners/EventTrappers who should receive them. More...

#include <EventRouter.h>


Detailed Description

Does the actual storage of the mapping between EventBase's and the EventListeners/EventTrappers who should receive them.

Actually only stores void*'s, so it's more general than just Listeners or Trappers

Definition at line 427 of file EventRouter.h.

List of all members.

Public Member Functions

 EventMapper ()
 constructor
void addMapping (void *el, EventBase::EventGeneratorID_t egid)
 Adds a listener for all events from a given event generator.
void addMapping (void *el, EventBase::EventGeneratorID_t egid, size_t sid, EventBase::EventTypeID_t etid)
 Adds a listener for a specific source id and type from a given event generator.
bool removeMapping (const void *el, EventBase::EventGeneratorID_t egid)
 Removes a listener for all events from a given event generator, returns true if something was actually removed.
bool removeMapping (const void *el, EventBase::EventGeneratorID_t egid, size_t sid, EventBase::EventTypeID_t etid)
 Removes a listener for a specific source id and type from a given event generator, returns true if something was actually removed.
void clean ()
 removes empty data structures for all event generators
void clean (EventBase::EventGeneratorID_t egid)
 removes empty data structures associated with a single event generator
void clear ()
 Resets the mapping.
template<class T >
void getMapping (const EventBase &e, std::vector< T * > &listeners) const
 builds a list of all listeners which should receive the event, templated to typecast the pointers for you
bool verifyMapping (const void *listener, const EventBase &e) const
 Used to make sure that the specified listener exists for the given event.
bool verifyMapping (const void *listener, EventBase::EventGeneratorID_t egid, size_t sid, EventBase::EventTypeID_t etid) const
 Used to make sure that the specified listener exists for the given event.
bool verifyMappingAll (const void *listener, EventBase::EventGeneratorID_t egid) const
 Needed to complete EventRouter::isListening suite.
bool verifyMappingAny (const void *listener, EventBase::EventGeneratorID_t egid) const
 Needed to complete EventRouter::isListening suite.
bool verifyMappingAll (const void *listener, EventBase::EventGeneratorID_t egid, size_t sid) const
 Needed to complete EventRouter::isListening suite.
bool verifyMappingAny (const void *listener, EventBase::EventGeneratorID_t egid, size_t sid) const
 Needed to complete EventRouter::isListening suite.

bool hasMapping (EventBase::EventGeneratorID_t egid) const
 so stuff can tell if it even needs to bother generating an event...
bool hasMapping (EventBase::EventGeneratorID_t egid, size_t sid) const
 so stuff can tell if it even needs to bother generating an event...
bool hasMapping (EventBase::EventGeneratorID_t egid, size_t sid, EventBase::EventTypeID_t etid) const
 so stuff can tell if it even needs to bother generating an event...

Protected Types

typedef std::map< size_t,
std::vector< void * >
, std::less< size_t > > 
SIDtoListenerVectorMap_t
 a mapping from source IDs (size_t's), each to a vector of pointers to listeners

Protected Attributes

std::vector< void * > allevents [EventBase::numEGIDs]
 an array of vectors of pointers to listeners... in other words, a vector of listener pointers for each generator
SIDtoListenerVectorMap_tfilteredevents [EventBase::numEGIDs][EventBase::numETIDs]
 not for the faint of heart: a matrix of mappings to vectors of pointers to listeners

Private Member Functions

 EventMapper (const EventMapper &)
 this shouldn't be called...
EventMapperoperator= (const EventMapper &)
 this shouldn't be called...

Member Typedef Documentation

typedef std::map<size_t,std::vector<void*>,std::less<size_t> > EventRouter::EventMapper::SIDtoListenerVectorMap_t [protected]

a mapping from source IDs (size_t's), each to a vector of pointers to listeners

main use in filteredevents

See also:
filteredevents

Definition at line 495 of file EventRouter.h.


Constructor & Destructor Documentation

EventRouter::EventMapper::EventMapper (  ) 

constructor

Definition at line 594 of file EventRouter.cc.

EventRouter::EventMapper::EventMapper ( const EventMapper  )  [private]

this shouldn't be called...


Member Function Documentation

void EventRouter::EventMapper::addMapping ( void *  el,
EventBase::EventGeneratorID_t  egid,
size_t  sid,
EventBase::EventTypeID_t  etid 
)

Adds a listener for a specific source id and type from a given event generator.

Definition at line 600 of file EventRouter.cc.

void EventRouter::EventMapper::addMapping ( void *  el,
EventBase::EventGeneratorID_t  egid 
)

Adds a listener for all events from a given event generator.

Definition at line 432 of file EventRouter.h.

Referenced by EventRouter::addListener(), and EventRouter::addTrapper().

void EventRouter::EventMapper::clean ( EventBase::EventGeneratorID_t  egid  ) 

removes empty data structures associated with a single event generator

Definition at line 661 of file EventRouter.cc.

void EventRouter::EventMapper::clean (  ) 

removes empty data structures for all event generators

Definition at line 657 of file EventRouter.cc.

Referenced by EventRouter::removeListener(), and EventRouter::removeTrapper().

void EventRouter::EventMapper::clear (  ) 

Resets the mapping.

Definition at line 692 of file EventRouter.cc.

Referenced by EventRouter::reset().

template<class T >
void EventRouter::EventMapper::getMapping ( const EventBase e,
std::vector< T * > &  listeners 
) const

builds a list of all listeners which should receive the event, templated to typecast the pointers for you

Parameters:
e the key event
listeners upon return, the resulting list of listeners e maps to
listeners is not cleared prior to building, new listeners are pushed on end
Results are in the order: all specific matches first, all generator listeners second, in order they were added to the EventMapper.

Definition at line 747 of file EventRouter.cc.

Referenced by EventRouter::PostingStatus::PostingStatus().

bool EventRouter::EventMapper::hasMapping ( EventBase::EventGeneratorID_t  egid,
size_t  sid,
EventBase::EventTypeID_t  etid 
) const

so stuff can tell if it even needs to bother generating an event...

... if a tree falls in a forest, and there's no one around to see it, does it make a sound?
... if Vision sees a ball in an image, and there's no listeners, does it make an event? ;)

Returns:
true if it has any listeners, false otherwise

Definition at line 734 of file EventRouter.cc.

bool EventRouter::EventMapper::hasMapping ( EventBase::EventGeneratorID_t  egid,
size_t  sid 
) const

so stuff can tell if it even needs to bother generating an event...

... if a tree falls in a forest, and there's no one around to see it, does it make a sound?
... if Vision sees a ball in an image, and there's no listeners, does it make an event? ;)

Returns:
true if it has any listeners, false otherwise

Definition at line 720 of file EventRouter.cc.

bool EventRouter::EventMapper::hasMapping ( EventBase::EventGeneratorID_t  egid  )  const

so stuff can tell if it even needs to bother generating an event...

... if a tree falls in a forest, and there's no one around to see it, does it make a sound?
... if Vision sees a ball in an image, and there's no listeners, does it make an event? ;)

Returns:
true if it has any listeners, false otherwise

Definition at line 705 of file EventRouter.cc.

Referenced by EventRouter::hasListeners().

EventMapper& EventRouter::EventMapper::operator= ( const EventMapper  )  [private]

this shouldn't be called...

bool EventRouter::EventMapper::removeMapping ( const void *  el,
EventBase::EventGeneratorID_t  egid,
size_t  sid,
EventBase::EventTypeID_t  etid 
)

Removes a listener for a specific source id and type from a given event generator, returns true if something was actually removed.

Doesn't necessarily remove the vector or mapping if this was the last listener, use clean() to do that

Definition at line 640 of file EventRouter.cc.

bool EventRouter::EventMapper::removeMapping ( const void *  el,
EventBase::EventGeneratorID_t  egid 
)

Removes a listener for all events from a given event generator, returns true if something was actually removed.

Doesn't necessarily remove the vector or mapping if this was the last listener, use clean() to do that

Definition at line 616 of file EventRouter.cc.

Referenced by EventRouter::removeListener(), and EventRouter::removeTrapper().

bool EventRouter::EventMapper::verifyMapping ( const void *  listener,
EventBase::EventGeneratorID_t  egid,
size_t  sid,
EventBase::EventTypeID_t  etid 
) const

Used to make sure that the specified listener exists for the given event.

This is needed because after we call processEvent on a lister, we can't assume that no other listeners have been modified - one listener could cause another to turn off. If that has happened, we shouldn't send the event, even if it was in the queue originally.

Definition at line 765 of file EventRouter.cc.

bool EventRouter::EventMapper::verifyMapping ( const void *  listener,
const EventBase e 
) const

Used to make sure that the specified listener exists for the given event.

This is needed because after we call processEvent on a lister, we can't assume that no other listeners have been modified - one listener could cause another to turn off. If that has happened, we shouldn't send the event, even if it was in the queue originally.

Definition at line 470 of file EventRouter.h.

Referenced by EventRouter::isListening(), EventRouter::isTrapping(), EventRouter::PostingStatus::process(), and verifyMapping().

bool EventRouter::EventMapper::verifyMappingAll ( const void *  listener,
EventBase::EventGeneratorID_t  egid,
size_t  sid 
) const

Needed to complete EventRouter::isListening suite.

Checks both allevents and filteredevents, must be found in all

Definition at line 822 of file EventRouter.cc.

bool EventRouter::EventMapper::verifyMappingAll ( const void *  listener,
EventBase::EventGeneratorID_t  egid 
) const

Needed to complete EventRouter::isListening suite.

Only checks allevents

Definition at line 788 of file EventRouter.cc.

Referenced by EventRouter::isListeningAll(), and EventRouter::isTrappingAll().

bool EventRouter::EventMapper::verifyMappingAny ( const void *  listener,
EventBase::EventGeneratorID_t  egid,
size_t  sid 
) const

Needed to complete EventRouter::isListening suite.

Checks both allevents and filteredevents, can be found in either

Definition at line 853 of file EventRouter.cc.

bool EventRouter::EventMapper::verifyMappingAny ( const void *  listener,
EventBase::EventGeneratorID_t  egid 
) const

Needed to complete EventRouter::isListening suite.

Checks both allevents and filteredevents

Definition at line 797 of file EventRouter.cc.

Referenced by EventRouter::isListeningAny(), and EventRouter::isTrappingAny().


Member Data Documentation

std::vector<void*> EventRouter::EventMapper::allevents[EventBase::numEGIDs] [protected]

an array of vectors of pointers to listeners... in other words, a vector of listener pointers for each generator

Definition at line 498 of file EventRouter.h.

Referenced by addMapping(), getMapping(), hasMapping(), removeMapping(), verifyMapping(), verifyMappingAll(), and verifyMappingAny().

SIDtoListenerVectorMap_t* EventRouter::EventMapper::filteredevents[EventBase::numEGIDs][EventBase::numETIDs] [protected]

not for the faint of heart: a matrix of mappings to vectors of pointers to listeners

Definition at line 500 of file EventRouter.h.

Referenced by addMapping(), clean(), clear(), EventMapper(), getMapping(), hasMapping(), removeMapping(), verifyMapping(), verifyMappingAll(), and verifyMappingAny().


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