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

PsMultipleConfigurationParameter Class Reference

class PsMultipleConfigurationParameter : stores multiple configuration parameters. More...

#include <PsMultipleConfigurationParameter.h>

Inheritance diagram for PsMultipleConfigurationParameter:

Inheritance graph
[legend]
Collaboration diagram for PsMultipleConfigurationParameter:

Collaboration graph
[legend]
List of all members.

Public Methods

 PsMultipleConfigurationParameter ()
 constructor

 PsMultipleConfigurationParameter (const PsMultipleConfigurationParameter &)
 copy constructor

virtual ~PsMultipleConfigurationParameter ()
 destructor

virtual const string & getAssociatedString () const
 get a string representation of these configuration parameters

virtual const PsConfigurationParameterDescriptorgetSubDescriptorByName (const string &descriptorName) const
 get a named subdescriptor

virtual const PsConfigurationParameterDescriptorgetSubDescriptorByPosition (int descriptorPosition) const
 get a subdescriptor by it's position

virtual PsConfigurationParameterDescriptorgetSubDescriptorByName (const string &descriptorName)
 get a named subdescriptor

virtual PsConfigurationParameterDescriptorgetSubDescriptorByPosition (int descriptorPosition)
 get a subdescriptor by it's position

virtual const string & getNameOfSubDescriptor (int descriptorPosition) const
 get a the name of a subdescriptor of a certain position

virtual int getNumberOfSubItems () const
 get the number of subdescriptors

virtual int appendSubDescriptor (PsConfigurationParameterDescriptor *subDescriptor)
 add an unnamed subdescriptor

virtual int appendSubDescriptorNamed (const string &descriptorName, PsConfigurationParameterDescriptor *subDescriptor)
 add an named subdescriptor.

virtual int replaceSubDescriptorNamed (const string &descriptorName, PsConfigurationParameterDescriptor *subDescriptor)
 replace a named subdescriptor

virtual int replaceSubDescriptor (int position, PsConfigurationParameterDescriptor *subDescriptor)
 replace a named subdescriptor

virtual int appendSubDescriptorsOf (const PsMultipleConfigurationParameter &otherDescriptor)
 append all the descriptor contained in an other multipleConfigurationParameterDescriptor

virtual PsConfigurationParameterDescriptorclone () const
 create a clone of this configuration parameter

virtual void extract (istream &=cin)
 extraction from an input stream

virtual void insertInStream (ostream &=cout) const
 insertion in an output stream

virtual void printToStream (ostream &out, int offset) const
 pretty insertion in an output stream (using an offset value)

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

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


Protected Types

typedef pair< string, PsConfigurationParameterDescriptor * > DataContainedType
 define how individual subdescriptors are stored

typedef vector< DataContainedTypeDataContainerType
 define the data structure use to store all subdescriptors

typedef hash_map< string,
PsConfigurationParameterDescriptor *,
openMaskString_hash
FastAccessContainer
 define an additional data structure for fast acces to named subdescriptors


Protected Attributes

DataContainerType _subDescriptors
 this data structure contains all the elements of the descriptor

FastAccessContainer _hashtable
 this data structure serves as a fast access storage for named descriptors.

string _associatedString
 cache to construct the associated string

bool _associatedStringValid
 validity of the stored associated string


Detailed Description

class PsMultipleConfigurationParameter : stores multiple configuration parameters.

Author:
David Margery
Version:
1.1 (Revision , last change by $author$) 1.0->1.1 added fast access capability

Definition at line 36 of file PsMultipleConfigurationParameter.h.


Member Typedef Documentation

typedef pair<string, PsConfigurationParameterDescriptor *> PsMultipleConfigurationParameter::DataContainedType [protected]
 

define how individual subdescriptors are stored

Definition at line 122 of file PsMultipleConfigurationParameter.h.

Referenced by appendSubDescriptorsOf().

typedef vector< DataContainedType > PsMultipleConfigurationParameter::DataContainerType [protected]
 

define the data structure use to store all subdescriptors

Definition at line 125 of file PsMultipleConfigurationParameter.h.

typedef hash_map<string, PsConfigurationParameterDescriptor *, openMaskString_hash > PsMultipleConfigurationParameter::FastAccessContainer [protected]
 

define an additional data structure for fast acces to named subdescriptors

Definition at line 128 of file PsMultipleConfigurationParameter.h.


Constructor & Destructor Documentation

PsMultipleConfigurationParameter::PsMultipleConfigurationParameter  
 

constructor

Definition at line 81 of file PsMultipleConfigurationParameter.cxx.

Referenced by clone().

00082                                                                     :
00083    PsConfigurationParameterDescriptor (),
00084    _subDescriptors (),
00085    _associatedStringValid ( false ) 
00086 {
00087 
}

PsMultipleConfigurationParameter::PsMultipleConfigurationParameter const PsMultipleConfigurationParameter &   
 

copy constructor

Definition at line 36 of file PsMultipleConfigurationParameter.cxx.

References _associatedString, _associatedStringValid, _hashtable, _subDescriptors, hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::insert(), and vector< DataContainedType >::push_back().

00037                                                                                                                  :
00038    PsConfigurationParameterDescriptor ( orig ),
00039    _subDescriptors ()
00040 {
00041    if (orig._associatedStringValid)
00042       {
00043          _associatedStringValid = true ;
00044          _associatedString= orig._associatedString ;
00045       }
00046    else 
00047       {
00048          _associatedStringValid = false ;
00049       }
00050 
00051    //reconstruct the data containers after having duplicated the subdescriptors
00052    FastAccessContainer::const_iterator j ;
00053    for (DataContainerType::const_iterator i = orig._subDescriptors.begin() ;
00054         i != orig._subDescriptors.end() ;
00055         ++i)
00056       {
00057          PsConfigurationParameterDescriptor * subdescriptorCopy = (*i).second->clone() ;
00058          _subDescriptors.push_back( DataContainerType::value_type( (*i).first,
00059                                                                   subdescriptorCopy )
00060                                     ) ;
00061 
00062          j = orig._hashtable.find ((*i).first ) ;
00063          if ( j != orig._hashtable.end() )
00064             {
00065                _hashtable.insert ( FastAccessContainer::value_type ( (*i).first,
00066                                                                      subdescriptorCopy )
00067                                    ) ;
00068 
00069             }
00070       }
}

PsMultipleConfigurationParameter::~PsMultipleConfigurationParameter   [virtual]
 

destructor

Definition at line 89 of file PsMultipleConfigurationParameter.cxx.

References _subDescriptors, vector< DataContainedType >::begin(), and vector< DataContainedType >::end().

00091 {
00092    DataContainerType::iterator i ;
00093    for ( i = _subDescriptors.begin() ;
00094          i != _subDescriptors.end() ;
00095          i++ )
00096       {
00097          delete i->second ;
00098       }


Member Function Documentation

int PsMultipleConfigurationParameter::appendSubDescriptor PsConfigurationParameterDescriptor   subDescriptor [virtual]
 

add an unnamed subdescriptor

Implements PsConfigurationParameterDescriptor.

Definition at line 320 of file PsMultipleConfigurationParameter.cxx.

References _subDescriptors, vector< DataContainedType >::push_back(), and vector< DataContainedType >::size().

00322 {
00323    assert ( subDescriptor != NULL ) ;
00324    _subDescriptors.push_back ( DataContainedType ( string() ,subDescriptor ) ) ;
00325    return _subDescriptors.size() - 1 ;

int PsMultipleConfigurationParameter::appendSubDescriptorNamed const string &    descriptorName,
PsConfigurationParameterDescriptor   subDescriptor
[virtual]
 

add an named subdescriptor.

If a descriptor with the same name allready exist, replaces it

Implements PsConfigurationParameterDescriptor.

Definition at line 329 of file PsMultipleConfigurationParameter.cxx.

References _hashtable, _subDescriptors, hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::insert(), vector< DataContainedType >::push_back(), replaceSubDescriptorNamed(), pair< T1, T2 >::second, and vector< DataContainedType >::size().

Referenced by PsObjectDescriptor::interpretSchedulingParameters(), PsObjectDescriptor::PsObjectDescriptor(), replaceSubDescriptorNamed(), and PsObjectDescriptor::setProcess().

00331 {
00332    assert ( subDescriptor != NULL ) ;
00333    pair<FastAccessContainer::iterator ,bool > result = _hashtable.insert( FastAccessContainer::value_type(descriptorName, subDescriptor) ) ;
00334    // only add the sub descriptor if no subsdescriptor with the same name was allready added
00335    if (result.second)
00336       {
00337          _subDescriptors.push_back ( DataContainedType ( descriptorName, subDescriptor ) ) ;
00338       }
00339    else
00340       {
00341          replaceSubDescriptorNamed ( descriptorName, subDescriptor ) ;
00342       }
00343    return _subDescriptors.size() - 1 ;

int PsMultipleConfigurationParameter::appendSubDescriptorsOf const PsMultipleConfigurationParameter &    otherDescriptor [virtual]
 

append all the descriptor contained in an other multipleConfigurationParameterDescriptor

Returns:
the index of the last appended sub descriptor.

Definition at line 346 of file PsMultipleConfigurationParameter.cxx.

References _hashtable, _subDescriptors, PsController::AllWarnings, vector< DataContainedType >::begin(), DataContainedType, vector< DataContainedType >::end(), hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::erase(), PsConfigurationParameterDescriptor::getAssociatedString(), getSubDescriptorByName(), hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::insert(), vector< DataContainedType >::push_back(), replaceSubDescriptorNamed(), vector< DataContainedType >::size(), hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::size(), and PsController::warning().

00348 {
00349    if ( _hashtable.size() == 0 )
00350       {
00351          *this = otherDescriptor ;
00352       }
00353    else
00354       {
00355          string emptyString ; 
00356          for ( DataContainerType::const_iterator i = otherDescriptor._subDescriptors.begin() ;
00357                i != otherDescriptor._subDescriptors.end() ;
00358                ++i)
00359             {
00360                //_subDescriptors.push_back ( *i ) ;
00361                if ( (*i).first != emptyString )
00362                   {
00363                      PsConfigurationParameterDescriptor * existingDescriptor = getSubDescriptorByName ((*i).first) ;
00364                      if ( existingDescriptor == NULL )
00365                         {
00366                            PsConfigurationParameterDescriptor * newDescriptor =  (*i).second->clone() ;
00367                            
00368                            _hashtable.insert( FastAccessContainer::value_type ( (*i).first , newDescriptor ) ) ;
00369                            
00370                            _subDescriptors.push_back( DataContainedType((*i).first,newDescriptor) ) ;   
00371                         }
00372                      else
00373                         {
00374 #ifdef _USESSTREAM
00375                            ostringstream warningMessage ;
00376 #else                
00377                            ostrstream warningMessage ;
00378 #endif
00379                            warningMessage << "While merging two PsMultipleConfigurationParameter: "
00380                                           <<"2 subdescriptors named "<<(*i).first<<" found: ";
00381                            
00382                            PsMultipleConfigurationParameter * originalDescriptor ;
00383                            originalDescriptor = dynamic_cast<PsMultipleConfigurationParameter * > (existingDescriptor) ;
00384                            PsMultipleConfigurationParameter * appendedDescriptor ;
00385                            appendedDescriptor = dynamic_cast<PsMultipleConfigurationParameter * > ((*i).second) ;
00386                            if ( (originalDescriptor != NULL) &&
00387                                 (appendedDescriptor != NULL) )
00388                               {
00389                                  if ( originalDescriptor->_hashtable.size() == 0 )
00390                                     {
00391                                        //it is a list of values, replace
00392                                        replaceSubDescriptorNamed ((*i).first, appendedDescriptor) ;
00393                                     }
00394                                  else
00395                                     {
00396                                        originalDescriptor->appendSubDescriptorsOf ( *appendedDescriptor ) ; 
00397                                     }
00398                               }
00399                            else 
00400                               {
00401                                  _hashtable.erase ( (*i).first ) ;      
00402                                  
00403                                  //find (*i).first in the vector
00404                                  DataContainerType::iterator j = _subDescriptors.begin() ;
00405                                  
00406                                  //(*i).first should be present in the vector
00407                                  assert ( j != _subDescriptors.end() );
00408                                  while ( (*j).first != (*i).first )
00409                               {
00410                                  ++j ;
00411                                  assert ( j != _subDescriptors.end() );
00412                               }
00413                                  
00414                                  PsConfigurationParameterDescriptor * newDescriptor =  (*i).second->clone() ;
00415                                  
00416                                  _hashtable.insert( FastAccessContainer::value_type ( (*i).first , newDescriptor ) ) ;
00417 
00418                                  (*j).second = newDescriptor ;
00419                                  
00420                                  warningMessage<<"Replaced original value: that was "<<existingDescriptor->getAssociatedString() ;
00421                                  assert ( existingDescriptor != NULL ) ;
00422                                  delete existingDescriptor ;
00423                               }
00424 #ifdef _USESSTREAM
00425                            PsController::warning (warningMessage.str(), PsController::AllWarnings) ;
00426 #else
00427                            warningMessage.put('\0') ;
00428                            PsController::warning (warningMessage.str(), PsController::AllWarnings) ;
00429                            delete warningMessage.str() ;
00430 #endif
00431                         }
00432                   }
00433             }
00434       }
00435    return _subDescriptors.size() - 1 ;

PsConfigurationParameterDescriptor * PsMultipleConfigurationParameter::clone   const [virtual]
 

create a clone of this configuration parameter

Implements PsConfigurationParameterDescriptor.

Definition at line 73 of file PsMultipleConfigurationParameter.cxx.

References PsMultipleConfigurationParameter().

Referenced by PsObjectDescriptor::interpretSchedulingParameters(), and PsObjectDescriptor::PsObjectDescriptor().

00075 {
00076    return new PsMultipleConfigurationParameter( *this ) ;

void PsMultipleConfigurationParameter::extract istream &    = cin [virtual]
 

extraction from an input stream

Implements PsConfigurationParameterDescriptor.

Definition at line 557 of file PsMultipleConfigurationParameter.cxx.

References _hashtable, _subDescriptors, ANTLRToken, vector< DataContainedType >::clear(), hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::clear(), and genericKernelParser::multipleValue().

Referenced by unpack().

00559 {
00560    _hashtable.clear () ;
00561    _subDescriptors.clear () ;
00562 
00563    KernelIstreamLexer<istream> inputStream (in) ;
00564    DLGLexer scan( & inputStream ) ;
00565    ANTLRTokenBuffer pipe ( & scan ) ;
00566    ANTLRTokenPtr aToken = new ANTLRToken() ;
00567    scan.setToken(mytoken(aToken)) ;
00568    genericKernelParser extractor  ( &pipe ) ;
00569    extractor.init() ;
00570    extractor.multipleValue ( this ) ;

const string & PsMultipleConfigurationParameter::getAssociatedString   const [virtual]
 

get a string representation of these configuration parameters

Implements PsConfigurationParameterDescriptor.

Definition at line 102 of file PsMultipleConfigurationParameter.cxx.

References _associatedString, _associatedStringValid, _subDescriptors, vector< DataContainedType >::begin(), and getNumberOfSubItems().

00104 {
00105    if ( ! _associatedStringValid ) 
00106       {
00107          string emptyString ;
00108          int numberOfSubItems = getNumberOfSubItems() ;
00109          _associatedString = "{ \n" ;
00110          DataContainerType::const_iterator i = _subDescriptors.begin() ;
00111          for ( int j = 0 ;
00112                j != numberOfSubItems - 1;
00113                ++j )
00114             {
00115                //indent the subdescriptors
00116                _associatedString += "   " ;
00117                if ( i-> first != emptyString ) 
00118                   {
00119                      _associatedString += i-> first ;
00120                      _associatedString += " = " ;
00121                   }
00122                _associatedString += i->second->getAssociatedString() ;
00123                _associatedString += ",\n" ;
00124                i++ ;
00125             }
00126          //print the last item
00127          _associatedString += "   " ;
00128          if ( i-> first != emptyString ) 
00129             {
00130                _associatedString += i-> first ;
00131                _associatedString += " = " ;
00132             }
00133          _associatedString += i->second->getAssociatedString() ;
00134          _associatedString += "\n" ;
00135          
00136          
00137          _associatedString += "}" ;
00138       }
00139    _associatedStringValid = true ; 
00140    return _associatedString ;

const string & PsMultipleConfigurationParameter::getNameOfSubDescriptor int    descriptorPosition const [virtual]
 

get a the name of a subdescriptor of a certain position

Definition at line 291 of file PsMultipleConfigurationParameter.cxx.

References _subDescriptors, and vector< DataContainedType >::size().

Referenced by PsObjectDescriptor::interpretConfigurationParameterAsListOfSons().

00293 {
00294    assert (descriptorPosition < _subDescriptors.size() )  ;
00295    return _subDescriptors[descriptorPosition].first ;

int PsMultipleConfigurationParameter::getNumberOfSubItems   const [virtual]
 

get the number of subdescriptors

Implements PsConfigurationParameterDescriptor.

Definition at line 313 of file PsMultipleConfigurationParameter.cxx.

References _subDescriptors, and vector< DataContainedType >::size().

Referenced by getAssociatedString(), PsObjectDescriptor::interpretConfigurationParameterAsListOfSons(), and printToStream().

00315 {
00316    return _subDescriptors.size() ;

PsConfigurationParameterDescriptor * PsMultipleConfigurationParameter::getSubDescriptorByName const string &    descriptorName [virtual]
 

get a named subdescriptor

Implements PsConfigurationParameterDescriptor.

Definition at line 259 of file PsMultipleConfigurationParameter.cxx.

References _hashtable, hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::end(), and hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::find().

00261 {
00262    PsConfigurationParameterDescriptor * result = NULL ;
00263    FastAccessContainer::const_iterator i ;
00264    i = _hashtable.find (descriptorName) ;
00265    if ( i != _hashtable.end() )
00266       {
00267          result = i->second ;
00268          assert ( result != NULL ) ;
00269       }
00270    else
00271       {
00272         result = NULL ;
00273       }
00274    return result ;

const PsConfigurationParameterDescriptor * PsMultipleConfigurationParameter::getSubDescriptorByName const string &    descriptorName const [virtual]
 

get a named subdescriptor

Implements PsConfigurationParameterDescriptor.

Definition at line 241 of file PsMultipleConfigurationParameter.cxx.

References _hashtable, hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::end(), and hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::find().

Referenced by appendSubDescriptorsOf(), PsObjectDescriptor::extract(), PsObjectDescriptor::interpretConfigurationParameterAsObjectDescription(), PsObjectDescriptor::interpretSchedulingParameters(), PsMultiThreadedController::PsMultiThreadedController(), PsMultiThreadedPvmController::PsMultiThreadedPvmController(), and PsObjectDescriptor::setProcess().

00243 {
00244    PsConfigurationParameterDescriptor * result = NULL ;
00245    FastAccessContainer::const_iterator i ;
00246    i = _hashtable.find (descriptorName) ;
00247    if ( i != _hashtable.end() )
00248       {
00249          result = i->second ;
00250          assert ( result != NULL ) ;
00251       }
00252    else
00253       {
00254         result = NULL ;
00255       }
00256    return result ;

PsConfigurationParameterDescriptor * PsMultipleConfigurationParameter::getSubDescriptorByPosition int    descriptorPosition [virtual]
 

get a subdescriptor by it's position

Implements PsConfigurationParameterDescriptor.

Definition at line 298 of file PsMultipleConfigurationParameter.cxx.

References _subDescriptors, and vector< DataContainedType >::size().

00300 {
00301    if (descriptorPosition >= _subDescriptors.size() ) 
00302       {
00303          return NULL ;
00304       }
00305    else
00306       {
00307          assert ( _subDescriptors[descriptorPosition].second != NULL ) ;
00308          return _subDescriptors[descriptorPosition].second ;
00309       }

const PsConfigurationParameterDescriptor * PsMultipleConfigurationParameter::getSubDescriptorByPosition int    descriptorPosition const [virtual]
 

get a subdescriptor by it's position

Implements PsConfigurationParameterDescriptor.

Definition at line 278 of file PsMultipleConfigurationParameter.cxx.

References _subDescriptors, and vector< DataContainedType >::size().

Referenced by PsObjectDescriptor::interpretConfigurationParameterAsListOfSons().

00280 {
00281    if (descriptorPosition >= _subDescriptors.size() ) 
00282       {
00283          return NULL ;
00284       }
00285    else
00286       {
00287          assert ( _subDescriptors[descriptorPosition].second != NULL ) ;
00288          return _subDescriptors[descriptorPosition].second ;
00289       }

void PsMultipleConfigurationParameter::insertInStream ostream &    = cout const [virtual]
 

insertion in an output stream

Implements PsConfigurationParameterDescriptor.

Definition at line 552 of file PsMultipleConfigurationParameter.cxx.

References printToStream().

00554 {
00555    printToStream ( out, 0 ) ;

void PsMultipleConfigurationParameter::pack PsOutgoingSynchronisationMessage   const [virtual]
 

pack in a synchronisation message

Implements PsConfigurationParameterDescriptor.

Definition at line 501 of file PsMultipleConfigurationParameter.cxx.

References printToStream().

00503 {
00504 #ifdef _USESSTREAM
00505    ostringstream char_out ;
00506    printToStream ( char_out, 0 ) ;
00507    out<<char_out.str() ;
00508 #else
00509    ostrstream char_out ;
00510    printToStream ( char_out, 0 ) ;
00511    char_out.put ('\0') ;
00512    char * C_string = char_out.str() ;
00513    assert (C_string[char_out.pcount()-1] == '\0') ;
00514    out<<char_out.pcount() ;
00515    out<<C_string;
00516    delete C_string ;
00517 #endif

void PsMultipleConfigurationParameter::printToStream ostream &    out,
int    offset
const [virtual]
 

pretty insertion in an output stream (using an offset value)

Implements PsConfigurationParameterDescriptor.

Definition at line 143 of file PsMultipleConfigurationParameter.cxx.

References _hashtable, _subDescriptors, vector< DataContainedType >::begin(), hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::empty(), vector< DataContainedType >::end(), getNumberOfSubItems(), and printTabToStream().

Referenced by insertInStream(), pack(), and PsObjectDescriptor::printToStream().

00145 {
00146    string emptyString ;
00147    int numberOfSubItems = getNumberOfSubItems() ;
00148 
00149    DataContainerType::const_iterator i = _subDescriptors.begin() ;
00150    if ( i != _subDescriptors.end () ) 
00151       {
00152          bool inList ;
00153          if ( i->first == emptyString )
00154             {
00155                if ( ! _hashtable.empty() )
00156                   {
00157                      out<<endl;
00158                      printTabToStream(out,offset) ;
00159                      out << "{"  ;
00160                      out<<endl;
00161                      printTabToStream(out,offset+2) ;
00162                   }
00163                out << "[ " ;
00164                inList = true ;
00165             }
00166          else
00167             {
00168                out<<endl;
00169                printTabToStream(out,offset) ;
00170                out << "{"  ;
00171                inList = false ;
00172             }
00173          
00174          for ( int j = 0 ;
00175                j != numberOfSubItems ;
00176                ++j )
00177             {
00178                //at each step, if not printing a list of unamed values, new line has just been inserted
00179                if ( inList ) 
00180                   {
00181                      if ( i-> first != emptyString ) 
00182                         {
00183                            // the list was finished by the preceeding value
00184                            out << "]" ;
00185                            inList = false ;
00186                            out<<endl;
00187                            printTabToStream (out, offset + 2 ) ;
00188                            out<< i->first <<" ";
00189                            i->second->printToStream (out, offset + 2  ) ;
00190                         }
00191                      else 
00192                         {
00193                            i->second->printToStream (out, offset + 4  ) ;
00194                            out<<" ";
00195                         }
00196                   }
00197                else 
00198                   {
00199                      if ( i-> first == emptyString )
00200                         {
00201                            //starting a list
00202                            out << "[ " ;
00203                            inList = true ;
00204                            i->second->printToStream (out, offset + 4  ) ;
00205                            out<<" ";
00206                         }
00207                      else
00208                         {
00209                            out << endl ;
00210                            printTabToStream (out, offset + 2 ) ;
00211                            out<< i->first <<" " ;
00212                            i->second->printToStream (out, offset + 4  ) ;
00213                         }
00214                   }
00215                i++ ;
00216             }
00217          if (inList)
00218             {
00219                out<<"]";
00220                if ( ! _hashtable.empty() )
00221                   {
00222                      out<<endl;
00223                      printTabToStream (out, offset ) ;
00224                      out<<"}";
00225                   }
00226             }
00227          else
00228             {
00229                out<<endl;
00230                printTabToStream (out, offset ) ;
00231                out<<"}";
00232             }
00233       }
00234    else 
00235       {
00236          out<<" - undefined - ";
00237       }

int PsMultipleConfigurationParameter::replaceSubDescriptor int    position,
PsConfigurationParameterDescriptor   subDescriptor
[virtual]
 

replace a named subdescriptor

Definition at line 478 of file PsMultipleConfigurationParameter.cxx.

References _hashtable, _subDescriptors, hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::end(), hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::find(), and vector< DataContainedType >::size().

00480 {
00481    assert (position < _subDescriptors.size() ) ;
00482    string descriptorName = _subDescriptors[position].first ;
00483    string emptyString ;
00484    PsConfigurationParameterDescriptor * replacedDescription = _subDescriptors[position].second ;
00485 
00486    if ( descriptorName != emptyString ) 
00487       {
00488          FastAccessContainer::iterator i ;
00489          i = _hashtable.find (descriptorName) ;
00490   
00491          //the descriptor should be present in the hash table
00492          assert ( i != _hashtable.end() ) ;
00493          (*i).second = subDescriptor ;
00494       }
00495    delete replacedDescription ; 
00496    _subDescriptors[position].second = subDescriptor ;    
00497    return position ;

int PsMultipleConfigurationParameter::replaceSubDescriptorNamed const string &    descriptorName,
PsConfigurationParameterDescriptor   subDescriptor
[virtual]
 

replace a named subdescriptor

Definition at line 439 of file PsMultipleConfigurationParameter.cxx.

References _hashtable, _subDescriptors, appendSubDescriptorNamed(), vector< DataContainedType >::begin(), vector< DataContainedType >::end(), hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::end(), and hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::find().

Referenced by appendSubDescriptorNamed(), and appendSubDescriptorsOf().

00441 {
00442    FastAccessContainer::iterator i ;
00443    i = _hashtable.find (descriptorName) ;
00444    if ( i == _hashtable.end() ) 
00445       {
00446          return appendSubDescriptorNamed ( descriptorName, subDescriptor) ;
00447       }
00448    else 
00449       {
00450          int result = 0 ;
00451 
00452          //find descriptorName in the vector
00453          DataContainerType::iterator j = _subDescriptors.begin() ;
00454 
00455          //It should be present
00456          assert ( j != _subDescriptors.end() );
00457 
00458          while ( (*j).first != descriptorName )
00459             {
00460                ++j ;
00461                ++result ;
00462                //descriptorName should be present
00463                assert ( j != _subDescriptors.end() );
00464             }
00465          
00466          //delete the old descriptor
00467          delete (*i).second ;
00468          
00469          //replace it
00470          (*i).second = subDescriptor ;
00471          (*j).second = subDescriptor ;
00472 
00473          assert (_subDescriptors[result].second == subDescriptor) ;
00474          return result ;
00475       }

void PsMultipleConfigurationParameter::unpack PsIncomingSynchronisationMessage   [virtual]
 

unpack from a synchronisation message

Implements PsConfigurationParameterDescriptor.

Definition at line 519 of file PsMultipleConfigurationParameter.cxx.

References _hashtable, _subDescriptors, vector< DataContainedType >::clear(), hash_map< string, PsConfigurationParameterDescriptor *, openMaskString_hash >::clear(), and extract().

00521 {
00522    _hashtable.clear () ;
00523    _subDescriptors.clear () ;
00524 
00525    int messageSize ;
00526 
00527 #ifdef _USESSTREAM
00528    string messageBuffer ;
00529    in>>messageBuffer ;
00530    istringstream message ( messageBuffer ) ;
00531 #else
00532    in>>messageSize ;
00533    char * messageBuffer = new char [messageSize + 1];
00534    in>>messageBuffer ;
00535 
00536    assert (messageBuffer[messageSize] == '\0' ) ; 
00537 
00538    istrstream message ( messageBuffer );
00539 #endif
00540    extract (message ) ;
00541    
00542 //     //this doesn't work, because a IncomingSynchronisationMessage dosn't known the size of what has to be extracted
00543 //     KernelIstreamLexer<PsIncomingSynchronisationMessage> inputStream (in) ;
00544 //     DLGLexer scan( & inputStream ) ;
00545 //     ANTLRTokenBuffer pipe ( & scan ) ;
00546 //     ANTLRTokenPtr aToken = new ANTLRToken() ;
00547 //     scan.setToken(mytoken(aToken)) ;
00548 //     genericKernelParser extractor  ( &pipe ) ;
00549 //     extractor.init() ;
00550 //     extractor.multipleValue ( this ) ;


Member Data Documentation

string PsMultipleConfigurationParameter::_associatedString [mutable, protected]
 

cache to construct the associated string

Definition at line 138 of file PsMultipleConfigurationParameter.h.

Referenced by getAssociatedString(), and PsMultipleConfigurationParameter().

bool PsMultipleConfigurationParameter::_associatedStringValid [mutable, protected]
 

validity of the stored associated string

Definition at line 141 of file PsMultipleConfigurationParameter.h.

Referenced by getAssociatedString(), and PsMultipleConfigurationParameter().

FastAccessContainer PsMultipleConfigurationParameter::_hashtable [protected]
 

this data structure serves as a fast access storage for named descriptors.

All named descriptors are also present in _subDescriptors

Definition at line 135 of file PsMultipleConfigurationParameter.h.

Referenced by appendSubDescriptorNamed(), appendSubDescriptorsOf(), extract(), getSubDescriptorByName(), printToStream(), PsMultipleConfigurationParameter(), replaceSubDescriptor(), replaceSubDescriptorNamed(), and unpack().

DataContainerType PsMultipleConfigurationParameter::_subDescriptors [protected]
 

this data structure contains all the elements of the descriptor

Definition at line 131 of file PsMultipleConfigurationParameter.h.

Referenced by appendSubDescriptor(), appendSubDescriptorNamed(), appendSubDescriptorsOf(), extract(), getAssociatedString(), getNameOfSubDescriptor(), getNumberOfSubItems(), getSubDescriptorByPosition(), printToStream(), PsMultipleConfigurationParameter(), replaceSubDescriptor(), replaceSubDescriptorNamed(), unpack(), and ~PsMultipleConfigurationParameter().


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

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

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