OMKAddAnimatorPrm.cpp

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                 
00022 
00023 #include "OMKAddAnimatorPrm.h"
00024 #include "OMKSimulatedObject.h"
00025 #include "OMKParametersAccessor.inl"
00026 #include "OMKMultipleConfigurationParameter.h"
00027 #include <vector>
00028 #include <string>
00029 #include <iostream>
00030 
00031 using namespace OMK ;
00032 using namespace OMK::Type ;
00033 //========================================================================
00034 // Default constructor
00035 AddAnimatorPrm::AddAnimatorPrm()
00036 : Base(),
00037   _objectName() ,
00038   _classId(),
00039   _visualObjectName(),
00040   _visuName(),
00041   _configParam( 0 )
00042 {
00043 }
00044 
00045 //========================================================================
00046 // Copy constructor
00047 AddAnimatorPrm::AddAnimatorPrm( const AddAnimatorPrm& ref )
00048 : Base(),
00049 _configParam( 0 )
00050 {
00051   _copy( ref ) ;
00052 }
00053 
00054 //========================================================================
00055 // Constructor with the parameters
00056 AddAnimatorPrm::AddAnimatorPrm( const Name& objectName,
00057                                 const Name& classId,
00058                                 const Name& visualObjectName,
00059                                 const Name& VisuName,
00060                                 const ConfigurationParameterDescriptor* configParam )
00061 : Base(),
00062   _objectName( objectName ) ,
00063   _classId( classId ) ,
00064   _visualObjectName( visualObjectName ) ,
00065   _visuName( VisuName ) ,
00066   _configParam( configParam ? configParam->clone() : 0 ) 
00067 {
00068 }
00069 
00070 //========================================================================
00071 // Destructor
00072 AddAnimatorPrm::~AddAnimatorPrm()
00073 {
00074   delete _configParam ;
00075 }
00076 
00077 //========================================================================
00078 // Default values for parameters
00079 void AddAnimatorPrm::resetDefaultValues()
00080 {
00081   //=== Reset default parameters
00082   _classId = Name() ;
00083   _visualObjectName = Name() ;
00084   _visuName = Name() ;
00085   delete _configParam ;
00086   _configParam = 0 ;
00087 }
00088                 
00089 //========================================================================
00090 // Configuration parameters loader
00091 bool AddAnimatorPrm::loadParameters( const ConfigurationParameterDescriptor * node, 
00092                                const std::string& prefix,
00093                                SimulatedObject* p )
00094 {
00095   resetDefaultValues() ;
00096   return innerParametersLoader( node, prefix, p );
00097 }
00098 
00099 //========================================================================
00100 // Configuration parameters loader
00101 bool AddAnimatorPrm::innerParametersLoader( const ConfigurationParameterDescriptor * node, const std::string& prefix, SimulatedObject* p )
00102 {
00103   // Tests the configuration parameter node
00104   if( !node )
00105   { // No valid node => display error message and return false
00106     std::ostringstream txt ;
00107     txt << "Error in AddAnimatorPrm::innerParametersLoader";
00108     if( p ) txt << " for " << OMK::debugMsg( p ) ;
00109     txt << std::endl << ">>> :-( Invalid node" << std::endl ; 
00110     OMERROR( txt.str() ) ;
00111     return false ;
00112   }
00113   // return value
00114   bool ok = true ;
00115 
00116   //=== The optional parameters => no test
00117   // Load the value of VisuName
00118   ParametersAccessor::get( node, prefix + "VisuName", _visuName ) ;
00119   // Load the value of ObjectName
00120   ParametersAccessor::get( node, prefix + "ObjectName", _objectName ) ;
00121   // Load the value of ObjectName
00122   ParametersAccessor::get( node, prefix + "VisualObjectName", _visualObjectName ) ;
00123 
00124   //=== The needed parameters => tested
00125   // Load the value of ClassId
00126   ok = ParametersAccessor::get( node, prefix + "Class", _classId, p ) && ok ;
00127   // store the value of ConfigParam
00128   _configParam = node->clone() ;
00129 
00130   return ok ;
00131 }
00132                 
00133 
00134 //========================================================================
00135 // != operator
00136 bool AddAnimatorPrm::operator != ( const AddAnimatorPrm& ref ) const
00137 {
00138   return _objectName != ref.getObjectName()
00139       || _classId != ref.getClassId()
00140       || _visualObjectName != ref.getVisualObjectName()
00141       || _visuName != ref.getVisuName()
00142       || _configParam != ref.getConfigParam() ;
00143 }
00144 
00145 //========================================================================
00146 // copy operator
00147 AddAnimatorPrm& AddAnimatorPrm::operator = ( const AddAnimatorPrm& ref )
00148 {
00149   if ( this != &ref ) 
00150   {
00151     _copy( ref ) ;
00152   }
00153   return *this ;
00154 }  
00155 
00156 //========================================================================
00157 // insert in stream
00158 void AddAnimatorPrm::insertInStream( std::ostream& out ) const 
00159 {
00160   out << getObjectName() << " "
00161       << getClassId() << " "
00162       << getVisualObjectName() << " "
00163       << getVisuName() << " "
00164             << *getConfigParam() << " "
00165       << " " ;
00166 }
00167 
00168 //========================================================================
00169 // extract from a stream
00170 void AddAnimatorPrm::extract( std::istream& in ) 
00171 {
00172   in >> _objectName
00173      >> _classId
00174      >> _visualObjectName
00175      >> _visuName ;
00176   // At this step we must retrieve the configuration parameters
00177   // we assume that is a MultipleConfigurationParameter
00178   MultipleConfigurationParameter* configParamTmp = new MultipleConfigurationParameter ;
00179   in >> ( *configParamTmp ) ;
00180   delete _configParam ;
00181   _configParam = configParamTmp ;
00182 }
00183 
00184 //========================================================================
00185 // pack
00186 void AddAnimatorPrm::pack( OutgoingSynchronisationMessage& out ) const
00187 {
00188   out << getObjectName()
00189       << getClassId()
00190       << getVisualObjectName()
00191       << getVisuName()
00192           << *getConfigParam() ;
00193 }
00194 
00195 //========================================================================
00196 // unpack
00197 void AddAnimatorPrm::unpack( IncomingSynchronisationMessage& in ) 
00198 {
00199   in >> _objectName
00200      >> _classId
00201      >> _visualObjectName
00202      >> _visuName ;
00203   // At this step we must retrieve the configuration parameters
00204   // we assume that is a MultipleConfigurationParameter
00205   MultipleConfigurationParameter* configParamTmp = new MultipleConfigurationParameter ;
00206   in >> ( *configParamTmp ) ;
00207   delete _configParam ;
00208   _configParam = configParamTmp ;
00209 }
00210 
00211 //========================================================================
00212 // create a default polator
00213 PolatorNT* AddAnimatorPrm::createPolator() 
00214 {
00215   return new Polator<AddAnimatorPrm>() ;
00216 }
00217 
00218 //========================================================================
00219 // Protected copy methods
00220 void AddAnimatorPrm::_copy( const AddAnimatorPrm& ref )
00221 {
00222   _objectName = ref.getObjectName() ; 
00223   _classId = ref.getClassId() ; 
00224   _visualObjectName = ref.getVisualObjectName() ; 
00225   _visuName = ref.getVisuName() ; 
00226   delete _configParam ;
00227   _configParam = ref.getConfigParam() ? ref.getConfigParam()->clone() : 0 ; 
00228 }
00229 
00230 //========================================================================
00231 

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007