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 OMKInputConnectionEventListenerHEADER 00019 #define OMKInputConnectionEventListenerHEADER 00020 00021 #include "OMKEventListener.h" 00022 #include "OMKTracer.h" 00023 00024 namespace OMK 00025 { 00026 00027 template< typename T > class Input ; 00035 template< typename T > 00036 class InputConnectionEventListener : public EventListener 00037 { 00038 public: 00043 InputConnectionEventListener( SimulatedObject & owner , 00044 Input< T > * associatedInput ) ; 00045 00047 virtual ~InputConnectionEventListener() ; 00048 00050 virtual void registerEvents() ; 00051 00053 virtual bool processEvent( Event * event ) ; 00054 00055 protected: 00057 Input< T > * _associatedInput ; 00058 }; 00059 00060 00061 //----------------------------------------------------------------------------- 00062 //----------------------------------------------------------------------------- 00063 00064 00065 template< typename T > 00066 InputConnectionEventListener< T >::InputConnectionEventListener( 00067 SimulatedObject & owner, 00068 Input<T> * associatedInput ) 00069 : EventListener( owner ), 00070 _associatedInput( associatedInput ) 00071 { 00072 _owner.addEventListener( *this ) ; 00073 } 00074 00075 //----------------------------------------------------------------------------- 00076 00077 template< typename T > 00078 InputConnectionEventListener<T>::~InputConnectionEventListener() 00079 { 00080 } 00081 00082 //----------------------------------------------------------------------------- 00083 00084 template< typename T > 00085 void InputConnectionEventListener<T>::registerEvents() 00086 { 00087 _owner.registerEventListenerForEvent( 00088 *this, _associatedInput->getConnectionEventId() ) ; 00089 _owner.registerEventListenerForEvent( 00090 *this, _associatedInput->getConnectionToControlParameterEventId() ) ; 00091 } 00092 00093 //----------------------------------------------------------------------------- 00094 00095 template< typename T > 00096 bool InputConnectionEventListener<T>::processEvent( Event * event ) 00097 { 00098 ValuedEvent< Name > * realEvent = 00099 dynamic_cast< ValuedEvent< Name > *>( event ) ; 00100 OMASSERT( realEvent != 0 ) ; 00101 if( realEvent->eventId == _associatedInput->getConnectionEventId() ) 00102 { 00103 _associatedInput->connect( realEvent->sender, realEvent->value ) ; 00104 } 00105 else 00106 { 00107 _associatedInput->connectToControlParameter( realEvent->sender, 00108 realEvent->value ) ; 00109 } 00110 return true ; 00111 } 00112 00113 //----------------------------------------------------------------------------- 00114 00115 } // namespace OMK 00116 00117 #endif
Documentation generated on Mon Jun 9 11:45:56 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |