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 "OMKAddInputKeyPrm.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::Inp ; 00033 using namespace OMK::Type ; 00034 //======================================================================== 00035 // Default constructor 00036 AddInputKeyPrm::AddInputKeyPrm() 00037 : Base(), 00038 _key( "" ), 00039 _listeningObjectId() 00040 { 00041 } 00042 00043 //======================================================================== 00044 // Copy constructor 00045 AddInputKeyPrm::AddInputKeyPrm( const AddInputKeyPrm& ref ) 00046 : Base() 00047 { 00048 _copy( ref ) ; 00049 } 00050 00051 //======================================================================== 00052 // Constructor with the parameters 00053 AddInputKeyPrm::AddInputKeyPrm( const std::string& key, 00054 const Name& listeningObjectId ) 00055 : Base(), 00056 _key( key ), 00057 _listeningObjectId( listeningObjectId ) 00058 { 00059 } 00060 00061 //======================================================================== 00062 // Destructor 00063 AddInputKeyPrm::~AddInputKeyPrm() 00064 { 00065 } 00066 00067 //======================================================================== 00068 // Default values for parameters 00069 void AddInputKeyPrm::resetDefaultValues() 00070 { 00071 //=== Reset default parameters 00072 _key = "" ; 00073 } 00074 00075 //======================================================================== 00076 // Configuration parameters loader 00077 bool AddInputKeyPrm::loadParameters( const ConfigurationParameterDescriptor * node, 00078 const std::string& prefix, 00079 SimulatedObject* p ) 00080 { 00081 resetDefaultValues() ; 00082 return innerParametersLoader( node, prefix, p ); 00083 } 00084 00085 //======================================================================== 00086 // Configuration parameters loader 00087 bool AddInputKeyPrm::innerParametersLoader( const ConfigurationParameterDescriptor * node, const std::string& prefix, SimulatedObject* p ) 00088 { 00089 // Tests the configuration parameter node 00090 if( !node ) 00091 { // No valid node => display error message and return false 00092 std::ostringstream txt ; 00093 txt << "Error in AddInputKeyPrm::innerParametersLoader"; 00094 if( p ) txt << " for " << OMK::debugMsg( p ) ; 00095 txt << std::endl << ">>> :-( Invalid node" << std::endl ; 00096 OMERROR( txt.str() ) ; 00097 return false ; 00098 } 00099 // return value 00100 bool ok = true ; 00101 00102 //=== The needed parameters => tested 00103 // Load the value of Key 00104 ok = ParametersAccessor::get( node, prefix + "Key", _key, p ) && ok ; 00105 // Load the value of ListeningObjectId 00106 ok = ParametersAccessor::get( node, prefix + "ObjectName", _listeningObjectId, p ) && ok ; 00107 00108 return ok ; 00109 } 00110 00111 00112 //======================================================================== 00113 // != operator 00114 bool AddInputKeyPrm::operator != ( const AddInputKeyPrm& ref ) const 00115 { 00116 return _key != ref.getKey() 00117 || _listeningObjectId != ref.getListeningObjectId() ; 00118 } 00119 00120 //======================================================================== 00121 // copy operator 00122 AddInputKeyPrm& AddInputKeyPrm::operator = ( const AddInputKeyPrm& ref ) 00123 { 00124 if ( this != &ref ) 00125 { 00126 _copy( ref ) ; 00127 } 00128 return *this ; 00129 } 00130 00131 //======================================================================== 00132 // insert in stream 00133 void AddInputKeyPrm::insertInStream( std::ostream& out ) const 00134 { 00135 out << getKey() << " " 00136 << getListeningObjectId() << " " 00137 << " " ; 00138 } 00139 00140 //======================================================================== 00141 // extract from a stream 00142 void AddInputKeyPrm::extract( std::istream& in ) 00143 { 00144 in >> _key 00145 >> _listeningObjectId ; 00146 } 00147 00148 //======================================================================== 00149 // pack 00150 void AddInputKeyPrm::pack( OutgoingSynchronisationMessage& out ) const 00151 { 00152 out << getKey() 00153 << getListeningObjectId() ; 00154 } 00155 00156 //======================================================================== 00157 // unpack 00158 void AddInputKeyPrm::unpack( IncomingSynchronisationMessage& in ) 00159 { 00160 in >> _key 00161 >> _listeningObjectId ; 00162 } 00163 00164 //======================================================================== 00165 // create a default polator 00166 OMK::Type::PolatorNT* AddInputKeyPrm::createPolator() 00167 { 00168 return new OMK::Type::Polator<AddInputKeyPrm>() ; 00169 } 00170 00171 //======================================================================== 00172 // Protected copy methods 00173 void AddInputKeyPrm::_copy( const AddInputKeyPrm& ref ) 00174 { 00175 _key = ref.getKey() ; 00176 _listeningObjectId = ref.getListeningObjectId() ; 00177 } 00178 00179 //======================================================================== 00180
Documentation generated on Mon Jun 9 11:45:55 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |