OMK::EventListener Class Reference

The base class for event listener, wich enable automatic reaction on registred events. More...

#include <OMKEventListener.h>

Inheritance diagram for OMK::EventListener:

Inheritance graph
[legend]
Collaboration diagram for OMK::EventListener:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 EventListener (SimulatedObject &owner)
 constructor
virtual ~EventListener ()
 Destructor.
virtual void registerEvents ()
 Registration method.
virtual bool processEvent (Event *event)=0
 process an event :
virtual void prepareEventProcessing (const std::list< Event * > &, std::list< Event * >::const_iterator)
 called before processEvent, in case the event listener has to take more than one event into account

Protected Attributes

SimulatedObject_owner
 the simulated object the event listener is acting in hehalf of

Detailed Description

The base class for event listener, wich enable automatic reaction on registred events.

The event listeners are added to an object, which is its owner.

When the event listener is deleted it calls unregisterEventListener to inform its owner that it is no more available.

At the end of its live, during its destruction the object deletes all the remaining event listeners. So an event listener can be delete at any time.

Definition at line 41 of file OMKEventListener.h.


Constructor & Destructor Documentation

EventListener::EventListener ( SimulatedObject owner  ) 

constructor

Parameters:
owner : the simulated object this event listener is reacting in behalf of

Definition at line 24 of file OMKEventListener.cpp.

00024                                                       :
00025    _owner ( owner ) 
00026 {
00027 }

EventListener::~EventListener (  )  [virtual]

Destructor.

The destructor unregister the event listener near the object with a call to unregisterEventListener. So when the one which declares the event listener delete it, the object removes any link to this event listener.

Definition at line 30 of file OMKEventListener.cpp.

References _owner, and OMK::SimulatedObject::unregisterEventListener().

00031 {
00032   _owner.unregisterEventListener( *this );
00033 }


Member Function Documentation

void EventListener::registerEvents (  )  [virtual]

Registration method.

This member function is used by the owner of the event listener to know which events are taken in charge. To register the events id the event listener calls registerEventListenerForEvent method of its owner, like this:

void MyEventListener::registerEvents() 
{
  _owner.registerEventListenerForEvent( *this, myEventId ) ;
}

Reimplemented in OMK::ChangedControlParameterEventListener< T >, OMK::EventListenerCallBack< CallerClass >, OMK::ValuedEventListenerCallBack< CallerClass, PrmType >, OMK::InputConnectionEventListener< T >, OMK::Inp::InputCreatorListener, OMK::InputConnectionEventListener< ModelType >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< bool > >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< float > >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< T > >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< PrmType > >, OMK::InputConnectionEventListener< PrmType >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< OMK::Type::Transform > >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< HBT::PostureData > >, and OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< Type > >.

Definition at line 40 of file OMKEventListener.cpp.

Referenced by OMK::SimulatedObject::addEventListener().

00041 {
00042    //don't do anything, as we don't know to which event we will be associated to
00043 }

virtual bool OMK::EventListener::processEvent ( Event event  )  [pure virtual]

process an event :

Returns:
returning true will 1 - stop the event from being processed by any other eventlistener or by the object 2 - tell the system to destroy the event
if you want to prevent the event from being seen by the other eventListeners but want it seen by the object, call owner.processEvent and return true. Warning, if owner.processEvent returns false, you have a problem because the event will be destoyed whilst the owner is thinking he can still use it safely

Implemented in OMK::ChangedControlParameterEventListener< T >, OMK::EventListenerCallBack< CallerClass >, OMK::ValuedEventListenerCallBack< CallerClass, PrmType >, OMK::InputConnectionEventListener< T >, OMK::Inp::InputCreatorListener, OMK::InputConnectionEventListener< ModelType >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< bool > >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< float > >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< T > >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< PrmType > >, OMK::InputConnectionEventListener< PrmType >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< OMK::Type::Transform > >, OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< HBT::PostureData > >, and OMK::InputConnectionEventListener< OMK::Type::SimpleTypeT< Type > >.

void EventListener::prepareEventProcessing ( const std::list< Event * > &  ,
std::list< Event * >::const_iterator   
) [virtual]

called before processEvent, in case the event listener has to take more than one event into account

Definition at line 35 of file OMKEventListener.cpp.

00036                                                                                  {
00037 
00038 }


Member Data Documentation

SimulatedObject& OMK::EventListener::_owner [protected]

the simulated object the event listener is acting in hehalf of

Definition at line 85 of file OMKEventListener.h.

Referenced by OMK::ChangedControlParameterEventListener< T >::ChangedControlParameterEventListener(), OMK::EventListenerCallBack< CallerClass >::EventListenerCallBack(), OMK::InputConnectionEventListener< T >::InputConnectionEventListener(), OMK::ValuedEventListenerCallBack< CallerClass, PrmType >::processEvent(), OMK::ValuedEventListenerCallBack< CallerClass, PrmType >::registerEvents(), OMK::Inp::InputCreatorListener::registerEvents(), OMK::InputConnectionEventListener< T >::registerEvents(), OMK::EventListenerCallBack< CallerClass >::registerEvents(), OMK::ChangedControlParameterEventListener< T >::registerEvents(), OMK::ValuedEventListenerCallBack< CallerClass, PrmType >::ValuedEventListenerCallBack(), and ~EventListener().


logo OpenMask

Documentation generated on Mon Jun 9 11:46:01 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007