00001 /* 00002 * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software 00003 * 00004 * The Software has been developped within the Siames Project. 00005 * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights 00006 * 00007 * The Software has been registered with the Agence pour la Protection des 00008 * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200 00009 * 00010 * This file may be distributed under the terms of the Q Public License 00011 * version 1.0 as defined by Trolltech AS of Norway and appearing in the file 00012 * LICENSE.QPL included in the packaging of this file. 00013 * 00014 * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 00015 * for the software may use this file in accordance with that specific license 00016 * 00017 */ 00018 #ifndef PsObjectDescriptorHEADER 00019 #define PsObjectDescriptorHEADER 00020 00021 #include "PsFlowable.h" 00022 #include "PsName.h" 00023 #include "PsNumericType.h" 00024 #include "PsnMutexLock.h" 00025 #include "pthread.h" 00026 #include <list> 00027 00028 class PsConfigurationParameterDescriptor ; 00029 class PsMultipleConfigurationParameter ; 00030 class PsSimulatedObject ; 00031 class PsnObjectHandle ; 00032 00040 class PsObjectDescriptor : public PsFlowable 00041 { 00042 public: 00046 explicit PsObjectDescriptor () ; 00047 00048 00050 PsObjectDescriptor (const PsObjectDescriptor &) ; 00051 00052 00056 PsObjectDescriptor( const PsName & objectName, 00057 const PsName & classId, 00058 PsMultipleConfigurationParameter * schedulingParameters, 00059 PsConfigurationParameterDescriptor * configurationParameters); 00060 00061 00065 PsObjectDescriptor( const PsName & objectName, 00066 const PsName & classId, 00067 const PsFrequency & frequency, 00068 PsConfigurationParameterDescriptor * configurationParameters); 00069 00070 00074 PsObjectDescriptor( const PsName & objectName, 00075 const PsName & classId, 00076 const PsName & process, 00077 const PsFrequency & frequency, 00078 PsConfigurationParameterDescriptor * configurationParameters); 00079 00080 00084 virtual ~PsObjectDescriptor(); 00085 00086 00089 virtual const PsName & getName () const ; 00090 00091 00094 virtual const PsName & getClass () const ; 00095 00096 00099 virtual const PsName & getProcess () const ; 00100 00101 00104 virtual const PsFrequency & getFrequency () const ; 00105 00106 00109 virtual const PsFrequency & getOriginalFrequency () const ; 00110 00111 00114 virtual const PsConfigurationParameterDescriptor * getConfigurationParameters() const ; 00115 00116 00119 virtual PsConfigurationParameterDescriptor * getConfigurationParameters() ; 00120 00121 00124 virtual const PsMultipleConfigurationParameter * getOriginalSchedulingParameters() const ; 00125 00126 00129 virtual const PsMultipleConfigurationParameter * getSchedulingParameters() const ; 00130 00131 00133 virtual void setProcess ( const PsName & newProcessName ) ; 00134 00135 00137 virtual void setFrequency ( const PsFrequency & newFrequency ) ; 00138 00139 00142 virtual void deleteCachedData() ; 00143 00145 virtual void unpack (PsIncomingSynchronisationMessage &) ; 00146 00148 virtual void pack (PsOutgoingSynchronisationMessage &) const ; 00149 00151 virtual void extract (istream & in) ; 00152 00154 virtual void insertInStream (ostream & out) const ; 00155 00158 00159 00162 virtual const PsObjectDescriptor * getFathersObjectDescriptor() const ; 00163 00164 00167 virtual PsObjectDescriptor * getFathersObjectDescriptor() ; 00168 00169 00171 typedef list<PsObjectDescriptor *> SonsContainerType ; 00172 00173 00175 virtual SonsContainerType & getSons() ; 00176 00177 00181 virtual const list<PsObjectDescriptor *> * getSons() const ; 00182 00183 00188 virtual list<const PsObjectDescriptor *> * getDescendants() const ; 00189 00190 00196 virtual list<const PsObjectDescriptor *> * getDescendants(list<const PsObjectDescriptor *> * resultList) const ; 00197 00198 00203 virtual list<PsObjectDescriptor *> * getDescendants() ; 00204 00205 00211 virtual list<PsObjectDescriptor *> * getDescendants(list<PsObjectDescriptor *> * resultList) ; 00212 00213 00218 virtual void addSon(PsObjectDescriptor * newSon ) ; 00219 00220 00224 virtual void removeSon(PsObjectDescriptor * oldSon ) ; 00225 00226 00231 template <typename Type> 00232 list<const PsObjectDescriptor *> * listSonsOfType ( ) const ; 00233 00234 00239 template <typename Type> 00240 list<const PsObjectDescriptor *> * listSonsOfType (list<const PsObjectDescriptor *> * resultList) const ; 00241 00242 00246 template <typename Type> 00247 list<const PsObjectDescriptor *> * listDescendantsOfType ( ) const ; 00248 00249 00255 template <typename Type> 00256 list<const PsObjectDescriptor *> * listDescendantsOfType (list<const PsObjectDescriptor *> * resultList ) const ; 00257 00258 00262 virtual const PsObjectDescriptor * findDescendantNamed(const PsName & name) const ; 00263 00264 00268 virtual PsObjectDescriptor * findDescendantNamed(const PsName & name) ; 00269 00270 00273 static void interpretConfigurationParameterAsListOfSons (SonsContainerType & listOfSons, 00274 PsMultipleConfigurationParameter * sonsDescription ) ; 00275 00278 static PsObjectDescriptor * 00279 interpretConfigurationParameterAsObjectDescription ( string objectName, 00280 PsMultipleConfigurationParameter * ) ; 00282 protected: 00286 friend class PsController ; 00287 00288 00291 friend class PsnObjectHandle ; 00292 00294 friend class PsSimulatedObject ; 00295 00306 virtual PsSimulatedObject * createDescribedObject( ) const ; 00307 00308 00309 virtual void setFathersDescription (PsObjectDescriptor * newFather ) ; 00310 00314 mutable PsSimulatedObject * _pointerToSimulatedObject ; 00315 00316 00317 00320 mutable bool _destroySimulatedObject ; 00321 00322 00326 void interpretSchedulingParameters (PsMultipleConfigurationParameter * schedulingParamters) ; 00327 00328 public: 00331 virtual PsMultipleConfigurationParameter * getSchedulingParameters(); 00332 00333 protected: 00335 PsName _objectName ; 00336 00338 PsName _classId ; 00339 00341 PsConfigurationParameterDescriptor * _configurationParameters ; 00342 00344 PsMultipleConfigurationParameter * _originalSchedulingParameters ; 00345 00347 PsMultipleConfigurationParameter * _schedulingParameters ; 00348 00350 PsObjectDescriptor * _fathersDescription ; 00351 00352 00356 SonsContainerType _sonsContainer ; 00357 00359 virtual void printToStream (ostream & out, int currentOffset) const ; 00360 00361 00363 mutable PsnMutexLock _dataLock ; 00364 00366 mutable PsnCondition _createdCondition ; 00367 00369 mutable bool _creatingObject ; 00370 00372 mutable pthread_t _creatingThread ; 00373 private: 00375 PsName _processId ; 00376 00378 PsFrequency _frequency ; 00379 00381 PsFrequency _originalFrequency ; 00382 00383 }; 00384 00385 00386 // ---------------------------- implementation ---------------------------- / 00387 template <typename Type> 00388 list<const PsObjectDescriptor *> * 00389 PsObjectDescriptor::listSonsOfType ( ) const 00390 { 00391 return listSonsOfType< Type > ( new list<const PsObjectDescriptor *>() ); 00392 } 00393 00394 00395 00396 template <typename Type> 00397 list<const PsObjectDescriptor *> * 00398 PsObjectDescriptor::listSonsOfType (list<const PsObjectDescriptor *> * resultList) const 00399 { 00400 for ( SonsContainerType::const_iterator i = _sonsContainer.begin() ; 00401 i != _sonsContainer.end() ; 00402 ++i ) 00403 { 00404 if (dynamic_cast<Type *>( (*i)->createDescribedObject () ) != NULL) 00405 { 00406 resultList->push_back ( (*i) ) ; 00407 } 00408 } 00409 return resultList ; 00410 } 00411 00412 00413 00414 template <typename Type> 00415 list<const PsObjectDescriptor *> * 00416 PsObjectDescriptor::listDescendantsOfType ( ) const 00417 { 00418 return listDescendantsOfType<Type> ( new list<const PsObjectDescriptor *>() ); 00419 } 00420 00421 00422 00423 template <typename Type> 00424 list<const PsObjectDescriptor *> * 00425 PsObjectDescriptor::listDescendantsOfType (list<const PsObjectDescriptor *> * resultList ) const 00426 { 00427 assert ( createDescribedObject () != NULL ) ; 00428 00429 // test the current node 00430 if (dynamic_cast<Type *>( createDescribedObject () ) != NULL) 00431 { 00432 resultList->push_back ( this ) ; 00433 } 00434 00435 //recurse through the sons 00436 for ( SonsContainerType::const_iterator i = _sonsContainer.begin() ; 00437 i != _sonsContainer.end() ; 00438 ++i ) 00439 { 00440 assert ((*i)->getFathersObjectDescriptor() == this ) ; 00441 (*i)->template listDescendantsOfType<Type> ( resultList ) ; 00442 } 00443 return resultList ; 00444 } 00445 00446 #endif 00447 00448 00449
| Documentation generated on Mon Nov 25 15:25:02 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |