OMKControlTakeOverPrm.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 "OMKControlTakeOverPrm.h"
00024 #include "OMKSimulatedObject.h"
00025 #include "OMKParametersAccessor.inl"
00026 #include <vector>
00027 #include <string>
00028 #include <iostream>
00029 using namespace OMK ;
00030 using namespace OMK::Type ;
00031 
00032 //========================================================================
00033 // AccessGroup
00034 //========================================================================
00035 
00036 //========================================================================
00037 // Default constructor
00038 AccessGroup::AccessGroup()
00039 : _groupName( "" ),
00040   _level( 0 )
00041 {
00042 }
00043 
00044 //------------------------------------------------------------------------
00045 // Copy constructor
00046 AccessGroup::AccessGroup( const AccessGroup& ref )
00047 {
00048   _copy( ref ) ;
00049 }
00050 
00051 //------------------------------------------------------------------------
00052 // Constructor with the parameters
00053 AccessGroup::AccessGroup( const Name& groupName,
00054                           int level )
00055 : _groupName( groupName ),
00056   _level( level )
00057 {
00058 }
00059 
00060 //------------------------------------------------------------------------
00061 // Destructor
00062 AccessGroup::~AccessGroup()
00063 {
00064 }
00065 
00066 //------------------------------------------------------------------------
00067 // copy operator
00068 AccessGroup& AccessGroup::operator = ( const AccessGroup& ref )
00069 {
00070   if ( this != &ref )
00071   {
00072     _copy( ref ) ;
00073   }
00074   return *this ;
00075 }
00076 
00077 //------------------------------------------------------------------------
00078 // Protected copy methods
00079 void AccessGroup::_copy( const AccessGroup& ref )
00080 {
00081   _groupName = ref._groupName ; 
00082   _level = ref._level ; 
00083 }
00084 
00085 //========================================================================
00086 namespace OMK
00087 {
00088 namespace Type
00089 {
00090 //------------------------------------------------------------------------
00091 // != operator
00092 bool operator != ( const AccessGroup& a0, const AccessGroup& a1 )
00093 {
00094   return a0._groupName != a1._groupName
00095       || a0._level != a1._level ;
00096 }
00097 
00098 } //namespace OMK
00099 } //namespace Type
00100 //========================================================================
00101 
00102 //------------------------------------------------------------------------
00103 // insert in stream
00104 std::ostream& operator << ( std::ostream& out, const OMK::Type::AccessGroup& a )
00105 {
00106   out << a._groupName << " "
00107       << a._level << " "
00108       << " " ;
00109   return out ;
00110 }
00111 
00112 //------------------------------------------------------------------------
00113 // extract from a 
00114 std::istream& operator >> ( std::istream& in, OMK::Type::AccessGroup& a )
00115 {
00116   in >> a._groupName
00117      >> a._level ;
00118   return in ;
00119 }
00120 
00121 //------------------------------------------------------------------------
00122 // insert in stream
00123 OMK::OutgoingSynchronisationMessage& operator << ( OMK::OutgoingSynchronisationMessage& out, const OMK::Type::AccessGroup& a )
00124 {
00125   out << a._groupName
00126       << a._level ;
00127   return out ;
00128 }
00129 
00130 //------------------------------------------------------------------------
00131 // extract from a 
00132 OMK::IncomingSynchronisationMessage& operator >> ( OMK::IncomingSynchronisationMessage& in, OMK::Type::AccessGroup& a )
00133 {
00134   in >> a._groupName
00135      >> a._level ;
00136   return in ;
00137 }
00138 
00139 //========================================================================
00140 
00141 //========================================================================
00142 // ParametersAccessor specific implementation for OMK::Type::AccessGroup.
00143 template<>
00144 bool OMK::ParametersAccessor::getValue< OMK::Type::AccessGroup >
00145                     ( const ConfigurationParameterDescriptor * nodeValue, 
00146                       OMK::Type::AccessGroup& value, 
00147                       std::string& errorStr )
00148 {
00149   bool ok = true ;
00150   const OMK::MultipleConfigurationParameter *tmpNode = 
00151     dynamic_cast< const OMK::MultipleConfigurationParameter * >( nodeValue ) ;
00152   ok = ok && tmpNode ;
00153   if( ok ) 
00154   {
00155     bool named = tmpNode && !tmpNode->getNameOfSubDescriptor( 0 ).empty() ;
00156     ok = ( named || 2 <= tmpNode->getNumberOfSubItems() ) ;
00157     if ( !ok && errorStr.empty() )
00158     {
00159       errorStr = "Bad format of AccessGroup which needs 2 arguments" ;
00160     }
00161 
00162     // "GroupName" parameter (member "_groupName")
00163     const OMK::ConfigurationParameterDescriptor *dataNode = !ok ? 0 :
00164       ( named ?
00165         tmpNode->getSubDescriptorByName( "GroupName" ) :
00166         tmpNode->getSubDescriptorByPosition( 0 ) ) ;
00167     ok = ok 
00168       && ( ( !dataNode && named ) // optional parameter if named
00169         || getValue( dataNode, value._groupName, errorStr ) ) ;
00170 
00171     // "Level" parameter (member "_level")
00172     dataNode = !ok ? 0 :
00173       ( named ?
00174         tmpNode->getSubDescriptorByName( "Level" ) :
00175         tmpNode->getSubDescriptorByPosition( 1 ) ) ;
00176     ok = ok 
00177       && ( ( !dataNode && named ) // optional parameter if named
00178         || getValue( dataNode, value._level, errorStr ) ) ;
00179   }
00180   return ok ;
00181 }
00182 //========================================================================
00183 
00184 
00185 //========================================================================
00186 // TwoIdsPrm
00187 //========================================================================
00188 
00189 //========================================================================
00190 // Default constructor
00191 TwoIdsPrm::TwoIdsPrm()
00192 : _id( OMK::Name() ),
00193   _secondId( OMK::Name() )
00194 {
00195 }
00196 
00197 //------------------------------------------------------------------------
00198 // Copy constructor
00199 TwoIdsPrm::TwoIdsPrm( const TwoIdsPrm& ref )
00200 {
00201   _copy( ref ) ;
00202 }
00203 
00204 //------------------------------------------------------------------------
00205 // Constructor with the parameters
00206 TwoIdsPrm::TwoIdsPrm( OMK::Name id,
00207                       OMK::Name secondId )
00208 : _id( id ),
00209   _secondId( secondId )
00210 {
00211 }
00212 
00213 //------------------------------------------------------------------------
00214 // Destructor
00215 TwoIdsPrm::~TwoIdsPrm()
00216 {
00217 }
00218 
00219 //------------------------------------------------------------------------
00220 // copy operator
00221 TwoIdsPrm& TwoIdsPrm::operator = ( const TwoIdsPrm& ref )
00222 {
00223   if ( this != &ref )
00224   {
00225     _copy( ref ) ;
00226   }
00227   return *this ;
00228 }
00229 
00230 //------------------------------------------------------------------------
00231 // Protected copy methods
00232 void TwoIdsPrm::_copy( const TwoIdsPrm& ref )
00233 {
00234   _id = ref._id ; 
00235   _secondId = ref._secondId ; 
00236 }
00237 
00238 //========================================================================
00239 namespace OMK
00240 {
00241 namespace Type
00242 {
00243 //------------------------------------------------------------------------
00244 // != operator
00245 bool operator != ( const TwoIdsPrm& t0, const TwoIdsPrm& t1 )
00246 {
00247   return t0._id != t1._id
00248       || t0._secondId != t1._secondId ;
00249 }
00250 
00251 } //namespace OMK
00252 } //namespace Type
00253 //========================================================================
00254 
00255 //------------------------------------------------------------------------
00256 // insert in stream
00257 std::ostream& operator << ( std::ostream& out, const OMK::Type::TwoIdsPrm& t )
00258 {
00259   out << t._id << " "
00260       << t._secondId << " "
00261       << " " ;
00262   return out ;
00263 }
00264 
00265 //------------------------------------------------------------------------
00266 // extract from a 
00267 std::istream& operator >> ( std::istream& in, OMK::Type::TwoIdsPrm& t )
00268 {
00269   in >> t._id
00270      >> t._secondId ;
00271   return in ;
00272 }
00273 
00274 //------------------------------------------------------------------------
00275 // insert in stream
00276 OMK::OutgoingSynchronisationMessage& operator << ( OMK::OutgoingSynchronisationMessage& out, const OMK::Type::TwoIdsPrm& t )
00277 {
00278   out << t._id
00279       << t._secondId ;
00280   return out ;
00281 }
00282 
00283 //------------------------------------------------------------------------
00284 // extract from a 
00285 OMK::IncomingSynchronisationMessage& operator >> ( OMK::IncomingSynchronisationMessage& in, OMK::Type::TwoIdsPrm& t )
00286 {
00287   in >> t._id
00288      >> t._secondId ;
00289   return in ;
00290 }
00291 
00292 //========================================================================
00293 
00294 //========================================================================
00295 // ParametersAccessor specific implementation for OMK::Type::TwoIdsPrm.
00296 template<>
00297 bool OMK::ParametersAccessor::getValue< OMK::Type::TwoIdsPrm >
00298                     ( const ConfigurationParameterDescriptor * nodeValue, 
00299                       OMK::Type::TwoIdsPrm& value, 
00300                       std::string& errorStr )
00301 {
00302   bool ok = true ;
00303   const OMK::MultipleConfigurationParameter *tmpNode = 
00304     dynamic_cast< const OMK::MultipleConfigurationParameter * >( nodeValue ) ;
00305   ok = ok && tmpNode ;
00306   if( ok ) 
00307   {
00308     bool named = tmpNode && !tmpNode->getNameOfSubDescriptor( 0 ).empty() ;
00309     ok = ( named || 2 <= tmpNode->getNumberOfSubItems() ) ;
00310     if ( !ok && errorStr.empty() )
00311     {
00312       errorStr = "Bad format of TwoIdsPrm which needs 2 arguments" ;
00313     }
00314 
00315     // "Id" parameter (member "_id")
00316     const OMK::ConfigurationParameterDescriptor *dataNode = !ok ? 0 :
00317       ( named ?
00318         tmpNode->getSubDescriptorByName( "Id" ) :
00319         tmpNode->getSubDescriptorByPosition( 0 ) ) ;
00320     ok = ok 
00321       && ( ( !dataNode && named ) // optional parameter if named
00322         || getValue( dataNode, value._id, errorStr ) ) ;
00323 
00324     // "SecondId" parameter (member "_secondId")
00325     dataNode = !ok ? 0 :
00326       ( named ?
00327         tmpNode->getSubDescriptorByName( "SecondId" ) :
00328         tmpNode->getSubDescriptorByPosition( 1 ) ) ;
00329     ok = ok 
00330       && ( ( !dataNode && named ) // optional parameter if named
00331         || getValue( dataNode, value._secondId, errorStr ) ) ;
00332   }
00333   return ok ;
00334 }
00335 //========================================================================
00336 
00337 
00338 
00339 //========================================================================
00340 // ControlTakeOverPrm
00341 //========================================================================
00342 
00343 //========================================================================
00344 // Default constructor
00345 ControlTakeOverPrm::ControlTakeOverPrm()
00346 : OMK::Type::TwoIdsPrm(),
00347   _accessGroup()
00348 {
00349 }
00350 
00351 //------------------------------------------------------------------------
00352 // Copy constructor
00353 ControlTakeOverPrm::ControlTakeOverPrm( const ControlTakeOverPrm& ref )
00354 : OMK::Type::TwoIdsPrm(),
00355   _accessGroup()
00356 {
00357   _copy( ref ) ;
00358 }
00359 
00360 //------------------------------------------------------------------------
00361 // Constructor with the parameters
00362 ControlTakeOverPrm::ControlTakeOverPrm( const Name& id, const Name& secondId )
00363 : OMK::Type::TwoIdsPrm( id, secondId ),
00364   _accessGroup()
00365 {
00366 }
00367 
00368 //------------------------------------------------------------------------
00369 // Constructor with the parameters
00370 ControlTakeOverPrm::ControlTakeOverPrm( const Name& id, const Name& secondId,
00371                                         const AccessGroupLevel& accessGroup )
00372 : OMK::Type::TwoIdsPrm( id, secondId ),
00373   _accessGroup( accessGroup )
00374 {
00375 }
00376 
00377 //------------------------------------------------------------------------
00378 // Destructor
00379 ControlTakeOverPrm::~ControlTakeOverPrm()
00380 {
00381 }
00382 
00383 //------------------------------------------------------------------------
00384 // copy operator
00385 ControlTakeOverPrm& ControlTakeOverPrm::operator = ( const ControlTakeOverPrm& ref )
00386 {
00387   if ( this != &ref )
00388   {
00389     _copy( ref ) ;
00390   }
00391   return *this ;
00392 }
00393 
00394 //------------------------------------------------------------------------
00395 // Protected copy methods
00396 void ControlTakeOverPrm::_copy( const ControlTakeOverPrm& ref )
00397 {
00398   OMK::Type::TwoIdsPrm::_copy( ref ) ;
00399   _accessGroup = ref._accessGroup ; 
00400 }
00401 
00402 //========================================================================
00403 namespace OMK
00404 {
00405 namespace Type
00406 {
00407 //------------------------------------------------------------------------
00408 // != operator
00409 bool operator != ( const ControlTakeOverPrm& c0, const ControlTakeOverPrm& c1 )
00410 {
00411   return (OMK::Type::TwoIdsPrm)c0 != (OMK::Type::TwoIdsPrm)c1
00412       || c0._accessGroup != c1._accessGroup ;
00413 }
00414 
00415 } //namespace OMK
00416 } //namespace Type
00417 //========================================================================
00418 
00419 //------------------------------------------------------------------------
00420 // insert in stream
00421 std::ostream& operator << ( std::ostream& out, const OMK::Type::ControlTakeOverPrm& c )
00422 {
00423   out << (OMK::Type::TwoIdsPrm)c
00424       << c._accessGroup << " "
00425       << " " ;
00426   return out ;
00427 }
00428 
00429 //------------------------------------------------------------------------
00430 // extract from a 
00431 std::istream& operator >> ( std::istream& in, OMK::Type::ControlTakeOverPrm& c )
00432 {
00433   in >> (OMK::Type::TwoIdsPrm&)c
00434      >> c._accessGroup ;
00435   return in ;
00436 }
00437 
00438 //------------------------------------------------------------------------
00439 // insert in stream
00440 OMK::OutgoingSynchronisationMessage& operator << ( OMK::OutgoingSynchronisationMessage& out, const OMK::Type::ControlTakeOverPrm& c )
00441 {
00442   out << (OMK::Type::TwoIdsPrm)c
00443       << c._accessGroup ;
00444   return out ;
00445 }
00446 
00447 //------------------------------------------------------------------------
00448 // extract from a 
00449 OMK::IncomingSynchronisationMessage& operator >> ( OMK::IncomingSynchronisationMessage& in, OMK::Type::ControlTakeOverPrm& c )
00450 {
00451   in >> (OMK::Type::TwoIdsPrm&)c
00452      >> c._accessGroup ;
00453   return in ;
00454 }
00455 
00456 //========================================================================
00457 
00458 //========================================================================
00459 // ParametersAccessor specific implementation for OMK::Type::ControlTakeOverPrm.
00460 template<>
00461 bool OMK::ParametersAccessor::getValue< OMK::Type::ControlTakeOverPrm >
00462                     ( const ConfigurationParameterDescriptor * nodeValue, 
00463                       OMK::Type::ControlTakeOverPrm& value, 
00464                       std::string& errorStr )
00465 {
00466   bool ok = OMK::ParametersAccessor::getValue< OMK::Type::TwoIdsPrm >( nodeValue, value, errorStr ) ;
00467   const OMK::MultipleConfigurationParameter *tmpNode = 
00468     dynamic_cast< const OMK::MultipleConfigurationParameter * >( nodeValue ) ;
00469   ok = ok && tmpNode ;
00470   if( ok ) 
00471   {
00472     bool named = tmpNode && !tmpNode->getNameOfSubDescriptor( 0 ).empty() ;
00473     ok = ( named || 3 <= tmpNode->getNumberOfSubItems() ) ;
00474     if ( !ok && errorStr.empty() )
00475     {
00476       errorStr = "Bad format of ControlTakeOverPrm which needs 3 arguments" ;
00477     }
00478 
00479     // "AccessGroup" parameter (member "_accessGroup")
00480     const OMK::ConfigurationParameterDescriptor *dataNode = !ok ? 0 :
00481       ( named ?
00482         tmpNode->getSubDescriptorByName( "AccessGroup" ) :
00483         tmpNode->getSubDescriptorByPosition( 2 ) ) ;
00484     ok = ok 
00485       && ( ( !dataNode && named ) // optional parameter if named
00486         || getValue( dataNode, value._accessGroup, errorStr ) ) ;
00487   }
00488   return ok ;
00489 }

logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007