OMK::Inp::InputListener Class Reference
[User inputs]

Input listener base class. More...

#include <OMKInputListener.h>

Inheritance diagram for OMK::Inp::InputListener:

Inheritance graph
[legend]
Collaboration diagram for OMK::Inp::InputListener:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~InputListener ()
const NamegetId () const

Static Public Member Functions

static OIS::KeyCode retrieveCode (const std::string &code)
 Get the OIS code from the name of a key (string).
static bool retrieveCodeFromConfig (const ConfigurationParameterDescriptor *node, const std::string &keyId, OIS::KeyCode &keyCode)
 Get the OIS code from a key id read in a configuration file.

Protected Member Functions

 InputListener (ExtensibleSimulatedObject *sender, const Name &id, const ConfigurationParameterDescriptor *node)
 The parameters of the constructor.
void sendEvent (const Name &receiver, const EventIdentifier &eventId)
template<typename UserType>
void sendValuedEvent (const Name &receiver, const EventIdentifier &eventId, const UserType &prm)

Protected Attributes

Name _id
ExtensibleSimulatedObject_sender

Detailed Description

Input listener base class.

Date:
2007-02-14
Author:
Benoît Chanclou
The ancestor of every input listeners. The Listeners are dynamically created by the factory.
A listener must have this class as ancestor and one of the OIS device listener class :

Definition at line 53 of file OMKInputListener.h.


Constructor & Destructor Documentation

InputListener::InputListener ( ExtensibleSimulatedObject sender,
const Name id,
const ConfigurationParameterDescriptor node 
) [protected]

The parameters of the constructor.

Definition at line 33 of file OMKInputListener.cpp.

References _sender, and OMASSERT.

00035   : _id( id ),
00036     _sender( sender )
00037 {
00038   OMASSERT( _sender && "Must be a valid pointer on a simulated object" ) ;
00039 }

InputListener::~InputListener (  )  [virtual]

Definition at line 41 of file OMKInputListener.cpp.

00042 {
00043 }


Member Function Documentation

OIS::KeyCode InputListener::retrieveCode ( const std::string &  code  )  [static]

Get the OIS code from the name of a key (string).

Definition at line 200 of file OMKInputListener.cpp.

References initCodes().

Referenced by retrieveCodeFromConfig().

00201 {
00202   // May be not thread safe
00203   static bool keyCodesRetrieved = false ;
00204   static std::map< std::string, OIS::KeyCode > s_keyCodes ;
00205   if( !keyCodesRetrieved )
00206   { // try to retreive key codes only once per OMK session
00207     keyCodesRetrieved = true ;
00208     initCodes( s_keyCodes ) ;
00209   }
00210 
00211   std::string str( code ) ;
00212   std::transform( str.begin(), str.end(), str.begin(), toupper );
00213   return s_keyCodes[ str ] ;
00214 }

bool InputListener::retrieveCodeFromConfig ( const ConfigurationParameterDescriptor node,
const std::string &  keyId,
OIS::KeyCode &  keyCode 
) [static]

Get the OIS code from a key id read in a configuration file.

Date:
2007-11-19
Author:
Laurent Aguerreche
Parameters:
[in] node The configuration node to find (or not) the keyId
[in] keyId The name of the key in the configuration node
[out] keyCode Returns the OIS code for the read keyId
This function tries to retreive the OIS code of a key id read in a given configuration file. If it fails then false is returned, otherwise true is returned and keyCode parameter is set to the OIS code of the read key id.

Definition at line 217 of file OMKInputListener.cpp.

References OMK::ParametersAccessor::get(), and retrieveCode().

00221 {
00222   std::string keyVal ;
00223   if( ParametersAccessor::get( node, keyId, keyVal ) )
00224   {
00225     OIS::KeyCode k( retrieveCode( keyVal ) ) ;
00226     if( k != OIS::KC_UNASSIGNED )
00227     {
00228       keyCode = k ;
00229       return true ;
00230     }
00231   }
00232   return false ;
00233 }

const Name & OMK::Inp::InputListener::getId (  )  const [inline]

Definition at line 89 of file OMKInputListener.h.

References _id.

00089 { return _id ; } 

void InputListener::sendEvent ( const Name receiver,
const EventIdentifier eventId 
) [protected]

Definition at line 45 of file OMKInputListener.cpp.

References _sender, and OMK::SimulatedObject::sendEvent().

Referenced by OMK::Inp::KeyListener::sendKeyEvent().

00046 {
00047   _sender->sendEvent( receiver, eventId ) ;
00048 }

template<typename UserType>
void OMK::Inp::InputListener::sendValuedEvent ( const Name receiver,
const EventIdentifier eventId,
const UserType &  prm 
) [inline, protected]

Definition at line 91 of file OMKInputListener.h.

References _sender, and OMK::SimulatedObject::sendValuedEvent().

00092 {
00093   _sender->sendValuedEvent( receiver, eventId, prm ) ;
00094 }


Member Data Documentation

Name OMK::Inp::InputListener::_id [protected]

Definition at line 86 of file OMKInputListener.h.

Referenced by getId().

ExtensibleSimulatedObject* OMK::Inp::InputListener::_sender [protected]

Definition at line 87 of file OMKInputListener.h.

Referenced by InputListener(), OMK::Inp::EscListener::keyPressed(), OMK::Inp::DistributedCameraOgreListener::postComputeParameters(), sendEvent(), and sendValuedEvent().


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007