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_OMKVisBase_H 00022 #define OMK_VIS_OMKVisBase_H 00023 00024 #include "OMKExtensibleSimulatedObject.h" 00025 #include "OMKInput.h" 00026 #include "OMKTracer.h" 00027 #include "OMKAddAnimatorPrm.h" 00028 namespace OMK 00029 { 00030 namespace Type 00031 { 00032 class AddVisualObjectPrm ; 00033 class AddAnimatorPrm ; 00034 } 00035 namespace Vis 00036 { 00037 class VisualObject ; 00038 class IAnimatorEventPlug ; 00039 class Animator ; 00048 class OMKVIS_API VisBase : public OMK::ExtensibleSimulatedObject 00049 { 00051 00052 public: 00053 00055 virtual ~VisBase() ; 00056 00057 protected: 00058 00060 VisBase( Controller& ctrl, const ObjectDescriptor& objectDescriptor ); 00062 00063 public: 00064 00066 00067 00068 00069 00070 00071 virtual bool processEvent( Event *e ) ; 00072 00074 virtual void init() ; 00076 virtual void finish() ; 00077 00078 00083 virtual void computeParameters() ; 00085 00087 00088 static EventIdentifier ADD_VISUAL_OBJECT_EVENT_ID ; 00089 static EventIdentifier DELETE_VISUAL_OBJECT_EVENT_ID ; 00090 static EventIdentifier ADD_ANIMATOR_EVENT_ID ; 00091 static EventIdentifier DELETE_ANIMATOR_EVENT_ID ; 00092 DECLARE_EVENT_LISTENER( OMK::Type::AddVisualObjectPrm, AddVisualObject, VisBase ) ; 00093 DECLARE_EVENT_LISTENER( Name, DeleteVisualObject, VisBase ) ; 00094 DECLARE_EVENT_LISTENER( OMK::Type::AddAnimatorPrm, AddAnimator, VisBase ) ; 00095 typedef std::pair< Name, Name > DeleteAnimatorPrm ; 00096 DECLARE_TYPE_EVENT_LISTENER( DeleteAnimatorPrm, DeleteAnimator, VisBase ) ; 00098 00102 template< typename T > 00103 Input<T>* createInput( const Name& object, const Name& output ) ; 00104 00115 void registerEventPlug( const EventIdentifier& eventId, 00116 const std::string& emitter, 00117 OMK::Vis::IAnimatorEventPlug* plug ) ; 00118 00122 void removeEventPlug( const EventIdentifier& eventId, OMK::Vis::IAnimatorEventPlug *plug ) ; 00123 00129 OMK::Vis::VisualObject* getVisualObject( const Name& id ) const ; 00130 00131 private: 00132 00133 bool processAddVisualObjectEvent( AddVisualObjectEvent *e ) ; 00134 bool processDeleteVisualObjectEvent( DeleteVisualObjectEvent *e ) ; 00135 bool processAddAnimatorEvent( AddAnimatorEvent *e ) ; 00136 bool processDeleteAnimatorEvent( DeleteAnimatorEvent *e ) ; 00137 void addNewVisualObject( OMK::Vis::VisualObject* visualObject ); 00138 void deleteVisualObject( const Name& id ) ; 00139 00140 typedef std::map< Name, std::vector< OMK::Type::AddAnimatorPrm > > AnimatorsToCreateMap ; 00141 typedef std::map< Name, OMK::Vis::VisualObject* > VisualObjectMap ; 00142 typedef std::list< OMK::Vis::IAnimatorEventPlug* > EventPlugList ; 00143 typedef std::map< EventIdentifier, EventPlugList > EventPlugMap ; 00144 00148 VisualObjectMap _visualObjects ; 00149 00151 EventPlugMap _eventIdAndPlug ; 00152 00153 AnimatorsToCreateMap _animatorsToCreate ; 00154 }; 00155 00156 template< typename T > 00157 inline Input< T >* VisBase::createInput( const Name& object, const Name& output ) 00158 { 00159 // Create a name for the input 00160 // :-( must use a temporary string because + operator doesn't work 00161 Name inputName( std::string( object.getCString() ) + output.getCString() ) ; 00162 // add an input, if it already defined => will display an error message and 00163 // returns the previous input 00164 Input< T >* input = &addInput< T >( inputName ) ; 00165 // connection to the output 00166 if( !input || !input->connect( object, output ) ) 00167 { // unable to connect => display a message 00168 OMTRACEID( OMK_DEBUG_VIS, "Error in VisBase::createInput() " 00169 << "for object \"" << getName().getCString() << "\" (class " 00170 << getObjectDescriptor().getClass().getCString() << ")" << std::endl 00171 << ">>> :-( Invalid connection parameters, unable to connect to the output \"" 00172 << output.getCString() << "\" of the object \"" << object.getCString() 00173 << "\"." ) ; 00174 input = 0 ; // will return null pointer if the input cannot be connected 00175 } 00176 // returns the result 00177 return input ; 00178 } 00179 00180 00181 }// namespace Vis 00182 }// namespace OMK 00183 00184 #endif // OMK_VIS_OMKVisBase_H
Documentation generated on Mon Jun 9 11:45:57 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |