OMKAnimatorT.h

Go to the documentation of this file.
00001 /************************************************************************/
00002 /* This file is part of openMask(c) INRIA, CNRS, Universite de Rennes 1 */
00003 /* 1993-2002, thereinafter the Software                                 */
00004 /*                                                                      */
00005 /* The Software has been developped within the Siames Project.          */
00006 /* INRIA, the University of Rennes 1 and CNRS jointly hold intellectual */
00007 /* property rights                                                      */
00008 /*                                                                      */
00009 /* The Software has been registered with the Agence pour la Protection  */
00010 /* des Programmes (APP) under registration number                       */
00011 /* IDDN.FR.001.510008.00.S.P.2001.000.41200                             */
00012 /*                                                                      */
00013 /* This file may be distributed under the terms of the Q Public License */
00014 /* version 1.0 as defined by Trolltech AS of Norway and appearing in    */
00015 /* the file LICENSE.QPL included in the packaging of this file.         */
00016 /*                                                                      */
00017 /* Licensees holding valid specific licenses issued by INRIA, CNRS or   */
00018 /* Universite Rennes 1 for the software may use this file in            */
00019 /* acordance with that specific license                                 */
00020 /************************************************************************/
00021 #ifndef OMK_VIS_ANIMATORT_H
00022 #define OMK_VIS_ANIMATORT_H
00023 
00024 #include "OMKParametersAccessor.inl"
00025 #include "OMKVisBase.h"
00026 #include "OMKAnimator.h"
00027 #include "OMKAnimatorInputPlugT.h"
00028 #include "OMKAnimatorEventPlugT.h"
00029 #include "OMKVisualObject.h"
00030 
00031 namespace OMK  
00032 {
00033 namespace Vis 
00034 {
00048 template< typename T >
00049 class AnimatorT : public Animator
00050 {
00051 public:
00052 
00054 
00055 
00056   virtual ~AnimatorT() ;
00058 
00059 protected:
00060 
00062 
00063 
00064   AnimatorT( VisualObject& visualObject, const Name& id, AnimatorPlugT<T>* plug )  ;
00065 
00067   AnimatorT( VisualObject& visualObject, const Name& id, const ConfigurationParameterDescriptor& node ) ;
00069 
00071 
00072 
00073 
00074 
00075 
00076   virtual void selfProcessVis( void ) ;
00077 
00082   virtual void selfProcessVis( const T& value ) = 0 ;
00084 
00086   AnimatorPlugT<T>* _plugValue ;
00087 } ;
00088 
00089 //-------------------------------------------------------------------------
00090 // constructor
00091 //-------------------------------------------------------------------------
00092 template< typename T > 
00093 AnimatorT<T>::AnimatorT( VisualObject& visualObject, const Name& id, AnimatorPlugT<T>* plug ) 
00094 : Animator( visualObject, id ),
00095   _plugValue( plug ) 
00096 {
00097   OMASSERT( _plugValue && "must be a well typed plug" ) ;
00098 }
00099 
00100 //-------------------------------------------------------------------------
00101 // constructor
00102 //-------------------------------------------------------------------------
00103 template< typename T >
00104 AnimatorT<T>::AnimatorT( VisualObject& visualObject, const Name& id, const ConfigurationParameterDescriptor& node ) 
00105 : Animator( visualObject, id ),
00106   _plugValue( 0 )
00107 {
00108   std::pair< std::string, std::string > inputPrm ;
00109   if( ParametersAccessor::get( &node, "ConnectTo", inputPrm ) )
00110   { 
00111     // found parameters for input plug => retrieve the input and create the plug
00112     Input< T >* input( visualObject.touchVis().template createInput< T >( inputPrm.first, inputPrm.second ) ) ;
00113     if( input )
00114     {
00115       AnimatorInputPlugT< T >* inputPlug( new AnimatorInputPlugT< T >( input ) ) ;
00116       _plugUpdate = inputPlug ;
00117       _plugValue  = inputPlug ;
00118     }
00119     OMASSERT( ( _plugUpdate != NULL ) && "Must be a valid pointer to a new plug" ) ;
00120     OMASSERT( ( _plugValue != NULL ) && "Cannot be null, must be a valid plug" ) ;
00121   }
00122   else
00123   {
00124     // If configFile is not providing the EventId, EventId will be the id
00125     std::string eventId = id.getString() ;
00126     ParametersAccessor::get( &node, "ListenedEvent", eventId ) ; 
00127     AnimatorEventPlugT<T>* eventPlug( new AnimatorEventPlugT<T>( visualObject.touchVis(), EventIdentifier( eventId ) ) ) ;
00128     _plugUpdate = eventPlug ;
00129     _plugValue  = eventPlug ;
00130     std::string emitter ;
00131     ParametersAccessor::get( &node, "Emitter", emitter ) ;
00132     visualObject.touchVis().registerEventPlug( EventIdentifier( eventId ), emitter, eventPlug ) ;
00133   }
00134 }
00135 
00136 //-------------------------------------------------------------------------
00137 // destructor
00138 //-------------------------------------------------------------------------
00139 template< typename T >
00140 AnimatorT<T>::~AnimatorT()
00141 {
00142 }
00143 
00144 //-------------------------------------------------------------------------
00145 // selfProcessVis
00146 //-------------------------------------------------------------------------
00147 template< typename T >
00148 void AnimatorT<T>::selfProcessVis( void ) 
00149 {
00150   selfProcessVis( _plugValue->getTypedValue() ) ;
00151 }
00152 
00153 }// namespace Vis
00154 }// namespace OMK
00155 
00156 #endif //OMK_VIS_ANIMATORT_H

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007