OMKChangedControlParameterEventListener.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software
00003  * 
00004  * The Software has been developped within the Siames Project. 
00005  * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights
00006  * 
00007  * The Software has been registered with the Agence pour la Protection des
00008  * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200
00009  *
00010  * This file may be distributed under the terms of the Q Public License
00011  * version 1.0 as defined by Trolltech AS of Norway and appearing in the file
00012  * LICENSE.QPL included in the packaging of this file.
00013  *
00014  * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 
00015  * for the software may use this file in accordance with that specific license 
00016  *
00017  */
00018 #ifndef OMKChangedControlParameterEventListenerHEADER
00019 #define OMKChangedControlParameterEventListenerHEADER
00020 
00021 #include "OMKEventListener.h"
00022 namespace OMK
00023 {
00030 template <typename T>
00031 class OMK_API ChangedControlParameterEventListener : public EventListener
00032 {
00033 public:
00038    ChangedControlParameterEventListener(SimulatedObject & owner ,
00039                                           ControlParameter<T> & associatedControlParameter);
00040 
00042    virtual ~ChangedControlParameterEventListener() ;
00043 
00045    virtual void registerEvents() ;
00046 
00048    virtual bool processEvent (Event * event) ;
00049 
00050 protected:
00052    virtual void setControlParameter ( const T & newValue);
00053 
00055    ControlParameter<T> & _associatedControlParameter ;
00056 
00057 };
00058 
00059 
00060 
00061 template <typename T>
00062 ChangedControlParameterEventListener<T>::
00063 ChangedControlParameterEventListener(SimulatedObject & owner,
00064                                        ControlParameter<T> & associatedControlParameter) :
00065 EventListener ( owner ),
00066    _associatedControlParameter( associatedControlParameter )
00067 {
00068   _owner.addEventListener( *this ) ;     
00069 }
00070 
00071 
00072 
00073 template <typename T>
00074 ChangedControlParameterEventListener<T>::
00075 ~ChangedControlParameterEventListener()
00076 {
00077 
00078 }
00079 
00080 
00081 template <typename T>
00082 void ChangedControlParameterEventListener<T>::registerEvents() 
00083 {
00084    _owner.registerEventListenerForEvent ( *this, _associatedControlParameter.getAssociatedEventId() ) ;
00085 }
00086 
00087 
00088 template <typename T>
00089 bool ChangedControlParameterEventListener<T>::processEvent (Event * event) 
00090 {
00091    ValuedEvent<T > * realEvent = dynamic_cast<ValuedEvent<T > *>(event) ;
00092    assert ( realEvent != NULL );
00093    setControlParameter ( realEvent->value ) ;
00094    return true ;
00095 }
00096 
00097 
00098 template <typename T>
00099 void ChangedControlParameterEventListener<T>::setControlParameter (const T & value)
00100 {
00101    _associatedControlParameter.realSet ( value ) ;
00102 
00103 }
00104 
00105 } // namespace OMK 
00106 #endif

logo OpenMask

Documentation generated on Mon Jun 9 11:45:55 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007