OMK::Inp::GenericKeyExtension< OwnerClass > Class Template Reference
[User inputs]

Generic extension to handle a key. More...

#include <OMKGenericKeyExtension.h>

Inheritance diagram for OMK::Inp::GenericKeyExtension< OwnerClass >:

Inheritance graph
[legend]
Collaboration diagram for OMK::Inp::GenericKeyExtension< OwnerClass >:

Collaboration graph
[legend]
List of all members.

Protected Member Functions

bool pressFct (Event *event)
 The call back method associated with the event listener for press.
bool releaseFct (Event *event)
 The call back method associated with the event listener for release.
virtual void action ()
 The method to overwrite for press action.
virtual void actionRelease ()
 The method to overwrite for release action.
Configuration loaders
virtual bool loadExtensionParameters (const ConfigurationParameterDescriptor *node)
 Configuration parameters loader of Extension.

Protected Attributes

EventListener_eventListenerPress
 The event listener which receives the key press event.
EventListener_eventListenerRelease
 The event listener which receives the key release event.
const std::string _defaultKey
 The default key.

Detailed Description

template<class OwnerClass>
class OMK::Inp::GenericKeyExtension< OwnerClass >

Generic extension to handle a key.

Date:
2007-03-14
Author:
Benoît Chanclou
Defines a generic extension which handles a key. This is a template class, the parameters are: There is two ways to use those extnsion.

Definition at line 61 of file OMKGenericKeyExtension.h.


Constructor & Destructor Documentation

template<class OwnerClass>
OMK::Inp::GenericKeyExtension< OwnerClass >::GenericKeyExtension ( ExtensibleSimulatedObject owner,
const Name id,
bool  registerExtension,
const std::string &  defaultKey 
) [inline, protected]

Constructor.

It is protected, because it is only called by the friend creator.

Definition at line 69 of file OMKGenericKeyExtension.h.

00070   : ExtensionT< OwnerClass >( owner, id ),
00071     _eventListenerPress( 0 ),
00072     _eventListenerRelease( 0 ),
00073     _defaultKey( defaultKey )
00074   {
00075   }

template<class OwnerClass>
virtual OMK::Inp::GenericKeyExtension< OwnerClass >::~GenericKeyExtension (  )  [inline, virtual]

Definition at line 77 of file OMKGenericKeyExtension.h.

00078   {
00079     delete _eventListenerPress ;
00080     delete _eventListenerRelease ;
00081   }

template<class OwnerClass>
OMK::Inp::GenericKeyExtension< OwnerClass >::GenericKeyExtension ( ExtensibleSimulatedObject owner,
const Name id,
bool  registerExtension,
const std::string &  defaultKey 
) [inline, protected]

Constructor.

It is protected, because it is only called by the friend creator.

Definition at line 69 of file OMKGenericKeyExtension.h.

00070   : ExtensionT< OwnerClass >( owner, id ),
00071     _eventListenerPress( 0 ),
00072     _eventListenerRelease( 0 ),
00073     _defaultKey( defaultKey )
00074   {
00075   }

template<class OwnerClass>
virtual OMK::Inp::GenericKeyExtension< OwnerClass >::~GenericKeyExtension (  )  [inline, virtual]

Definition at line 77 of file OMKGenericKeyExtension.h.

00078   {
00079     delete _eventListenerPress ;
00080     delete _eventListenerRelease ;
00081   }


Member Function Documentation

template<class OwnerClass>
virtual bool OMK::Inp::GenericKeyExtension< OwnerClass >::loadExtensionParameters ( const ConfigurationParameterDescriptor node  )  [inline, protected, virtual]

Configuration parameters loader of Extension.

Retrieves the key (by default it is B), then creates the event listener and the key listener for the defined key.

Reimplemented from OMK::Extension.

Reimplemented in OMK::Inp::DebugOverlayExtension, OMK::Inp::KeyEmitterExtension, OMK::Inp::KeyEmitterExtensionT< T, ModelType >, OMK::Inp::OverlayExtension, and OMK::Inp::PlusMinusExtension< T >.

Definition at line 96 of file OMKGenericKeyExtension.h.

Referenced by OMK::Inp::PlusMinusExtension< T >::loadExtensionParameters().

00097   {
00098     bool ok = true ;
00099     std::string key( _defaultKey ) ;
00100     ParametersAccessor::get( node, "Key", key ) ;
00101     std::string visuName( "visualisation" ) ;
00102     ok = ok && ParametersAccessor::get( node, "VisuName", visuName, _owner ) ;
00103     // What kind of action
00104     bool press = true ;
00105     bool release = false ;
00106     std::string actionOn ;
00107     if( ParametersAccessor::get( node, "ActionOn", actionOn ) )
00108     {
00109       std::transform( actionOn.begin(), actionOn.end(), actionOn.begin(), toupper ) ;
00110       press = ( actionOn == "PRESS" ) || ( actionOn == "BOTH" ) ;
00111       release = ( actionOn == "RELEASE" ) || ( actionOn == "BOTH" ) ;
00112     }
00113     // initialisation of the listeners
00114     if( ok && press )
00115     {
00116       _eventListenerPress = new EventListenerCallBack< GenericKeyExtension< OwnerClass > >
00117           ( *_owner, this, 
00118             (typename EventListenerCallBack< GenericKeyExtension< OwnerClass > >::CallBackFct)&GenericKeyExtension< OwnerClass >::pressFct, 
00119             OMK::Inp::KeyListener::getKeyPressCode( key ) ) ;
00120       _owner->sendValuedEvent( visuName, OMK::Inp::InputExtension::ADD_KEY, OMK::Inp::AddInputKeyPrm( key, _owner->getName() ) ) ;
00121     }
00122     if( ok && release )
00123     {
00124       _eventListenerRelease = new EventListenerCallBack< GenericKeyExtension< OwnerClass > >
00125           ( *_owner, this, 
00126             (typename EventListenerCallBack< GenericKeyExtension< OwnerClass > >::CallBackFct)&GenericKeyExtension< OwnerClass >::releaseFct, 
00127             OMK::Inp::KeyListener::getKeyReleaseCode( key ) ) ;
00128       _owner->sendValuedEvent( visuName, OMK::Inp::InputExtension::ADD_KEY, OMK::Inp::AddInputKeyPrm( key, _owner->getName() ) ) ;
00129     }
00130     return ok ;
00131   }

template<class OwnerClass>
bool OMK::Inp::GenericKeyExtension< OwnerClass >::pressFct ( Event event  )  [inline, protected]

The call back method associated with the event listener for press.

Definition at line 151 of file OMKGenericKeyExtension.h.

00152   {
00153     action() ;
00154     // Returns false because may be another key listener wants to see the event
00155     return false ;
00156   }

template<class OwnerClass>
bool OMK::Inp::GenericKeyExtension< OwnerClass >::releaseFct ( Event event  )  [inline, protected]

The call back method associated with the event listener for release.

Definition at line 158 of file OMKGenericKeyExtension.h.

00159   {
00160     actionRelease() ;
00161     // Returns false because may be another key listener wants to see the event
00162     return false ;
00163   }

template<class OwnerClass>
virtual void OMK::Inp::GenericKeyExtension< OwnerClass >::action (  )  [inline, protected, virtual]

The method to overwrite for press action.

Reimplemented in OMK::Inp::BoundingBoxExtension, OMK::Inp::DebugOverlayExtension, OMK::Inp::KeyEmitterExtension, OMK::Inp::KeyEmitterExtensionT< T, ModelType >, OMK::Inp::OverlayExtension, OMK::Inp::PlusMinusExtension< T >, and OMK::Inp::SceneDetailsExtension.

Definition at line 165 of file OMKGenericKeyExtension.h.

Referenced by OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::pressFct().

00165 {}

template<class OwnerClass>
virtual void OMK::Inp::GenericKeyExtension< OwnerClass >::actionRelease (  )  [inline, protected, virtual]

The method to overwrite for release action.

Reimplemented in OMK::Inp::PlusMinusExtension< T >.

Definition at line 167 of file OMKGenericKeyExtension.h.

Referenced by OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::releaseFct().

00167 {}


Member Data Documentation

template<class OwnerClass>
EventListener* OMK::Inp::GenericKeyExtension< OwnerClass >::_eventListenerPress [protected]

The event listener which receives the key press event.

It is created in the loadExtensionParameters method, it is a EventListenerCallBack which is associated with the callBackFct method.

Definition at line 142 of file OMKGenericKeyExtension.h.

Referenced by OMK::Inp::PlusMinusExtension< T >::actionRelease(), OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::loadExtensionParameters(), and OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::~GenericKeyExtension().

template<class OwnerClass>
EventListener* OMK::Inp::GenericKeyExtension< OwnerClass >::_eventListenerRelease [protected]

The event listener which receives the key release event.

It is created in the loadExtensionParameters method, it is a EventListenerCallBack which is associated with the callBackFct method.

Definition at line 147 of file OMKGenericKeyExtension.h.

Referenced by OMK::Inp::PlusMinusExtension< T >::action(), OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::loadExtensionParameters(), and OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::~GenericKeyExtension().

template<class OwnerClass>
const std::string OMK::Inp::GenericKeyExtension< OwnerClass >::_defaultKey [protected]

The default key.

Definition at line 149 of file OMKGenericKeyExtension.h.

Referenced by OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::loadExtensionParameters().


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007