OMK::Iii::InteractorOutputT< PrmType, ModelType > Class Template Reference

#include <OMKInteractorOutputT.h>

Inheritance diagram for OMK::Iii::InteractorOutputT< PrmType, ModelType >:

Inheritance graph
[legend]
Collaboration diagram for OMK::Iii::InteractorOutputT< PrmType, ModelType >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::pair< Name, ModelType > IdAndValuePrm
 The type of the data to update or retrieve the attibute value.

Public Member Functions

 DECLARE_TYPE_EVENT_LISTENER (IdAndValuePrm, IdAndValue, EventTypeForAttributeT< ModelType >)
 The type of the event to update or retrieve the attibute value.
virtual ~InteractorOutputT ()

Protected Member Functions

 InteractorOutputT (const Name &id, const Name &attributeId, InteractorExtension *interactor, const Name &category, bool setByEvent)
virtual bool processSetValue (IdAndValueEvent *e)
 The call back method to process the update of the attribute value.

Protected Attributes

IAttributeBaseT< PrmType > * _attribute
 The attribute interface.
IdAndValueEventListener * _listener

Friends

class OMK::Iii::InteractorOutputCreatorT< InteractorOutputT >

Detailed Description

template<typename PrmType, typename ModelType>
class OMK::Iii::InteractorOutputT< PrmType, ModelType >

Definition at line 37 of file OMKInteractorOutputT.h.


Member Typedef Documentation

template<typename PrmType, typename ModelType>
typedef std::pair< Name, ModelType > OMK::Iii::InteractorOutputT< PrmType, ModelType >::IdAndValuePrm

The type of the data to update or retrieve the attibute value.

This is a pair in which the first item is an id and the second is the value.

See sendValue and fireValue.

Reimplemented from OMK::EventTypeForAttributeT< ModelType >.

Definition at line 45 of file OMKInteractorOutputT.h.


Constructor & Destructor Documentation

template<typename PrmType, typename ModelType>
OMK::Iii::InteractorOutputT< PrmType, ModelType >::InteractorOutputT ( const Name id,
const Name attributeId,
InteractorExtension interactor,
const Name category,
bool  setByEvent 
) [protected]

Definition at line 36 of file OMKInteractorOutputT.inl.

References OMK::Iii::InteractorOutputT< PrmType, ModelType >::_attribute, OMK::Iii::InteractorOutput::_interactor, OMK::Iii::InteractorOutputT< PrmType, ModelType >::_listener, OMK::EventId::CURRENT_VALUE, OMK::ExtensionT< SimulatedObjectType >::getOwner(), and OMASSERTM.

00039 : InteractorOutput( id, interactor, category, typeid( PrmType ).name() ),
00040   _attribute( interactor->getOwner()->getBaseAttribute< PrmType >( attributeId ) ),
00041   _listener( 0 )
00042 {
00043   OMASSERTM( _attribute, "The attribute \"" << attributeId << "\" cannot be found, wrong type or wrong id!" ) ;
00044   if( setByEvent )
00045   {
00046     _listener = new IdAndValueEventListener
00047         ( *_interactor->getOwner(), this, 
00048         ( typename IdAndValueEventListener::CallBackFct)&InteractorOutputT< PrmType, ModelType >::processSetValue,
00049         EventId::CURRENT_VALUE ) ;
00050   }
00051 }

template<typename PrmType, typename ModelType>
OMK::Iii::InteractorOutputT< PrmType, ModelType >::~InteractorOutputT (  )  [virtual]

Definition at line 54 of file OMKInteractorOutputT.inl.

References OMK::Iii::InteractorOutputT< PrmType, ModelType >::_listener.

00055 {
00056   delete _listener ;
00057 }


Member Function Documentation

template<typename PrmType, typename ModelType>
OMK::Iii::InteractorOutputT< PrmType, ModelType >::DECLARE_TYPE_EVENT_LISTENER ( IdAndValuePrm  ,
IdAndValue  ,
EventTypeForAttributeT< ModelType >   
)

The type of the event to update or retrieve the attibute value.

This is a pair encapsulated in a valued event in which the first item is an id and the second is the value.

See sendValue and fireValue.

Reimplemented from OMK::EventTypeForAttributeT< ModelType >.

template<typename PrmType, typename ModelType>
bool OMK::Iii::InteractorOutputT< PrmType, ModelType >::processSetValue ( IdAndValueEvent *  e  )  [protected, virtual]

The call back method to process the update of the attribute value.

Parameters:
[in] e The valued event which encapsulate the new value.
Returns:
true if processed.

Implements OMK::EventTypeForAttributeT< ModelType >.

Definition at line 60 of file OMKInteractorOutputT.inl.

References OMK::Iii::InteractorOutputT< PrmType, ModelType >::_attribute, OMK::Iii::InteractorOutput::_interactor, OMK::Iii::SessionPrm::getOutputId(), OMK::ExtensionT< SimulatedObjectType >::getOwner(), OMK::Iii::InteractorExtension::getSessionWith(), and OMK::EventId::NEW_VALUE_AVAILABLE.

00061 {
00062   bool ok = false ;
00063   const IdAndValuePrm& prm = e->value.getValue() ;
00064   SessionPrm* session = _interactor->getSessionWith( e->sender ) ;
00065   if( session 
00066    && session->getOutputId( prm.first ) == _attribute->getId() ) 
00067   {
00068     _attribute->set( prm.second ) ;
00069     _interactor->getOwner()->sendValuedEvent( e->sender, 
00070                                               EventId::NEW_VALUE_AVAILABLE, 
00071                                               Type::NewValueAvailableType( Type::NewValueAvailablePrm( prm.first, _attribute->getId() ) ) ) ;
00072     ok = true ;
00073   }
00074   return ok ;
00075 }


Friends And Related Function Documentation

template<typename PrmType, typename ModelType>
friend class OMK::Iii::InteractorOutputCreatorT< InteractorOutputT > [friend]

Definition at line 40 of file OMKInteractorOutputT.h.


Member Data Documentation

template<typename PrmType, typename ModelType>
IAttributeBaseT< PrmType >* OMK::Iii::InteractorOutputT< PrmType, ModelType >::_attribute [protected]

The attribute interface.

Definition at line 52 of file OMKInteractorOutputT.h.

Referenced by OMK::Iii::InteractorOutputT< PrmType, ModelType >::InteractorOutputT(), and OMK::Iii::InteractorOutputT< PrmType, ModelType >::processSetValue().

template<typename PrmType, typename ModelType>
IdAndValueEventListener* OMK::Iii::InteractorOutputT< PrmType, ModelType >::_listener [protected]

Definition at line 53 of file OMKInteractorOutputT.h.

Referenced by OMK::Iii::InteractorOutputT< PrmType, ModelType >::InteractorOutputT(), and OMK::Iii::InteractorOutputT< PrmType, ModelType >::~InteractorOutputT().


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007