OMK::Inp::KeyEmitterExtensionT< T, ModelType > Class Template Reference
[User inputs]

Extension to emit a valued event when a key is pressed. More...

#include <OMKKeyEmitterExtension.h>

Inheritance diagram for OMK::Inp::KeyEmitterExtensionT< T, ModelType >:

Inheritance graph
[legend]
Collaboration diagram for OMK::Inp::KeyEmitterExtensionT< T, ModelType >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~KeyEmitterExtensionT ()

Static Public Attributes

static Name OMK_CLASS_ID
 The id for the class in a configuration.
static const bool REGISTERED_IN_EXTENSION_FACTORY
 The registration in the extension factory.

Protected Member Functions

 KeyEmitterExtensionT (ExtensibleSimulatedObject *owner, const Name &id, bool registerExtension)
 Constructor.
virtual bool loadExtensionParameters (const ConfigurationParameterDescriptor *node)
 Configuration parameters loader of Extension.
virtual void action ()
 The overwritten method.

Friends

class OMK::ExtensionCreatorT< KeyEmitterExtensionT< T, ModelType > >
 The creator is a friend.

Detailed Description

template<typename T, typename ModelType>
class OMK::Inp::KeyEmitterExtensionT< T, ModelType >

Extension to emit a valued event when a key is pressed.

Date:
2007-03-14
Author:
Benoît Chanclou
Defines an extension which can be used with any object. This extension emits a valued event with a defined id when a key is pressed. Values are stored in a vector, each time the key is pressed the next value is emitted, at the end of the vector, the index restarts at the beginning. It can set the value of an attribute, see lthe second example below.

The creation is done dynamically through the following configuration:

visualisation
{
  Class OgreVis
  ...
  Extensions
  {
    plus
    {
            Class Key...EmitterExtension // ... must be replace according to the used type
      Key P // the key which is used to trigger the action
      VisuName visualisation // the default is "visualisation" needed to create the key listener
      EventName eventId // The id of the event or signal
      Values[ value1 value2 ... ] // the values for the signal or event
      Signal on/off // by default is set to on 
                    // on: the extension fire a signal, off: the extension emit a event
      Listeners [ obj1 obj2 ... ] // the list of the object which listen
    }
    ...
  }
}
or the following one specially designed to set a attribute by pressing the key. The example is a point which moves each time the P is pressed, useful to move a visual object, a camera or a target.
movingPoint
{
  Class SimplePoint
  Extensions
  {
    togglePosition
    {
      Class KeyTransformEmitterExtension
      Key P // the key which is used to trigger the action
      VisuName visuOgre // the default is "visualisation" needed to create the key listener
      AttributeId Position // The id of the attribute to set
      Values[ [[0 0 1]] [[1 0 0]] [[0 1 0]] ] // the values for the signal or event
    }
  }
}
In that case, the listener is the owner of the extension (movingPoint) and activateSetByEventOf of the attribute is called to allow its setting by event.

It is the same to write:

movingPoint
{
  Class SimplePoint
  Extensions
  {
    togglePosition
    {
      Class KeyTransformEmitterExtension
      Key P
      VisuName visuOgre
      EventName "current_value_of_Position" // \
      Signal off                            //  > replaced by AttributeId Position
      Listeners [ "movingPoint" ]           // /
      Values[ [[0 0 10]] [[10 0 0]] [[0 10 0]] ]
    }
  }
  UserParams
  {
    PositionSetByEventOf enable // Needed to activate the setting by event
  }
}

There is two ways to activate the action of the extension.

If you use this template class for your own data type you must register your extension with
namespace OMK
{
  namespace Inp
  {
typedef KeyEmitterExtensionT< MyType, OMK::Type::SimpleTypeT< MyType > > KeyMyTypeEmitterExtension ;
  }
}
REGISTER_TEMPLATE_EXTENSION_FACTORY( OMK::Inp::KeyStringEmitterExtension, "KeyStringEmitterExtension" ) ;

Definition at line 177 of file OMKKeyEmitterExtension.h.


Constructor & Destructor Documentation

template<typename T, typename ModelType>
OMK::Inp::KeyEmitterExtensionT< T, ModelType >::KeyEmitterExtensionT ( ExtensibleSimulatedObject owner,
const Name id,
bool  registerExtension 
) [inline, protected]

Constructor.

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

Definition at line 191 of file OMKKeyEmitterExtension.h.

00192     : GenericKeyExtension< ExtensibleSimulatedObject >( owner, id, registerExtension, "" ),
00193       ValuedEventSignalEmitterUtilT< T, ModelType >()
00194   {
00195   }

template<typename T, typename ModelType>
virtual OMK::Inp::KeyEmitterExtensionT< T, ModelType >::~KeyEmitterExtensionT (  )  [inline, virtual]

Definition at line 198 of file OMKKeyEmitterExtension.h.

00198 {}


Member Function Documentation

template<typename T, typename ModelType>
virtual bool OMK::Inp::KeyEmitterExtensionT< T, ModelType >::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::Inp::GenericKeyExtension< OwnerClass >.

Definition at line 200 of file OMKKeyEmitterExtension.h.

References OMK::ExtensionT< OwnerClass >::_owner, and OMK::ValuedEventSignalEmitterUtilT< T, ModelType >::loadParametersUtil().

00201   {
00202     return GenericKeyExtension< ExtensibleSimulatedObject >::loadExtensionParameters( node ) 
00203         && this->loadParametersUtil( _owner, node );
00204   }

template<typename T, typename ModelType>
virtual void OMK::Inp::KeyEmitterExtensionT< T, ModelType >::action (  )  [inline, protected, virtual]

The overwritten method.

Fire a signal or send an event according to the configuration.

Reimplemented from OMK::Inp::GenericKeyExtension< OwnerClass >.

Definition at line 207 of file OMKKeyEmitterExtension.h.

References OMK::ExtensionT< OwnerClass >::_owner, and OMK::ValuedEventSignalEmitterUtilT< T, ModelType >::sendUtil().

00208   {
00209     this->sendUtil( _owner ) ;
00210   }


Friends And Related Function Documentation

template<typename T, typename ModelType>
friend class OMK::ExtensionCreatorT< KeyEmitterExtensionT< T, ModelType > > [friend]

The creator is a friend.

Definition at line 183 of file OMKKeyEmitterExtension.h.


Member Data Documentation

template<typename T, typename ModelType>
Name OMK::Inp::KeyEmitterExtensionT< T, ModelType >::OMK_CLASS_ID [static]

The id for the class in a configuration.

Definition at line 185 of file OMKKeyEmitterExtension.h.

template<typename T, typename ModelType>
const bool OMK::Inp::KeyEmitterExtensionT< T, ModelType >::REGISTERED_IN_EXTENSION_FACTORY [static]

The registration in the extension factory.

Definition at line 187 of file OMKKeyEmitterExtension.h.


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007