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

PsName Class Reference

class for naming things in Mask. More...

#include <PsName.h>

Inheritance diagram for PsName:

Inheritance graph
[legend]
Collaboration diagram for PsName:

Collaboration graph
[legend]
List of all members.

redefine standard operators

virtual PsName & operator= (const PsName &)
 affectation

virtual PsName & operator= (const PsString &)
 affectation

virtual PsName & operator= (const char *)
 affectation

virtual PsName & operator= (const string &)
 affectation

bool operator== (const PsName &first, const PsName &second)
 compare.

bool operator!= (const PsName &first, const PsName &second)
 compare.

int operator< (const PsName &Source1, const PsName &Source2)
 smaller than here, lexicographic ordre isn't used.

int operator> (const PsName &Source1, const PsName &Source2)
 greater than here, lexicographic ordre isn't used.

int operator<= (const PsName &Source1, const PsName &Source2)
 smaller than or equal to here, lexicographic ordre isn't used.

int operator>= (const PsName &Source1, const PsName &Source2)
 greater than or equal to here, lexicographic ordre isn't used.


Public Types

typedef long idType
 real type of name identifiers


Public Methods

 PsName ()
 Default contructor.

 PsName (const PsString &)
 Construction from a PsString.

 PsName (const char *)
 Construction from a char * (getCString).

 PsName (const string &)
 Construction from a standard string.

 PsName (const PsName &)
 copy constructor

virtual ~PsName ()
 Destructor.

virtual PsPolatorNTcreatePolator (void)
 Creation a Polator for names, a PsName derives from PsType.

virtual const char * getCString () const
 get C style string corresponding to name

virtual const PsStringgetPsString () const
 get PsString correponding to name

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

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

virtual void unpack (PsIncomingSynchronisationMessage &)
 unpack from a message

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


Static Public Methods

PsNameServergetNameServer ()
 get the name server.

void setNameServer (PsNameServer *)
 change the name server will only have any effect if the new name server is equivalent to the old one


Static Public Attributes

const idType _maxReservedId = 18
 max id of reserved ids (reserved ids are called system ids)


Protected Methods

virtual void changeId (idType oldId, idType newId)
 a protected member function to enable change of the id by the name server

 PsName (idType)
 constructor using the associated id.


Protected Attributes

idType _identifier
 the identifier used to store the name


Static Protected Attributes

PsNameServer_nameServer = getNameServer()
 the current name server


Friends

struct hashFunctionObject
struct equalToFunctionObject
struct lessThanFunctionObject
class PsNameServer
class PsnOutputOffsetTable
 declaring PsnOutputOffsetTable as friend class so as to optimize place usage when using shared memory


Detailed Description

class for naming things in Mask.

for efficiency reasons, name appear to the user as human readable strings but are in fact identifiers. correpondance between an identifier and a human readable string is kept by the name server The following PsNames are reserved id :

Definition at line 44 of file PsName.h.


Member Typedef Documentation

typedef long PsName::idType
 

real type of name identifiers

Definition at line 190 of file PsName.h.

Referenced by PsNameServer::changeNamesId(), PsNoRefCountingNameServer< STLallocator >::created(), PsNameServerT< STLallocator >::created(), PsNoRefCountingNameServer< STLallocator >::deleted(), PsNameServerT< STLallocator >::deleted(), extract(), PsNoRefCountingNameServer< STLallocator >::getIdentifier(), PsNameServerT< STLallocator >::getIdentifier(), PsNoRefCountingNameServer< STLallocator >::getIdentifierAsFrom(), PsNameServerT< STLallocator >::getIdentifierAsFrom(), PsNoRefCountingNameServer< STLallocator >::getNamesOfId(), PsNameServerT< STLallocator >::getNamesOfId(), PsNoRefCountingNameServer< STLallocator >::getStringAssociatedTo(), PsNameServerT< STLallocator >::getStringAssociatedTo(), PsNoRefCountingNameServer< STLallocator >::getSystemIdentifier(), PsNameServerT< STLallocator >::getSystemIdentifier(), operator=(), PsEventIdentifier::PsEventIdentifier(), PsnSvm::serveNameRequestsUntilEnd(), and unpack().


Constructor & Destructor Documentation

PsName::PsName  
 

Default contructor.

Definition at line 70 of file PsName.cxx.

References _identifier, PsNameServer::created(), and getNameServer().

00071 {
00072 #ifdef _DEBUGNOMSYM
00073    cerr<<"PsName::PsName()"<<endl;
00074 #endif
00075    _identifier=0;
00076    getNameServer()->created( _identifier, this );
00077 #ifdef _DEBUGNOMSYM
00078    cerr<<"PsName::PsName() fin"<<endl;
00079 #endif
00080 }

PsName::PsName const PsString  
 

Construction from a PsString.

Definition at line 112 of file PsName.cxx.

References _identifier, PsNameServer::created(), PsNameServer::getIdentifier(), and getNameServer().

00113 {
00114 #ifdef _DEBUGNOMSYM
00115    cerr<<"PsName::PsName(const PsString & nom)"<<endl;
00116 #endif
00117    _identifier=getNameServer()->getIdentifier (nom) ;
00118 
00119    getNameServer()->created(_identifier, this);
00120 #ifdef _DEBUGNOMSYM
00121    cerr<<"PsName::PsName(const PsString & nom) done"<<endl;
00122 #endif
00123 }

PsName::PsName const char *   
 

Construction from a char * (getCString).

Definition at line 82 of file PsName.cxx.

References _identifier, PsNameServer::created(), PsNameServer::getIdentifier(), and getNameServer().

00083 {
00084 #ifdef _DEBUGNOMSYM
00085    cerr<<"PsName::PsName(const char * "<<(void*)nom<<")"<<endl;
00086    cerr<<"Serveur de Nom = "<<(void*)getNameServer()<<endl;
00087 #endif
00088    _identifier = getNameServer()->getIdentifier(PsString(nom));
00089    getNameServer()->created( _identifier, this ) ;
00090 #ifdef _DEBUGNOMSYM
00091    cerr<<"PsName::PsName(const char * nom) fin"<<endl;
00092 #endif
00093 }

PsName::PsName const string &   
 

Construction from a standard string.

Definition at line 97 of file PsName.cxx.

References _identifier, PsNameServer::created(), PsNameServer::getIdentifier(), and getNameServer().

00098 {
00099 #ifdef _DEBUGNOMSYM
00100    cerr<<"PsName::PsName(const string & "<<name<<")"<<endl;
00101    cerr<<"Name server =  "<<(void*)getNameServer()<<endl;
00102 #endif
00103    _identifier = getNameServer()->getIdentifier(PsString(name));
00104    getNameServer()->created( _identifier, this ) ;
00105 #ifdef _DEBUGNOMSYM
00106    cerr<<"PsName::PsName(const string & ) done"<<endl;
00107 #endif
00108 }

PsName::PsName const PsName &   
 

copy constructor

Definition at line 125 of file PsName.cxx.

References _identifier, PsNameServer::created(), and getNameServer().

00126 {
00127 #ifdef _DEBUGNOMSYM
00128    cerr<<"PsName::PsName(const PsName & aCopier)"<<endl;
00129 #endif
00130 
00131    _identifier = aCopier._identifier;
00132    getNameServer()->created(_identifier,this);
00133 
00134 #ifdef _DEBUGNOMSYM
00135    cerr<<"PsName::PsName(const PsName & aCopier) fait"<<endl;
00136 #endif
00137 } 

PsName::~PsName   [virtual]
 

Destructor.

Definition at line 139 of file PsName.cxx.

References _identifier, PsNameServer::deleted(), and getNameServer().

00140 {
00141    getNameServer()->deleted( _identifier, this );
00142 }

PsName::PsName idType    [explicit, protected]
 

constructor using the associated id.

It's usage is reserved for the creation of system identifiers

Definition at line 57 of file PsName.cxx.

References _identifier, _maxReservedId, PsNameServer::created(), and getNameServer().

00058 {
00059 #ifdef _DEBUGNOMSYM
00060    cerr<<"PsName::PsName(idType i)"<<endl;
00061 #endif
00062    assert ( i < _maxReservedId ) ;
00063    _identifier = i ;
00064    getNameServer()->created( _identifier , this );
00065 #ifdef _DEBUGNOMSYM
00066    cerr<<"PsName::PsName(idType i) fin"<<endl;   
00067 #endif
00068 }


Member Function Documentation

void PsName::changeId idType    oldId,
idType    newId
[protected, virtual]
 

a protected member function to enable change of the id by the name server

Parameters:
oldId only used for verifications
newId the new id to use

Definition at line 300 of file PsName.cxx.

References _identifier.

Referenced by PsNameServer::changeNamesId().

00301 {
00302    //cerr<<"PsName::changeId ( "<<oldId<<", "<<newId<<" ) "<<endl;
00303    //this is called by the name server : do not need to call back to keep the books
00304    assert ( oldId == _identifier ) ;
00305 
00306    _identifier = newId ;
00307 }

PsPolatorNT * PsName::createPolator void    [virtual]
 

Creation a Polator for names, a PsName derives from PsType.

Implements PsType.

Definition at line 146 of file PsName.cxx.

00147 {
00148    return new PsPolator<PsName>();
00149 }

void PsName::extract istream &    in [virtual]
 

Extract from a stream.

Implements PsFlowable.

Definition at line 184 of file PsName.cxx.

References _identifier, PsNameServer::created(), PsNameServer::deleted(), PsNameServer::getIdentifier(), getNameServer(), and idType.

00185 {
00186    PsString nom;
00187    in>>nom;
00188    idType oldIdentifier = _identifier ;
00189 
00190    _identifier = getNameServer()->getIdentifier ( nom );
00191 
00192    getNameServer()->created( _identifier, this );
00193 
00194    getNameServer()->deleted( oldIdentifier, this );
00195 }

const char * PsName::getCString   const [virtual]
 

get C style string corresponding to name

Definition at line 152 of file PsName.cxx.

References _identifier, and getNameServer().

Referenced by PsOutput< Type >::getDateOfLastExactValue(), PsOutput< Type >::getLastExactValue(), PsOutput< Type >::localInsert(), PsName::hashFunctionObject::operator()(), PsObjectDescriptor::PsObjectDescriptor(), PsController::reactToControlledObjectsSystemEvents(), and PsObjectDescriptor::setProcess().

00153 {
00154 #ifdef _DEBUGNOMSYM
00155    cerr<<"PsName::getCString()"<<endl;
00156 #endif
00157    const char * resul((getNameServer()->getStringAssociatedTo(_identifier)).getCString());
00158 #ifdef _DEBUGNOMSYM
00159    cerr<<"PsName::getCString() fin"<<endl;
00160 #endif
00161    return resul ;
00162 }

PsNameServer * PsName::getNameServer   [static]
 

get the name server.

If no name server has been set yet, a default name server is created

Definition at line 30 of file PsName.cxx.

References _nameServer, and PsClassicalNameServer.

Referenced by PsnSvm::connectToDistributedSimulation(), PsController::destroyObject(), extract(), getCString(), getPsString(), insertInStream(), operator=(), PsMomeController::PsMomeController(), PsMultiThreadedController::PsMultiThreadedController(), PsName(), PsnSvm::serveNameRequestsUntilEnd(), unpack(), PsMomeController::~PsMomeController(), and ~PsName().

00031 {
00032    static bool initialised = false ;
00033    if ( ! initialised )
00034       {
00035          _nameServer = new PsClassicalNameServer () ;
00036          initialised = true ;
00037       }
00038    return _nameServer ;
00039 }

const PsString & PsName::getPsString   const [virtual]
 

get PsString correponding to name

Definition at line 164 of file PsName.cxx.

References _identifier, getNameServer(), and PsNameServer::getStringAssociatedTo().

00165 {
00166 #ifdef _DEBUGNOMSYM
00167    cerr<<"PsName::getPsString()"<<endl;
00168 #endif
00169    return getNameServer()->getStringAssociatedTo(_identifier);
00170 #ifdef _DEBUGNOMSYM
00171    cerr<<"PsName::getPsString() fin"<<endl;
00172 #endif
00173 }

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

Insert in a stream.

Implements PsFlowable.

Definition at line 176 of file PsName.cxx.

References _identifier, getNameServer(), and PsNameServer::getStringAssociatedTo().

00177 {
00178 //     cerr<<"PsName::insertInStream of id "<<_identifier<<endl;
00179 //     cerr<<"PsName::insertInStream of "<<getNameServer()->getStringAssociatedTo(_identifier)<<endl;
00180    out <<getNameServer()->getStringAssociatedTo(_identifier);
00181 }

PsName & PsName::operator= const string &    [virtual]
 

affectation

Definition at line 202 of file PsName.cxx.

References _identifier, PsNameServer::created(), PsNameServer::deleted(), PsNameServer::getIdentifier(), getNameServer(), and idType.

00203 {
00204    // copy into onself : creation must happen before deletion
00205    idType oldIdentifier = _identifier ;
00206 
00207    _identifier = getNameServer()->getIdentifier( original );
00208 
00209    getNameServer()->created(_identifier, this);
00210 
00211    getNameServer()->deleted( oldIdentifier, this );
00212 
00213    return *this;
00214 }

PsName & PsName::operator= const char *    [virtual]
 

affectation

Definition at line 217 of file PsName.cxx.

References _identifier, PsNameServer::created(), PsNameServer::deleted(), PsNameServer::getIdentifier(), getNameServer(), and idType.

00218 {
00219    // copy into onself
00220    idType oldIdentifier = _identifier ;
00221 
00222    _identifier = getNameServer()->getIdentifier( original );
00223    getNameServer()->created( _identifier, this );
00224 
00225    getNameServer()->deleted( oldIdentifier, this );
00226 
00227    return *this;
00228 }

PsName & PsName::operator= const PsString   [virtual]
 

affectation

Definition at line 231 of file PsName.cxx.

References _identifier, PsNameServer::created(), PsNameServer::deleted(), PsNameServer::getIdentifier(), getNameServer(), and idType.

00232 {
00233    // copy into onself
00234    idType oldIdentifier = _identifier ;
00235 
00236    _identifier = getNameServer()->getIdentifier( original );
00237    getNameServer()->created( _identifier, this );
00238 
00239    getNameServer()->deleted( oldIdentifier, this );
00240 
00241    return *this;
00242 }

PsName & PsName::operator= const PsName &    [virtual]
 

affectation

Definition at line 245 of file PsName.cxx.

References _identifier, PsNameServer::created(), PsNameServer::deleted(), getNameServer(), and idType.

00246 {
00247    // copy into onself
00248    idType oldIdentifier = _identifier ;
00249 
00250    _identifier=aCopier._identifier;
00251    getNameServer()->created( _identifier, this );
00252 
00253    getNameServer()->deleted( oldIdentifier, this );
00254 
00255    return *this;
00256 }

void PsName::pack PsOutgoingSynchronisationMessage   const [virtual]
 

pack in a message

Reimplemented from PsFlowable.

Definition at line 295 of file PsName.cxx.

References _identifier.

Referenced by PsOutput< Type >::pack(), PsnProcess::pack(), PsOutput< Type >::packAllValues(), PsnPvmReferenceObjectHandle::packInitialValues(), and PsnMirrorObjectHandle::registerToReferenceObject().

00296 {
00297   out<<_identifier ;
00298 }

void PsName::setNameServer PsNameServer   [static]
 

change the name server will only have any effect if the new name server is equivalent to the old one

Definition at line 43 of file PsName.cxx.

References _nameServer, and PsNameServer::includes().

Referenced by PsnSvm::connectToDistributedSimulation(), PsMomeController::PsMomeController(), PsMultiThreadedController::PsMultiThreadedController(), PsnSvm::serveNameRequestsUntilEnd(), and PsMomeController::~PsMomeController().

00044 {
00045    // the new name server is only installed if it has the same pairs <id,char *> as the old one.
00046   if ( newNameServer->includes( *_nameServer ) ) 
00047     {
00048      _nameServer = newNameServer ;
00049     }
00050   else 
00051     {
00052       cerr<<"WARNING : the name server wasn't changed because it wasn't equal to the old one"<<endl;
00053     }
00054 }

void PsName::unpack PsIncomingSynchronisationMessage   [virtual]
 

unpack from a message

Reimplemented from PsFlowable.

Definition at line 284 of file PsName.cxx.

References _identifier, PsNameServer::created(), PsNameServer::deleted(), getNameServer(), and idType.

Referenced by PsSimulatedObject::unpack(), PsnPvmReferenceObjectHandle::unpack(), and PsSimulatedObject::unpackAllValues().

00285 {
00286    idType oldIdentifier = _identifier ;
00287 
00288    in>>_identifier ;
00289    getNameServer()->created( _identifier, this ); 
00290 
00291    getNameServer()->deleted( oldIdentifier, this ); 
00292 }


Friends And Related Function Documentation

friend struct equalToFunctionObject [friend]
 

Definition at line 217 of file PsName.h.

friend struct hashFunctionObject [friend]
 

Definition at line 206 of file PsName.h.

friend struct lessThanFunctionObject [friend]
 

Definition at line 225 of file PsName.h.

bool operator!= const PsName &    first,
const PsName &    second
[friend]
 

compare.

inlined because == is heavely used in the maps of the kernel

Definition at line 142 of file PsName.h.

00143    {
00144       return first._identifier != second._identifier;
00145    }

int operator< const PsName &    premier,
const PsName &    second
[friend]
 

smaller than here, lexicographic ordre isn't used.

Definition at line 259 of file PsName.cxx.

00260 { 
00261    return premier._identifier < second._identifier; 
00262 }

int operator<= const PsName &    premier,
const PsName &    second
[friend]
 

smaller than or equal to here, lexicographic ordre isn't used.

Definition at line 271 of file PsName.cxx.

00272 { 
00273    return premier._identifier <= second._identifier; 
00274 }

bool operator== const PsName &    first,
const PsName &    second
[friend]
 

compare.

inlined because heavely used in the maps of the kernel

Definition at line 134 of file PsName.h.

00135    {
00136       return first._identifier == second._identifier;
00137    }

int operator> const PsName &    premier,
const PsName &    second
[friend]
 

greater than here, lexicographic ordre isn't used.

Definition at line 265 of file PsName.cxx.

00266 { 
00267    return premier._identifier > second._identifier; 
00268 }

int operator>= const PsName &    premier,
const PsName &    second
[friend]
 

greater than or equal to here, lexicographic ordre isn't used.

Definition at line 278 of file PsName.cxx.

00279 { 
00280    return premier._identifier >= second._identifier; 
00281 }

friend class PsNameServer [friend]
 

Definition at line 228 of file PsName.h.

friend class PsnOutputOffsetTable [friend]
 

declaring PsnOutputOffsetTable as friend class so as to optimize place usage when using shared memory

Definition at line 245 of file PsName.h.


Member Data Documentation

idType PsName::_identifier [protected]
 

the identifier used to store the name

Definition at line 250 of file PsName.h.

Referenced by changeId(), extract(), getCString(), getPsString(), insertInStream(), PsEventIdentifier::isSystemEvent(), operator!=(), PsName::lessThanFunctionObject::operator()(), PsName::equalToFunctionObject::operator()(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), pack(), PsName(), unpack(), and ~PsName().

const PsName::idType PsName::_maxReservedId = 18 [static]
 

max id of reserved ids (reserved ids are called system ids)

Definition at line 27 of file PsName.cxx.

Referenced by PsNoRefCountingNameServer< STLallocator >::getSystemIdentifier(), PsNameServerT< STLallocator >::getSystemIdentifier(), PsEventIdentifier::isSystemEvent(), PsName(), and PsNameServerT< STLallocator >::PsNameServerT().

PsNameServer * PsName::_nameServer = getNameServer() [static, protected]
 

the current name server

Definition at line 26 of file PsName.cxx.

Referenced by getNameServer(), and setNameServer().


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

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

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