Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsObjectDescriptor Class Reference

object of this class are used to store the description of simulated object, with data meaningfull for object outside the kernel. More...

#include <PsObjectDescriptor.h>

Inheritance diagram for PsObjectDescriptor:

Inheritance graph
[legend]
Collaboration diagram for PsObjectDescriptor:

Collaboration graph
[legend]
List of all members.

member functions using the object descriptor as a node of the simulation tree

typedef list< PsObjectDescriptor * > SonsContainerType
 The type of the container memorizing the sons of the described object in the simulation tree.

virtual const PsObjectDescriptor * getFathersObjectDescriptor () const
 get the object descriptor of the father

virtual PsObjectDescriptor * getFathersObjectDescriptor ()
 get the object descriptor of the father

virtual SonsContainerTypegetSons ()
 get a container with all the sons of this object in the simulation tree

virtual const list< PsObjectDescriptor * > * getSons () const
 get a container with all the sons of this object in the simulation tree the resulting list should be deleted

virtual list< const PsObjectDescriptor * > * getDescendants () const
 get a container with all the descendants of this object in the simualtion tree the result should be deleted after usage if the object has no descendants, an empty list is returned

virtual list< const PsObjectDescriptor * > * getDescendants (list< const PsObjectDescriptor * > *resultList) const
 get a container with all the descendants of this object in the simualtion tree

virtual list< PsObjectDescriptor * > * getDescendants ()
 get a container with all the descendants of this object in the simualtion tree the result should be deleted after usage if the object has no descendants, an empty list is returned

virtual list< PsObjectDescriptor * > * getDescendants (list< PsObjectDescriptor * > *resultList)
 get a container with all the descendants of this object in the simualtion tree

virtual void addSon (PsObjectDescriptor *newSon)
 add a son in the simulation tree to the described object If called after initialisation of the controller, isn't taken into account by the controller

virtual void removeSon (PsObjectDescriptor *oldSon)
 remove a son in the simulation tree If called after initialisation of the controller, isn't taken into account by the controller

template<typename Type> list< const PsObjectDescriptor * > * listSonsOfType () const
 listSonsOfType.

template<typename Type> list< const PsObjectDescriptor * > * listSonsOfType (list< const PsObjectDescriptor * > *resultList) const
 list the sons of a certain Type.

template<typename Type> list< const PsObjectDescriptor * > * listDescendantsOfType () const
 listDescendantsOfType.

template<typename Type> list< const PsObjectDescriptor * > * listDescendantsOfType (list< const PsObjectDescriptor * > *resultList) const
 listDescendantsOfType.

virtual const PsObjectDescriptor * findDescendantNamed (const PsName &name) const
 find a descendant of this node

virtual PsObjectDescriptor * findDescendantNamed (const PsName &name)
 find a descendant of this node

void interpretConfigurationParameterAsListOfSons (SonsContainerType &listOfSons, PsMultipleConfigurationParameter *sonsDescription)
 helper function, to help interpret a object described as a configuration parameter

PsObjectDescriptor * interpretConfigurationParameterAsObjectDescription (string objectName, PsMultipleConfigurationParameter *)
 helper function, to create a object described as a configuration parameter


Public Methods

 PsObjectDescriptor ()
 default constructor needed for an object descriptor to be included in a valued event for distributed creation

 PsObjectDescriptor (const PsObjectDescriptor &)
 copy constructor

 PsObjectDescriptor (const PsName &objectName, const PsName &classId, PsMultipleConfigurationParameter *schedulingParameters, PsConfigurationParameterDescriptor *configurationParameters)
 Constructor responsability of the destruction of schedulingParameters and configurationParameters is transfered to the object.

 PsObjectDescriptor (const PsName &objectName, const PsName &classId, const PsFrequency &frequency, PsConfigurationParameterDescriptor *configurationParameters)
 Constructor, used as a shortcut for constructing correct scheduling parameters responsability of the destruction of configurationParameters is transfered to the object.

 PsObjectDescriptor (const PsName &objectName, const PsName &classId, const PsName &process, const PsFrequency &frequency, PsConfigurationParameterDescriptor *configurationParameters)
 Constructor, used as a shortcut for constructing correct scheduling parameters responsability of the destruction of configurationParameters is transfered to the object.

virtual ~PsObjectDescriptor ()
 destructor

virtual const PsNamegetName () const
 get the name of the described object

virtual const PsNamegetClass () const
 get the class name of the described object

virtual const PsNamegetProcess () const
 get the process wich this object is affected to

virtual const PsFrequencygetFrequency () const
 get the frequency of the described object

virtual const PsFrequencygetOriginalFrequency () const
 get the original frequency of the described object

virtual const PsConfigurationParameterDescriptorgetConfigurationParameters () const
 get the configuration parameters of the controled object

virtual PsConfigurationParameterDescriptorgetConfigurationParameters ()
 get the configuration parameters of the controled object

virtual const PsMultipleConfigurationParametergetOriginalSchedulingParameters () const
 get the configuration parameters of the controled object

virtual const PsMultipleConfigurationParametergetSchedulingParameters () const
 get the configuration parameters of the controled object

virtual void setProcess (const PsName &newProcessName)
 change the process of the described object

virtual void setFrequency (const PsFrequency &newFrequency)
 change the frequency of the described object

virtual void deleteCachedData ()
 in the event this object description contains cached data, delete it

virtual void unpack (PsIncomingSynchronisationMessage &)
 unpack from a synchronisation message

virtual void pack (PsOutgoingSynchronisationMessage &) const
 pack in a synchronisation message

virtual void extract (istream &in)
 extract from a stream

virtual void insertInStream (ostream &out) const
 insert in a stream

virtual PsMultipleConfigurationParametergetSchedulingParameters ()
 get the configuration parameters of the controled object (non const version)


Protected Methods

virtual PsSimulatedObjectcreateDescribedObject () const
 create the described object if _pointerToSimulatedObject is nil, create the described object.

virtual void setFathersDescription (PsObjectDescriptor *newFather)
void interpretSchedulingParameters (PsMultipleConfigurationParameter *schedulingParamters)
 interpret a PsConfigurationParameterDescriptor as the initial scheduling parameters non virtual because called by the constructor

virtual void printToStream (ostream &out, int currentOffset) const
 pretty insert in a stream


Protected Attributes

PsSimulatedObject_pointerToSimulatedObject
 if a simulated object corresponding to this descriptor has been created, a pointer to this object is memorised here.

bool _destroySimulatedObject
 a pointer indicating if _pointerToSimulatedObject is deletable by this object

PsName _objectName
 decribed object's name

PsName _classId
 decribed object's class

PsConfigurationParameterDescriptor_configurationParameters
 described object's configuration parameters (isn't const to enable extraction

PsMultipleConfigurationParameter_originalSchedulingParameters
 described object's scheduling parameters

PsMultipleConfigurationParameter_schedulingParameters
 described object's scheduling parameters

PsObjectDescriptor * _fathersDescription
 a pointer to the objects father in the simulation tree

SonsContainerType _sonsContainer
 a container with all of the sons of an object.

PsnMutexLock _dataLock
 the lock to access _creatingObject and _creatingThread

PsnCondition _createdCondition
 the condition to wait on if an other thread is creating the object

bool _creatingObject
 the boolean used to avoid recursive creation : should be accessed only protected

pthread_t _creatingThread
 the thread id of the creating lock


Private Attributes

PsName _processId
 decribed object's current process (stored to avoid reinterpreting the scheduling parameters)

PsFrequency _frequency
 decribed object's current frequency (stored to avoid reinterpreting the scheduling parameters)

PsFrequency _originalFrequency
 decribed object's current frequency (stored to avoid reinterpreting the scheduling parameters)


Friends

class PsController
 make the controller a friend so that only controllers can ask for the creation of the described simulation object and change the father of an object

class PsnObjectHandle
 make the object handle a friend so that only controllers can change the boolean indicating delete responsability

class PsSimulatedObject
 make the simulated object friend so it can change the _pointerToSimulatedObject as early as possible


Detailed Description

object of this class are used to store the description of simulated object, with data meaningfull for object outside the kernel.

objects of this class store real data, and not references or pointers to data. Therefore, whatever the means of creation of any simulated object, the permanent location for it's general data is in objects of this class. An object handle is responsible for the creation of the corresponding simulated object and of its destruction if it'destruction wasn't handled over to the objct's object handle.

Author:
Siames
Version:
1.0

Definition at line 39 of file PsObjectDescriptor.h.


Member Typedef Documentation

typedef list<PsObjectDescriptor *> PsObjectDescriptor::SonsContainerType
 

The type of the container memorizing the sons of the described object in the simulation tree.

Definition at line 170 of file PsObjectDescriptor.h.


Constructor & Destructor Documentation

PsObjectDescriptor::PsObjectDescriptor   [explicit]
 

default constructor needed for an object descriptor to be included in a valued event for distributed creation

Definition at line 329 of file PsObjectDescriptor.cxx.

Referenced by interpretConfigurationParameterAsObjectDescription().

00330                                         :
00331    _configurationParameters (NULL),
00332    _originalSchedulingParameters (NULL),
00333    _schedulingParameters (NULL),
00334    _fathersDescription (NULL),
00335    _frequency(0),
00336    _originalFrequency ( 0 ),
00337    _creatingObject (false ),
00338    _creatingThread (0),
00339    _destroySimulatedObject (false ),
00340    _pointerToSimulatedObject (NULL)
00341 {
00342    // otherwise, the initial value of _creatingThread is inappropriate
00343    assert (pthread_self() != 0) ;
}

PsObjectDescriptor::PsObjectDescriptor const PsObjectDescriptor &   
 

copy constructor

Definition at line 345 of file PsObjectDescriptor.cxx.

References _configurationParameters, _originalSchedulingParameters, _schedulingParameters, _sonsContainer, addSon(), PsConfigurationParameterDescriptor::clone(), and list< PsObjectDescriptor * >::end().

00346                                                                          :
00347    _pointerToSimulatedObject (NULL ),
00348    _destroySimulatedObject ( false ),
00349    _objectName (orig._objectName),
00350    _classId ( orig._classId),
00351    _fathersDescription ( NULL ),
00352    _processId ( orig._processId),
00353    _frequency ( orig._frequency ),
00354    _originalFrequency ( orig._originalFrequency ),
00355    _creatingObject ( false )
00356 {
00357    if ( orig._configurationParameters != NULL )
00358       {
00359          _configurationParameters = orig._configurationParameters->clone() ;
00360       }
00361    else
00362       {
00363          _configurationParameters = NULL ;
00364       }
00365    if ( orig._originalSchedulingParameters != NULL )
00366       {
00367          _originalSchedulingParameters = dynamic_cast<PsMultipleConfigurationParameter *> (orig._originalSchedulingParameters->clone() ) ;
00368          assert ( _originalSchedulingParameters != NULL ) ;
00369       }
00370    else
00371       {
00372          _originalSchedulingParameters = NULL ;
00373       }
00374    if ( orig._schedulingParameters != NULL )
00375       {
00376          _schedulingParameters = dynamic_cast<PsMultipleConfigurationParameter *> (orig._schedulingParameters->clone()) ;
00377          assert ( _schedulingParameters != NULL ) ;
00378       }
00379    else
00380       {
00381          _schedulingParameters = NULL ;
00382       }
00383 
00384    // only one descriptor by object. Assume descriptor is copied only before the described object is created
00385    assert ( orig._pointerToSimulatedObject == NULL ) ;
00386    assert ( orig._destroySimulatedObject == false ) ;
00387 
00388    // copy the sons
00389      for ( SonsContainerType::const_iterator i = orig._sonsContainer.begin() ;
00390          i != orig. _sonsContainer.end() ;
00391          ++i )
00392       {
00393          addSon ( new PsObjectDescriptor (*(*i)) ) ;
00394       }
}

PsObjectDescriptor::PsObjectDescriptor const PsName   objectName,
const PsName   classId,
PsMultipleConfigurationParameter   schedulingParameters,
PsConfigurationParameterDescriptor   configurationParameters
 

Constructor responsability of the destruction of schedulingParameters and configurationParameters is transfered to the object.

Definition at line 472 of file PsObjectDescriptor.cxx.

References interpretSchedulingParameters().

00476                                                                                                       :
00477    _objectName ( objectName ), 
00478    _classId ( classId ), 
00479    _configurationParameters ( configurationParameters ),
00480    _schedulingParameters ( schedulingParameters ),
00481    _pointerToSimulatedObject( NULL ),
00482    _destroySimulatedObject ( false ),
00483    _fathersDescription ( NULL ),
00484    _originalSchedulingParameters (NULL),
00485    _creatingObject (false),
00486    _creatingThread ( 0 )
00487 {
00488    assert (pthread_self() != 0) ;
00489    interpretSchedulingParameters (schedulingParameters) ;
}

PsObjectDescriptor::PsObjectDescriptor const PsName   objectName,
const PsName   classId,
const PsFrequency   frequency,
PsConfigurationParameterDescriptor   configurationParameters
 

Constructor, used as a shortcut for constructing correct scheduling parameters responsability of the destruction of configurationParameters is transfered to the object.

Definition at line 436 of file PsObjectDescriptor.cxx.

References _originalSchedulingParameters, _schedulingParameters, PsMultipleConfigurationParameter::appendSubDescriptorNamed(), PsMultipleConfigurationParameter::clone(), and PsFrequency.

00440                                                                                                       : 
00441    _objectName ( objectName ), 
00442    _classId ( classId ), 
00443    _frequency ( frequency ),
00444    _originalFrequency ( frequency ),
00445    _configurationParameters ( configurationParameters ),
00446    _pointerToSimulatedObject( NULL ),
00447    _destroySimulatedObject ( false ),
00448    _fathersDescription ( NULL ),
00449    _creatingObject (false),
00450    _creatingThread ( 0 )
00451 {
00452    assert (pthread_self() != 0) ;
00453    _schedulingParameters = new PsMultipleConfigurationParameter () ;
00454 #ifdef _USESSTREAM
00455    ostringstream freq ;
00456    freq << frequency ;
00457    _schedulingParameters->appendSubDescriptorNamed ("Frequency", 
00458                                                    new PsUniqueConfigurationParameter (freq.str() ) ) ;
00459 #else   
00460    ostrstream freq ;
00461    freq << frequency ;
00462    freq.put('\0') ;
00463    _schedulingParameters->appendSubDescriptorNamed ("Frequency", 
00464                                                    new PsUniqueConfigurationParameter (freq.str() ) ) ;
00465    delete freq.str() ;
00466 #endif
00467    _originalSchedulingParameters = dynamic_cast<PsMultipleConfigurationParameter * >(_schedulingParameters->clone ()) ;
00468    assert (_originalSchedulingParameters != NULL ) ;

PsObjectDescriptor::PsObjectDescriptor const PsName   objectName,
const PsName   classId,
const PsName   process,
const PsFrequency   frequency,
PsConfigurationParameterDescriptor   configurationParameters
 

Constructor, used as a shortcut for constructing correct scheduling parameters responsability of the destruction of configurationParameters is transfered to the object.

Definition at line 396 of file PsObjectDescriptor.cxx.

References _originalSchedulingParameters, _schedulingParameters, PsMultipleConfigurationParameter::appendSubDescriptorNamed(), PsMultipleConfigurationParameter::clone(), PsName::getCString(), and PsFrequency.

00401                                                                                                       : 
00402    _objectName ( objectName ), 
00403    _classId ( classId ), 
00404    _processId ( processId ), 
00405    _frequency ( frequency ),
00406    _originalFrequency ( frequency ),
00407    _configurationParameters ( configurationParameters ),
00408    _pointerToSimulatedObject( NULL ),
00409    _destroySimulatedObject ( false ),
00410    _fathersDescription ( NULL ),
00411    _creatingObject (false),
00412    _creatingThread ( 0 )
00413 {
00414    assert (pthread_self() != 0) ;
00415    _schedulingParameters = new PsMultipleConfigurationParameter () ;
00416 #ifdef _USESSTREAM
00417    ostringstream freq ;
00418    freq << frequency ;
00419    _schedulingParameters->appendSubDescriptorNamed ("Frequency", 
00420                                                     new PsUniqueConfigurationParameter (freq.str() ) ) ;
00421 #else
00422    ostrstream freq ;
00423    freq << frequency ;
00424    freq.put('\0') ;
00425    _schedulingParameters->appendSubDescriptorNamed ("Frequency", 
00426                                                     new PsUniqueConfigurationParameter (freq.str() ) ) ;
00427    delete freq.str() ;
00428 #endif
00429    _schedulingParameters->appendSubDescriptorNamed ("Process", 
00430                                                    new PsUniqueConfigurationParameter (processId.getCString() ) ) ;
00431    _originalSchedulingParameters = dynamic_cast<PsMultipleConfigurationParameter * >(_schedulingParameters->clone ()) ;
00432    assert (_originalSchedulingParameters != NULL ) ;

PsObjectDescriptor::~PsObjectDescriptor   [virtual]
 

destructor

Definition at line 493 of file PsObjectDescriptor.cxx.

References _configurationParameters, _fathersDescription, _originalSchedulingParameters, _pointerToSimulatedObject, _schedulingParameters, _sonsContainer, list< PsObjectDescriptor * >::empty(), removeSon(), and list< PsObjectDescriptor * >::size().

00495 {
00496    if ( _destroySimulatedObject )
00497       {
00498          assert (_pointerToSimulatedObject != NULL) ;
00499          delete _pointerToSimulatedObject ;
00500       }
00501 
00502    if ( _fathersDescription != NULL )
00503       {
00504          _fathersDescription->removeSon (this) ;
00505       }
00506 
00507    if ( _originalSchedulingParameters != NULL ) delete _originalSchedulingParameters ;
00508    if ( _schedulingParameters != NULL ) delete _schedulingParameters ;
00509    if ( _configurationParameters != NULL ) delete _configurationParameters ;
00510 
00511    if (! _sonsContainer.empty() ) 
00512       {
00513          cout<<"PsObjectDescriptor with "<<_sonsContainer.size()<<" remaining sons deleted. Sons not deleted"<<endl;
00514       }


Member Function Documentation

void PsObjectDescriptor::addSon PsObjectDescriptor *    newSon [virtual]
 

add a son in the simulation tree to the described object If called after initialisation of the controller, isn't taken into account by the controller

Parameters:
newSon the added son. Responsability of the destruction of that descriptor is passed to this object descriptor. Nevertheless, all sons should be removed before this object descriptor is deleted (to ensure the controllers data structures reflect addition and removal of sons ). Moreover, if addition fails, the newSon is destroyed

Definition at line 700 of file PsObjectDescriptor.cxx.

References _fathersDescription, _sonsContainer, findDescendantNamed(), getName(), list< PsObjectDescriptor * >::push_back(), PsController::SomeWarnings, and PsController::warning().

Referenced by PsObjectDescriptor(), and setFathersDescription().

00702 {
00703    assert ( newSon != NULL ) ;
00704    const PsObjectDescriptor * duplicate = findDescendantNamed (newSon->getName() ) ;
00705    if ( duplicate == NULL )
00706       {
00707          _sonsContainer.push_back ( newSon ) ;
00708          newSon->_fathersDescription = this ;
00709       }
00710    else
00711       {
00712 #ifdef _USESSTREAM
00713          ostringstream warningMessage ;
00714          warningMessage<<"PsObjectDescriptor::addSon named "<<newSon->getName()
00715                        <<" failed because descendant with the same name allready exists for object named "
00716                        <<getName()<<"\n";
00717          PsController::warning ( warningMessage.str() , PsController::SomeWarnings) ;
00718 #else
00719          ostrstream warningMessage ;
00720          warningMessage<<"PsObjectDescriptor::addSon named "<<newSon->getName()
00721                        <<" failed because descendant with the same name allready exists for object named "
00722                        <<getName()<<"\n";
00723          warningMessage.put('\0') ;
00724          PsController::warning ( warningMessage.str() , PsController::SomeWarnings) ;
00725          delete warningMessage.str() ;
00726 #endif
00727          // as respnsability is transfered and the son is not added, delete it
00728          delete newSon ;
00729       }

PsSimulatedObject * PsObjectDescriptor::createDescribedObject   const [protected, virtual]
 

create the described object if _pointerToSimulatedObject is nil, create the described object.

Otherwise, returns a pointer to the previously created object responsability of the destruction of the object is kept by this objectDescriptor until _destroySimulatedObject is reset to false In particular, this member function is used for searches in the simulation tree in distributed contexts. the created object isn't handled to the controler for scheduling or other purposes, and isn't encapsulated in an object handle. only the constructor of the created object has been called

Definition at line 549 of file PsObjectDescriptor.cxx.

References _createdCondition, _creatingObject, _creatingThread, _dataLock, _destroySimulatedObject, _fathersDescription, _pointerToSimulatedObject, getClass(), getFathersObjectDescriptor(), getName(), PsnMutexLock::protect(), PsnCondition::signalChange(), PsController::SomeWarnings, PsnMutexLock::unprotect(), PsnCondition::waitForChange(), and PsController::warning().

Referenced by PsController::createDescribedObject(), and listDescendantsOfType().

00551 {
00552    //here, use mutual exclusion, to avoid
00553    // 1 - recursive creation loops
00554    // 2 - simultaneous creations
00555    // 3 - recursive creation loops during simultaneous creations !!!
00556 
00557    //therefore, only allow one thread to do creation at a time (share the creatingThread exclusion lock,
00558    // and test to see if we're in a recursive loop )
00559 
00560    _dataLock.protect() ;
00561 
00562    PsSimulatedObject * result = _pointerToSimulatedObject ;
00563    
00564    if ( _pointerToSimulatedObject == NULL )
00565       {
00566          
00567          if ( _creatingObject && (_creatingThread == pthread_self() ) ) 
00568             {
00569                // recursive creation loop : return NULL is the best that can be done
00570                _dataLock.unprotect() ;
00571             }
00572          else
00573             {
00574                // the object needs creating : here the question is whether an other thread is creating it or not
00575                if ( _creatingObject ) 
00576                   {
00577                      //other thread is creating the object : wait for it to finish creation
00578                      _createdCondition.waitForChange(_dataLock) ;
00579                   }
00580                else 
00581                   {
00582                      //no thread is creating the object, 
00583                      //therefore this thread takes responsability for creation
00584                      _creatingObject = true ;
00585                      _creatingThread = pthread_self() ;
00586                      _dataLock.unprotect() ;
00587                      
00588                      //here, we can garantie that we are the only creating thread,
00589                      //and that 
00590                      // 1 - any recursive creation loop is a non-blocking creation
00591                      // 2 - other threads creating the object are waiting on the condition
00592 
00593                      //attempt object creation
00594                      PsSimulatedObject * father = NULL ;
00595                      const PsObjectDescriptor * fathersDescription = _fathersDescription ;
00596                
00597                      // as creation can happen during a paralel simulation,
00598                      // it can happen at a time where getCurrentActiveObject returns the object whose request
00599                      // triggered instance creation. 
00600                      // Therefore, the current active object is temporarly set to NULL, so as to mimic creation phase
00601                      // If it is set to the controller, changing a controlparamter triggers the sending of a valueEvent by the controller, which might not have it's objectHandle initialized in order to avoid being scheduled by itself
00602                      PsnCurrentActiveObject context ( NULL ) ;
00603                      
00604                      while ( fathersDescription != NULL )
00605                         {
00606                            father = fathersDescription->createDescribedObject() ;
00607                            if ( father != NULL )
00608                               {
00609                                  result = father -> createInstanceOfEncapsulatedClass (*this);
00610                                  _dataLock.protect() ;
00611                                  _pointerToSimulatedObject = result ;
00612                                  _dataLock.unprotect() ;
00613                                  if ( _pointerToSimulatedObject != NULL )
00614                                     {
00615                                        _destroySimulatedObject = true ;
00616                                        fathersDescription = NULL ;
00617                                     }
00618                                  else 
00619                                     {
00620                                        fathersDescription = fathersDescription->getFathersObjectDescriptor() ;
00621                                     }
00622                               }
00623                            else 
00624                               {
00625                                  fathersDescription = NULL ;
00626                               }
00627                         }
00628                   }
00629                if ( _pointerToSimulatedObject == NULL )
00630                   {
00631 #ifdef _USESSTREAM
00632                      ostringstream warningMessage;
00633                      warningMessage<<"PsController::createReferenceObject: unable to create "<<getName()
00634                                    <<" of class "<<getClass()<<endl;
00635                      
00636                      PsController::warning ( warningMessage.str() , PsController::SomeWarnings ) ;
00637 #else
00638                      ostrstream warningMessage;
00639                      warningMessage<<"PsController::createReferenceObject: unable to create "<<getName()
00640                                    <<" of class "<<getClass()<<endl;
00641                      
00642                      warningMessage.put('\0') ;
00643                      PsController::warning ( warningMessage.str() , PsController::SomeWarnings ) ;
00644                      delete warningMessage.str() ;
00645 #endif
00646                   }
00647                _dataLock.protect() ;
00648                _creatingObject = false ;
00649                _creatingThread = 0 ;
00650                _dataLock.unprotect() ;
00651                //wathever the result, unblock other waiting threads
00652                _createdCondition.signalChange() ;
00653             }
00654       }
00655    else
00656       {
00657          _dataLock.unprotect() ;
00658       }
00659    return result ;

void PsObjectDescriptor::deleteCachedData   [virtual]
 

in the event this object description contains cached data, delete it

Definition at line 676 of file PsObjectDescriptor.cxx.

References _destroySimulatedObject, and _pointerToSimulatedObject.

00678 {
00679    if ( _destroySimulatedObject )
00680       {
00681          assert (_pointerToSimulatedObject != NULL) ;
00682          delete _pointerToSimulatedObject ;
00683          _pointerToSimulatedObject = NULL ;
00684       }
00685    _destroySimulatedObject = false ; 

void PsObjectDescriptor::extract istream &    in [virtual]
 

extract from a stream

Implements PsFlowable.

Definition at line 129 of file PsObjectDescriptor.cxx.

References _classId, _configurationParameters, _objectName, _sonsContainer, genericKernelParser::anonymousValue(), ANTLRToken, list< PsObjectDescriptor * >::clear(), PsConfigurationParameterDescriptor::getAssociatedString(), PsMultipleConfigurationParameter::getSubDescriptorByName(), interpretConfigurationParameterAsListOfSons(), interpretSchedulingParameters(), and genericKernelParser::key().

Referenced by unpack().

00131 {
00132    _sonsContainer.clear() ;
00133    
00134    KernelIstreamLexer<istream> inputStream (in) ;
00135    DLGLexer scan( & inputStream ) ;
00136    ANTLRTokenBuffer pipe ( & scan ) ;
00137    ANTLRTokenPtr aToken = new ANTLRToken() ;
00138    scan.setToken(mytoken(aToken)) ;
00139    genericKernelParser extractor  ( &pipe ) ;
00140    extractor.init() ;
00141 
00142    string stringName;
00143    extractor.key ( stringName ) ;
00144    _objectName = stringName ;
00145 
00146    PsConfigurationParameterDescriptor * genericSubDescription = extractor.anonymousValue() ;
00147    PsMultipleConfigurationParameter * generalDescription = dynamic_cast<PsMultipleConfigurationParameter *> ( genericSubDescription );
00148    
00149    if ( generalDescription == NULL ) 
00150       {
00151          throw PsUserException("Unable to extract a name for an ObjectDescriptor from a stream") ;
00152       }
00153 
00154 
00155    genericSubDescription = generalDescription->getSubDescriptorByName ("Class") ;
00156    if ( genericSubDescription == NULL ) 
00157       {
00158          throw PsUserException("Unable to extract a class for an ObjectDescriptor from a stream") ; 
00159       }
00160    _classId = genericSubDescription->getAssociatedString() ;
00161 
00162    delete _configurationParameters ;
00163    _configurationParameters = generalDescription->getSubDescriptorByName ("UserParams") ;
00164 
00165    genericSubDescription = generalDescription->getSubDescriptorByName ("Scheduling") ;
00166    if (genericSubDescription!=NULL)
00167       {
00168          interpretSchedulingParameters( dynamic_cast<PsMultipleConfigurationParameter * >(genericSubDescription ) ) ;
00169       }
00170    else
00171       {
00172          interpretSchedulingParameters(NULL) ;
00173       }
00174 
00175    genericSubDescription = generalDescription->getSubDescriptorByName ("Sons") ;
00176    generalDescription = dynamic_cast<PsMultipleConfigurationParameter *> (genericSubDescription) ;
00177    if (generalDescription != NULL)
00178       {
00179          interpretConfigurationParameterAsListOfSons ( _sonsContainer, generalDescription ) ;
00180       }

PsObjectDescriptor * PsObjectDescriptor::findDescendantNamed const PsName   name [virtual]
 

find a descendant of this node

Parameters:
name the named of the searched descriptor

Definition at line 807 of file PsObjectDescriptor.cxx.

References _sonsContainer, list< PsObjectDescriptor * >::begin(), list< PsObjectDescriptor * >::end(), findDescendantNamed(), and getName().

00809 {
00810    PsObjectDescriptor * resul = NULL ;
00811    
00812    if ( name == getName() )
00813       {
00814          resul = this ;
00815       }
00816    else
00817       {
00818          SonsContainerType::iterator i = _sonsContainer.begin() ;
00819          while ( (resul == NULL) &&
00820                  (i != _sonsContainer.end() ) )
00821             {
00822                resul = (*i)->findDescendantNamed ( name ) ;
00823                ++i ;
00824             } 
00825       }
00826    return resul ;  

const PsObjectDescriptor * PsObjectDescriptor::findDescendantNamed const PsName   name const [virtual]
 

find a descendant of this node

Parameters:
name the named of the searched descriptor

Definition at line 783 of file PsObjectDescriptor.cxx.

References _sonsContainer, list< PsObjectDescriptor * >::begin(), list< PsObjectDescriptor * >::end(), and getName().

Referenced by addSon(), PsController::changeObjectsFather(), PsController::destroyObject(), findDescendantNamed(), PsController::getObjectDescriptorOfObject(), PsDistributedController::getPointerToSimulatedObjectNamed(), PsDistributedController::processEvent(), PsController::processEvent(), PsController::reactToControlledObjectsSystemEvents(), and setFathersDescription().

00785 {
00786    const PsObjectDescriptor * resul = NULL ;
00787    
00788    if ( name == getName() )
00789       {
00790          resul = this ;
00791       }
00792    else
00793       {
00794          SonsContainerType::const_iterator i = _sonsContainer.begin() ;
00795          while ( (resul == NULL) &&
00796                  (i != _sonsContainer.end() ) )
00797             {
00798                resul = (*i)->findDescendantNamed ( name ) ;
00799                ++i ;
00800             } 
00801       }
00802    return resul ;  

const PsName & PsObjectDescriptor::getClass   const [virtual]
 

get the class name of the described object

Definition at line 33 of file PsObjectDescriptor.cxx.

References _classId.

Referenced by createDescribedObject(), PsSimulatedObject::createInstanceOfEncapsulatedClass(), PsCalculus::getClass(), and printToStream().

00035 {
00036   return _classId;

PsConfigurationParameterDescriptor * PsObjectDescriptor::getConfigurationParameters   [virtual]
 

get the configuration parameters of the controled object

Definition at line 59 of file PsObjectDescriptor.cxx.

References _configurationParameters.

00061 {
00062    return _configurationParameters ;

const PsConfigurationParameterDescriptor * PsObjectDescriptor::getConfigurationParameters   const [virtual]
 

get the configuration parameters of the controled object

Definition at line 54 of file PsObjectDescriptor.cxx.

References _configurationParameters.

Referenced by PsSimulatedObject::getConfigurationParameters(), PsCalculus::getConfigurationParameters(), and printToStream().

00056 {
00057    return _configurationParameters ;

list< PsObjectDescriptor * > * PsObjectDescriptor::getDescendants list< PsObjectDescriptor * > *    resultList [virtual]
 

get a container with all the descendants of this object in the simualtion tree

Parameters:
resultList : the list in wich the descendants should be inserted. The list is unchanged if no descendants are found the result should be deleted after usage if the object has no descendants, an empty list is returned

Definition at line 768 of file PsObjectDescriptor.cxx.

References _sonsContainer, list< PsObjectDescriptor * >::begin(), list< PsObjectDescriptor * >::end(), and list< T, Alloc >::push_back().

00770 {
00771    for ( SonsContainerType::const_iterator i = _sonsContainer.begin() ;
00772          i != _sonsContainer.end() ;
00773          ++i )
00774       {
00775          resultList->push_back( (*i) ) ;
00776          (*i)->getDescendants ( resultList ) ;
00777       }
00778    return resultList ;

list< PsObjectDescriptor * > * PsObjectDescriptor::getDescendants   [virtual]
 

get a container with all the descendants of this object in the simualtion tree the result should be deleted after usage if the object has no descendants, an empty list is returned

Definition at line 760 of file PsObjectDescriptor.cxx.

References getDescendants().

00762 {
00763    list<PsObjectDescriptor *> * result = new list<PsObjectDescriptor *> () ;
00764    return getDescendants (result) ;

list< const PsObjectDescriptor * > * PsObjectDescriptor::getDescendants list< const PsObjectDescriptor * > *    resultList const [virtual]
 

get a container with all the descendants of this object in the simualtion tree

Parameters:
resultList : the list in wich the descendants should be inserted. The list is unchanged if no descendants are found the result should be deleted after usage if the object has no descendants, an empty list is returned

Definition at line 747 of file PsObjectDescriptor.cxx.

References _sonsContainer, list< PsObjectDescriptor * >::begin(), list< PsObjectDescriptor * >::end(), and list< T, Alloc >::push_back().

00749 {
00750    for ( SonsContainerType::const_iterator i = _sonsContainer.begin() ;
00751          i != _sonsContainer.end() ;
00752          ++i )
00753       {
00754          resultList->push_back( (*i) ) ;
00755          (*i)->getDescendants ( resultList ) ;
00756       }
00757    return resultList ;

list< const PsObjectDescriptor * > * PsObjectDescriptor::getDescendants   const [virtual]
 

get a container with all the descendants of this object in the simualtion tree the result should be deleted after usage if the object has no descendants, an empty list is returned

Definition at line 740 of file PsObjectDescriptor.cxx.

Referenced by PsController::computeScheduling(), and getDescendants().

00742 {
00743    list<const PsObjectDescriptor *> * result = new list<const PsObjectDescriptor *> () ;
00744    return getDescendants (result) ;

PsObjectDescriptor * PsObjectDescriptor::getFathersObjectDescriptor   [virtual]
 

get the object descriptor of the father

Definition at line 669 of file PsObjectDescriptor.cxx.

References _fathersDescription.

00671 {
00672    return _fathersDescription ;

const PsObjectDescriptor * PsObjectDescriptor::getFathersObjectDescriptor   const [virtual]
 

get the object descriptor of the father

Definition at line 663 of file PsObjectDescriptor.cxx.

References _fathersDescription.

Referenced by createDescribedObject(), PsController::deleteObject(), PsSimulatedObject::getFather(), PsSimulatedObject::getFathersDescriptor(), PsSimulatedObject::isAncestor(), and PsSimulatedObject::listBrothersOfType().

00665 {
00666    return _fathersDescription ;

const PsFrequency & PsObjectDescriptor::getFrequency   const [virtual]
 

get the frequency of the described object

Definition at line 43 of file PsObjectDescriptor.cxx.

References _frequency, and PsFrequency.

Referenced by PsController::computeScheduling(), PsCalculus::getFrequency(), PsSimulatedObject::getPeriod(), PsDistributedController::getPointerToSimulatedObjectNamed(), PsController::processNewObjectDeclaration(), PsController::scheduleObject(), and PsController::sendInitialEventsTo().

00045 {
00046   return _frequency ;

const PsName & PsObjectDescriptor::getName   const [virtual]
 

get the name of the described object

Definition at line 28 of file PsObjectDescriptor.cxx.

References _objectName.

Referenced by addSon(), PsnMultiThreadedScheduler::addToScheduable(), PsnMultiThreadedBenchmarkingScheduler::addToScheduable(), PsnMultiThreadedAsynchronousScheduler::addToScheduable(), PsnMirrorObjectHandle::cancelRegistrationForSignal(), createDescribedObject(), PsDistributedController::createDuplicatedObject(), PsDistributedController::createMirrorObject(), PsController::createReferenceObject(), PsController::deleteObject(), PsController::deleteObjectHandle(), findDescendantNamed(), PsSimulatedObject::getFather(), PsSimulatedObject::getName(), PsCalculus::getName(), PsSimulatedObject::isAncestor(), operator<=(), printToStream(), PsController::processDeleteEventOf(), PsController::processEvent(), PsDistributedController::processNewObjectDeclaration(), PsMomeController::PsMomeController(), PsnMirrorObjectHandle::receiveEvent(), PsnMirrorObjectHandle::receiveRegistrationForSignal(), PsController::sendInitialEventsTo(), and setFathersDescription().

00030 {
00031   return _objectName ;

const PsFrequency & PsObjectDescriptor::getOriginalFrequency   const [virtual]
 

get the original frequency of the described object

Definition at line 49 of file PsObjectDescriptor.cxx.

References _originalFrequency, and PsFrequency.

Referenced by PsController::computeScheduling().

00051 {
00052   return _originalFrequency ;

const PsMultipleConfigurationParameter * PsObjectDescriptor::getOriginalSchedulingParameters   const [virtual]
 

get the configuration parameters of the controled object

Definition at line 74 of file PsObjectDescriptor.cxx.

References _originalSchedulingParameters.

00076 {
00077    return _originalSchedulingParameters ;

const PsName & PsObjectDescriptor::getProcess   const [virtual]
 

get the process wich this object is affected to

Definition at line 38 of file PsObjectDescriptor.cxx.

References _processId.

Referenced by PsnPvmDuplicatedObjectHandle::broadcastEvent(), PsDistributedController::createObject(), PsCalculus::getProcess(), PsDistributedController::processNewObjectDeclaration(), PsMomeOutput< Type >::PsMomeOutput(), PsnMirrorObjectHandle::PsnMirrorObjectHandle(), and PsnMirrorObjectHandle::sendRequestToReferenceObject().

00040 {
00041   return _processId ;

PsMultipleConfigurationParameter * PsObjectDescriptor::getSchedulingParameters   [virtual]
 

get the configuration parameters of the controled object (non const version)

Definition at line 69 of file PsObjectDescriptor.cxx.

References _schedulingParameters.

00071 {
00072    return _schedulingParameters ;

const PsMultipleConfigurationParameter * PsObjectDescriptor::getSchedulingParameters   const [virtual]
 

get the configuration parameters of the controled object

Definition at line 64 of file PsObjectDescriptor.cxx.

References _schedulingParameters.

Referenced by PsController::getSchedulingParametersOfObject(), printToStream(), PsMultiThreadedController::PsMultiThreadedController(), and PsMultiThreadedPvmController::PsMultiThreadedPvmController().

00066 {
00067    return _schedulingParameters ;

const list< PsObjectDescriptor * > * PsObjectDescriptor::getSons   const [virtual]
 

get a container with all the sons of this object in the simulation tree the resulting list should be deleted

Definition at line 689 of file PsObjectDescriptor.cxx.

References _sonsContainer.

00691 {
00692    return & _sonsContainer ;

PsObjectDescriptor::SonsContainerType & PsObjectDescriptor::getSons   [virtual]
 

get a container with all the sons of this object in the simulation tree

Definition at line 694 of file PsObjectDescriptor.cxx.

References _sonsContainer.

Referenced by PsDistributedController::createControlledObjects(), PsController::createControlledObjects(), PsController::destroyObject(), and PsController::finish().

00696 {
00697    return _sonsContainer ;

void PsObjectDescriptor::insertInStream ostream &    out const [virtual]
 

insert in a stream

Implements PsFlowable.

Definition at line 227 of file PsObjectDescriptor.cxx.

References printToStream().

00229 {
00230    printToStream ( out, 0 ) ;

void PsObjectDescriptor::interpretConfigurationParameterAsListOfSons SonsContainerType   listOfSons,
PsMultipleConfigurationParameter   sonsDescription
[static]
 

helper function, to help interpret a object described as a configuration parameter

Definition at line 828 of file PsObjectDescriptor.cxx.

References PsMultipleConfigurationParameter::getNameOfSubDescriptor(), PsMultipleConfigurationParameter::getNumberOfSubItems(), PsMultipleConfigurationParameter::getSubDescriptorByPosition(), interpretConfigurationParameterAsObjectDescription(), and list< PsObjectDescriptor * >::push_back().

Referenced by extract(), and interpretConfigurationParameterAsObjectDescription().

00831 {
00832    if ( sonsDescription != NULL )
00833       {
00834          int nbSons = sonsDescription->getNumberOfSubItems() ;
00835          string sonName ;
00836          for ( int i = 0 ; i < nbSons ; ++i )
00837             {
00838                PsConfigurationParameterDescriptor * aGenericSonsDescription ;
00839                aGenericSonsDescription = sonsDescription->getSubDescriptorByPosition(i) ;
00840                sonName = sonsDescription->getNameOfSubDescriptor (i) ;
00841                PsMultipleConfigurationParameter * aSonsDescription ;
00842                aSonsDescription = dynamic_cast<PsMultipleConfigurationParameter *> ( aGenericSonsDescription ) ;
00843                if ( aSonsDescription != NULL )
00844                   {
00845                      PsObjectDescriptor * descriptionOfSon ;
00846                      descriptionOfSon = interpretConfigurationParameterAsObjectDescription ( sonName,
00847                                                                                              aSonsDescription ) ;
00848                      listOfSons.push_back ( descriptionOfSon );
00849                   }
00850             }
00851       }

PsObjectDescriptor * PsObjectDescriptor::interpretConfigurationParameterAsObjectDescription string    objectName,
PsMultipleConfigurationParameter  
[static]
 

helper function, to create a object described as a configuration parameter

Definition at line 853 of file PsObjectDescriptor.cxx.

References _sonsContainer, list< PsObjectDescriptor * >::begin(), list< PsObjectDescriptor * >::end(), PsConfigurationParameterDescriptor::getAssociatedString(), PsMultipleConfigurationParameter::getSubDescriptorByName(), interpretConfigurationParameterAsListOfSons(), and PsObjectDescriptor().

Referenced by interpretConfigurationParameterAsListOfSons().

00856 {
00857    assert (generalDescription != NULL) ;
00858 
00859    PsConfigurationParameterDescriptor * genericSubDescription = generalDescription->getSubDescriptorByName ("Class") ;
00860 
00861    if ( genericSubDescription == NULL ) 
00862       {
00863          throw PsUserException("Unable to extract a class for an ObjectDescriptor from a stream") ; 
00864       }
00865 
00866    string classId = genericSubDescription->getAssociatedString() ;
00867 
00868 
00869    PsConfigurationParameterDescriptor *  configurationParameters ;
00870    configurationParameters = generalDescription->getSubDescriptorByName ("UserParams") ;
00871 
00872 
00873    PsMultipleConfigurationParameter *  schedulingParameters ;
00874    schedulingParameters = dynamic_cast<PsMultipleConfigurationParameter *> 
00875       ( generalDescription->getSubDescriptorByName ("Scheduling") ) ;
00876 
00877 
00878    PsObjectDescriptor * result = new PsObjectDescriptor (PsName (objectName), 
00879                                                          PsName (classId), 
00880                                                          schedulingParameters, 
00881                                                          configurationParameters) ;
00882 
00883 
00884    genericSubDescription = generalDescription->getSubDescriptorByName ("Sons") ;
00885    generalDescription = dynamic_cast<PsMultipleConfigurationParameter *> (genericSubDescription) ;
00886    if (generalDescription != NULL)
00887       {
00888          interpretConfigurationParameterAsListOfSons ( result->_sonsContainer, generalDescription ) ;
00889          //for all the sons, connect to their father, only known here
00890          for ( SonsContainerType::const_iterator i = result->_sonsContainer.begin() ;
00891                i != result->_sonsContainer.end() ;
00892                ++i )
00893             {
00894                (*i)->_fathersDescription = result ;
00895             }
00896       }
00897    return result ;

void PsObjectDescriptor::interpretSchedulingParameters PsMultipleConfigurationParameter   schedulingParamters [protected]
 

interpret a PsConfigurationParameterDescriptor as the initial scheduling parameters non virtual because called by the constructor

Definition at line 287 of file PsObjectDescriptor.cxx.

References _frequency, _originalFrequency, _originalSchedulingParameters, _processId, _schedulingParameters, PsMultipleConfigurationParameter::appendSubDescriptorNamed(), PsMultipleConfigurationParameter::clone(), PsConfigurationParameterDescriptor::getAssociatedString(), and PsMultipleConfigurationParameter::getSubDescriptorByName().

Referenced by extract(), and PsObjectDescriptor().

00289 {
00290    if ( (_schedulingParameters != NULL) && (_schedulingParameters != schedulingParameters ) ) delete _schedulingParameters ;
00291 
00292    _schedulingParameters = schedulingParameters ;
00293       
00294    if ( _schedulingParameters == NULL )
00295       {
00296          _schedulingParameters = new PsMultipleConfigurationParameter() ;
00297       } 
00298 
00299    const PsConfigurationParameterDescriptor * description ;
00300    description = _schedulingParameters->getSubDescriptorByName ("Frequency") ;
00301 
00302    if ( description != NULL )
00303       {
00304          _frequency = atoi (description->getAssociatedString().c_str() ) ;
00305       }
00306    else
00307       {
00308          _frequency = 0 ;
00309          _schedulingParameters->appendSubDescriptorNamed ("Frequency", 
00310                                                           new PsUniqueConfigurationParameter ("0") ) ;
00311       }
00312 
00313    if ( _originalSchedulingParameters != NULL ) 
00314       {
00315          delete _originalSchedulingParameters ;
00316       }
00317    _originalSchedulingParameters = dynamic_cast<PsMultipleConfigurationParameter *> ( _schedulingParameters->clone () ) ;
00318    assert ( _originalSchedulingParameters != NULL ) ; 
00319 
00320    _originalFrequency = _frequency ;
00321    
00322    description = _schedulingParameters->getSubDescriptorByName ("Process") ;
00323    
00324    if ( description != NULL )
00325       {
00326          _processId = description->getAssociatedString() ;
00327       }

template<typename Type>
list< const PsObjectDescriptor * > * PsObjectDescriptor::listDescendantsOfType list< const PsObjectDescriptor * > *    resultList const
 

listDescendantsOfType.

Parameters:
resultList a list to be used to store the result
Returns:
the list of descendants of the current node that are of the type of the template parameter delete the resulting list after usage

Definition at line 424 of file PsObjectDescriptor.h.

References _sonsContainer, list< PsObjectDescriptor * >::begin(), createDescribedObject(), list< PsObjectDescriptor * >::end(), and list< T, Alloc >::push_back().

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 ;  

template<typename Type>
list< const PsObjectDescriptor * > * PsObjectDescriptor::listDescendantsOfType   const
 

listDescendantsOfType.

Returns:
the list of descendants of the current node that are of the type of the template parameter

Definition at line 415 of file PsObjectDescriptor.h.

00417 {
00418    return listDescendantsOfType<Type> ( new list<const PsObjectDescriptor *>() );  

template<typename Type>
list< const PsObjectDescriptor * > * PsObjectDescriptor::listSonsOfType list< const PsObjectDescriptor * > *    resultList const
 

list the sons of a certain Type.

Parameters:
resultList a list to be used to store the result
Returns:
the list of sons of the current node that are of the type of the template parameter

Definition at line 397 of file PsObjectDescriptor.h.

References _sonsContainer, list< PsObjectDescriptor * >::begin(), list< PsObjectDescriptor * >::end(), and list< T, Alloc >::push_back().

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 ;  

template<typename Type>
list< const PsObjectDescriptor * > * PsObjectDescriptor::listSonsOfType   const
 

listSonsOfType.

Returns:
the list of sons of the current node that are of the type of the template parameter delete the resulting list after usage

Definition at line 388 of file PsObjectDescriptor.h.

00390 {
00391    return listSonsOfType< Type > ( new list<const PsObjectDescriptor *>() );  

void PsObjectDescriptor::pack PsOutgoingSynchronisationMessage   const [virtual]
 

pack in a synchronisation message

Reimplemented from PsFlowable.

Definition at line 109 of file PsObjectDescriptor.cxx.

References printToStream().

00111 {
00112    // packed in a quite inefficient way (unsing the string representation of the object descriptor), 
00113    // but much simpler to decode : therefore, use extract
00114 #ifdef _USESSTREAM
00115    ostringstream char_out ;
00116    printToStream ( char_out, 0 ) ;
00117    out<<char_out.str() ;
00118 #else
00119    ostrstream char_out ;
00120    printToStream ( char_out, 0 ) ;
00121    char_out.put ('\0') ;
00122    char * C_string = char_out.str() ;
00123    assert (C_string[char_out.pcount()-1] == '\0') ;
00124    out<<char_out.pcount() ;
00125    out<<C_string;
00126    delete C_string ;
00127 #endif

void PsObjectDescriptor::printToStream ostream &    out,
int    currentOffset
const [protected, virtual]
 

pretty insert in a stream

Definition at line 183 of file PsObjectDescriptor.cxx.

References _sonsContainer, list< PsObjectDescriptor * >::begin(), list< PsObjectDescriptor * >::end(), getClass(), getConfigurationParameters(), getName(), getSchedulingParameters(), printTabToStream(), PsConfigurationParameterDescriptor::printToStream(), PsMultipleConfigurationParameter::printToStream(), and list< PsObjectDescriptor * >::size().

Referenced by insertInStream(), and pack().

00185 {
00186    //suppose any needed offset has allready been printed
00187    out<<getName()<<endl;
00188    printTabToStream(out,offset+2) ;
00189    out<<"{"<<endl;
00190    printTabToStream(out,offset+4) ;
00191    out<<"Class "<<getClass()<<endl; 
00192    if ( getSchedulingParameters() != NULL )
00193       {
00194          printTabToStream(out,offset+4) ;
00195          out<<"Scheduling " ;
00196          getSchedulingParameters()->printToStream(out,offset+6) ;
00197          out<<endl;
00198       }
00199    if ( getConfigurationParameters() != NULL )
00200       {
00201          printTabToStream(out,offset+4) ;
00202          out<<"UserParams " ;
00203          getConfigurationParameters()->printToStream(out,offset+6) ;
00204          out<<endl;
00205       }
00206    if ( _sonsContainer.size() != 0 )
00207       {
00208          printTabToStream(out,offset+4) ;
00209          out<<"Sons"<<endl;
00210          printTabToStream(out,offset+6) ;
00211          out<<"{"<<endl;
00212          for ( SonsContainerType::const_iterator i = _sonsContainer.begin() ;
00213                i != _sonsContainer.end() ;
00214                ++i )
00215             {
00216                printTabToStream(out,offset+8) ;
00217                (*i)->printToStream (out, offset+8 ) ;
00218             }
00219          printTabToStream(out,offset+6) ;
00220          out<<"}"<<endl;         
00221       }
00222    printTabToStream(out,offset+2) ;
00223    out<<"}"<<endl;

void PsObjectDescriptor::removeSon PsObjectDescriptor *    oldSon [virtual]
 

remove a son in the simulation tree If called after initialisation of the controller, isn't taken into account by the controller

Parameters:
oldSon the son to remove. The removed son is not deleted

Definition at line 733 of file PsObjectDescriptor.cxx.

References _sonsContainer, and list< PsObjectDescriptor * >::remove().

Referenced by PsController::deleteObject(), setFathersDescription(), and ~PsObjectDescriptor().

00735 {
00736    _sonsContainer.remove (oldSon) ;

void PsObjectDescriptor::setFathersDescription PsObjectDescriptor *    newFather [protected, virtual]
 

Definition at line 516 of file PsObjectDescriptor.cxx.

References _fathersDescription, addSon(), findDescendantNamed(), getName(), removeSon(), PsController::SomeWarnings, and PsController::warning().

Referenced by PsController::changeObjectsFather().

00518 {
00519    assert (newFather != NULL) ;
00520    if ( _fathersDescription != NULL )
00521       {
00522          _fathersDescription->removeSon (this) ;
00523       }
00524    
00525    if ( newFather->findDescendantNamed ( getName() ) != NULL )
00526       {
00527          //cannot add the object : do nothing
00528 #ifdef _USESSTREAM
00529          ostringstream warningMessage ;
00530          warningMessage<<"PsObjectDescriptor::setFathersDescription of object named "<<getName()
00531                        <<" failed because descendant with the same name allready exists for object named "
00532                        <<newFather->getName()<<"\n";
00533          PsController::warning ( warningMessage.str() , PsController::SomeWarnings) ;
00534 #else
00535          ostrstream warningMessage ;
00536          warningMessage<<"PsObjectDescriptor::setFathersDescription of object named "<<getName()
00537                        <<" failed because descendant with the same name allready exists for object named "
00538                        <<newFather->getName()<<"\n";
00539          warningMessage.put('\0') ;
00540          PsController::warning ( warningMessage.str() , PsController::SomeWarnings) ;
00541          delete warningMessage.str() ;
00542 #endif
00543       }
00544    else 
00545       {
00546          newFather->addSon ( this ) ;
00547       }

void PsObjectDescriptor::setFrequency const PsFrequency   newFrequency [virtual]
 

change the frequency of the described object

Definition at line 249 of file PsObjectDescriptor.cxx.

Referenced by PsController::computeScheduling(), and PsController::reactToControlledObjectsSystemEvents().

00251 {
00252    _frequency = newFrequency ;
00253    
00254    PsUniqueConfigurationParameter * description = dynamic_cast<PsUniqueConfigurationParameter *>(_schedulingParameters->getSubDescriptorByName ("Frequency") );
00255 
00256    if ( description != NULL )
00257       {
00258 #ifdef _USESSTREAM
00259          ostringstream freq ;
00260          freq << newFrequency ;
00261          description->changeConfigurationParameter ( freq.str() ) ;
00262 #else
00263          ostrstream freq ;
00264          freq << newFrequency ;
00265          freq.put ('\0') ;
00266          description->changeConfigurationParameter ( freq.str() ) ;
00267          delete freq.str() ;
00268 #endif
00269       }
00270    else
00271       {
00272 #ifdef _USESSTREAM
00273          ostringstream freq ;
00274          freq << newFrequency ;
00275          _schedulingParameters->appendSubDescriptorNamed ("Frequency", 
00276                                                           new PsUniqueConfigurationParameter (freq.str() ) ) ;
00277 #else
00278          ostrstream freq ;
00279          freq << newFrequency ;
00280          freq.put ('\0') ;
00281          _schedulingParameters->appendSubDescriptorNamed ("Frequency", 
00282                                                           new PsUniqueConfigurationParameter (freq.str() ) ) ;
00283          delete freq.str() ;
00284 #endif
00285       }

void PsObjectDescriptor::setProcess const PsName   newProcessName [virtual]
 

change the process of the described object

Definition at line 234 of file PsObjectDescriptor.cxx.

References _processId, _schedulingParameters, PsMultipleConfigurationParameter::appendSubDescriptorNamed(), PsUniqueConfigurationParameter::changeConfigurationParameter(), PsName::getCString(), and PsMultipleConfigurationParameter::getSubDescriptorByName().

Referenced by PsDistributedController::createObject(), and PsController::setProcessOfDescriptor().

00236 {
00237    _processId = newProcessName ;
00238    PsUniqueConfigurationParameter * description = dynamic_cast<PsUniqueConfigurationParameter *>(_schedulingParameters->getSubDescriptorByName ("Process") );
00239    if ( description != NULL )
00240       {
00241          description->changeConfigurationParameter (newProcessName.getCString() ) ;
00242       }
00243    else
00244       {
00245          _schedulingParameters->appendSubDescriptorNamed ("Process", 
00246                                                           new PsUniqueConfigurationParameter (newProcessName.getCString() ) ) ;
00247          
00248       }

void PsObjectDescriptor::unpack PsIncomingSynchronisationMessage   [virtual]
 

unpack from a synchronisation message

Reimplemented from PsFlowable.

Definition at line 81 of file PsObjectDescriptor.cxx.

References extract().

00083 {
00084 #ifdef _USESSTREAM
00085    // but much simpler to decode
00086    string messageBuffer ;
00087 
00088    in>>messageBuffer ;
00089 
00090    istringstream message ( messageBuffer );
00091 
00092    extract (message ) ;
00093 #else
00094    // but much simpler to decode
00095    int messageSize ;
00096 
00097    in>>messageSize ;
00098    char * messageBuffer = new char [messageSize];
00099    in>>messageBuffer ;
00100 
00101    assert (messageBuffer[messageSize -1] == '\0' ) ; 
00102 
00103    istrstream message ( messageBuffer );
00104    extract (message ) ;
00105 #endif


Friends And Related Function Documentation

friend class PsController [friend]
 

make the controller a friend so that only controllers can ask for the creation of the described simulation object and change the father of an object

Definition at line 285 of file PsObjectDescriptor.h.

friend class PsnObjectHandle [friend]
 

make the object handle a friend so that only controllers can change the boolean indicating delete responsability

Definition at line 290 of file PsObjectDescriptor.h.

friend class PsSimulatedObject [friend]
 

make the simulated object friend so it can change the _pointerToSimulatedObject as early as possible

Definition at line 293 of file PsObjectDescriptor.h.


Member Data Documentation

PsName PsObjectDescriptor::_classId [protected]
 

decribed object's class

Definition at line 337 of file PsObjectDescriptor.h.

Referenced by extract(), and getClass().

PsConfigurationParameterDescriptor* PsObjectDescriptor::_configurationParameters [protected]
 

described object's configuration parameters (isn't const to enable extraction

Definition at line 340 of file PsObjectDescriptor.h.

Referenced by extract(), getConfigurationParameters(), PsObjectDescriptor(), and ~PsObjectDescriptor().

PsnCondition PsObjectDescriptor::_createdCondition [mutable, protected]
 

the condition to wait on if an other thread is creating the object

Definition at line 365 of file PsObjectDescriptor.h.

Referenced by createDescribedObject().

bool PsObjectDescriptor::_creatingObject [mutable, protected]
 

the boolean used to avoid recursive creation : should be accessed only protected

Definition at line 368 of file PsObjectDescriptor.h.

Referenced by createDescribedObject().

pthread_t PsObjectDescriptor::_creatingThread [mutable, protected]
 

the thread id of the creating lock

Definition at line 371 of file PsObjectDescriptor.h.

Referenced by createDescribedObject().

PsnMutexLock PsObjectDescriptor::_dataLock [mutable, protected]
 

the lock to access _creatingObject and _creatingThread

Definition at line 362 of file PsObjectDescriptor.h.

Referenced by createDescribedObject().

bool PsObjectDescriptor::_destroySimulatedObject [mutable, protected]
 

a pointer indicating if _pointerToSimulatedObject is deletable by this object

Definition at line 319 of file PsObjectDescriptor.h.

Referenced by createDescribedObject(), deleteCachedData(), PsController::PsController(), and PsnObjectHandle::PsnObjectHandle().

PsObjectDescriptor* PsObjectDescriptor::_fathersDescription [protected]
 

a pointer to the objects father in the simulation tree

Definition at line 349 of file PsObjectDescriptor.h.

Referenced by addSon(), createDescribedObject(), getFathersObjectDescriptor(), setFathersDescription(), and ~PsObjectDescriptor().

PsFrequency PsObjectDescriptor::_frequency [private]
 

decribed object's current frequency (stored to avoid reinterpreting the scheduling parameters)

Definition at line 377 of file PsObjectDescriptor.h.

Referenced by getFrequency(), and interpretSchedulingParameters().

PsName PsObjectDescriptor::_objectName [protected]
 

decribed object's name

Definition at line 334 of file PsObjectDescriptor.h.

Referenced by extract(), and getName().

PsFrequency PsObjectDescriptor::_originalFrequency [private]
 

decribed object's current frequency (stored to avoid reinterpreting the scheduling parameters)

Definition at line 380 of file PsObjectDescriptor.h.

Referenced by getOriginalFrequency(), and interpretSchedulingParameters().

PsMultipleConfigurationParameter* PsObjectDescriptor::_originalSchedulingParameters [protected]
 

described object's scheduling parameters

Definition at line 343 of file PsObjectDescriptor.h.

Referenced by getOriginalSchedulingParameters(), interpretSchedulingParameters(), PsObjectDescriptor(), and ~PsObjectDescriptor().

PsSimulatedObject* PsObjectDescriptor::_pointerToSimulatedObject [mutable, protected]
 

if a simulated object corresponding to this descriptor has been created, a pointer to this object is memorised here.

destruction of this object is the responsability of the descriptor only if _destroySimulatedObject is true

Definition at line 313 of file PsObjectDescriptor.h.

Referenced by createDescribedObject(), deleteCachedData(), PsController::deleteObjectHandle(), PsController::PsController(), PsSimulatedObject::PsSimulatedObject(), ~PsObjectDescriptor(), and PsSimulatedObject::~PsSimulatedObject().

PsName PsObjectDescriptor::_processId [private]
 

decribed object's current process (stored to avoid reinterpreting the scheduling parameters)

Definition at line 374 of file PsObjectDescriptor.h.

Referenced by getProcess(), interpretSchedulingParameters(), and setProcess().

PsMultipleConfigurationParameter* PsObjectDescriptor::_schedulingParameters [protected]
 

described object's scheduling parameters

Definition at line 346 of file PsObjectDescriptor.h.

Referenced by getSchedulingParameters(), interpretSchedulingParameters(), PsObjectDescriptor(), setProcess(), and ~PsObjectDescriptor().

SonsContainerType PsObjectDescriptor::_sonsContainer [protected]
 

a container with all of the sons of an object.

Order of sons in the container should be conseidered meaningless

Definition at line 355 of file PsObjectDescriptor.h.

Referenced by addSon(), extract(), findDescendantNamed(), getDescendants(), getSons(), interpretConfigurationParameterAsObjectDescription(), listDescendantsOfType(), listSonsOfType(), printToStream(), PsObjectDescriptor(), removeSon(), and ~PsObjectDescriptor().


The documentation for this class was generated from the following files:
logo OpenMask

Documentation generated on Mon Nov 25 15:26:17 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001