#include <PsNameServerT.h>
Inheritance diagram for PsNameServerT< STLallocator >:


Public Methods | |
| PsNameServerT () | |
| default constructor. | |
| PsNameServerT (const PsNameServer::CanonicalRepresentationType *) | |
| construction of a name server conformant to a canonical representation | |
| virtual | ~PsNameServerT () |
| destruction | |
| virtual long | getIdentifier (const PsString &) |
| get the id corresponding to a string if the string is unknown to the name server, a new id will be added | |
| virtual long | getSystemIdentifier (const PsString &) |
| get the id corresponding to a string the string should correspond to a reserverd string | |
| virtual long | getIdentifierAsFrom (const PsString &, long *nextId) |
| get the id corresponding to a string, using a specified nextId counter used to implement getIdentifier and getSystemIdentifier | |
| virtual const PsString & | getStringAssociatedTo (PsName::idType id) const |
| get the string associated to an id | |
| void * | operator new (size_t) |
| redefine new so that the nameserver is located in the same memory space than it's data structures and their elements | |
| void | operator delete (void *ptr, size_t n) |
| redefine delete 'cause new was redefined | |
| virtual void | created (PsName::idType id, PsName *) |
| a new PsName of id id was created | |
| virtual void | deleted (PsName::idType id, PsName *) |
| a PsName of id id was deleted | |
| CanonicalRepresentationType * | getCanonicalRepresentation () const |
| get the canonical representation once used, the result should be deleted | |
| virtual const list< PsName * > & | getNamesOfId (PsName::idType) const |
| get a list of pointers to the PsNames corresponding to an id | |
Protected Types | |
| typedef hash_map< PsString, long, PsString_hash,equal_to< PsString >, STLallocator< pair< PsString, long > > > | correspondenceContainerType |
| reference data structure type | |
| typedef map< long, typename correspondenceContainerType::iterator, less< long >, STLallocator< pair< const long, typename correspondenceContainerType::iterator > > > | fastStringAccessTableType |
| fast access data structure type | |
| typedef hash_map< PsName::idType, int, hash< PsName::idType >, equal_to< PsName::idType >, STLallocator< pair< PsName::idType, int > > > | referenceCountingContainerType |
| reference counting data structure type | |
| typedef hash_map< PsName::idType, list< PsName * > *, hash< PsName::idType >, equal_to< PsName::idType >, STLallocator< pair< PsName::idType, int > > > | placeOfNamesContainerType |
| reference counting data structure type | |
Protected Methods | |
| virtual void | lock () const |
| lock data in a multithread environment | |
| virtual void | unlock () const |
| unlock data in a multithread environment | |
Protected Attributes | |
| PsnMutexLock | _ourDataLock |
| the lock for multi-threaded environements | |
| long | _nextIdentifier |
| nextIdentifier to use | |
| long | _nextSystemIdentifier |
| next System Identifier to use | |
| fastStringAccessTableType | _fastStringAccessTable |
| fast access data structure | |
| correspondenceContainerType | _stringToIdCorrespondenceContainer |
| table holding String - id correspondance | |
| referenceCountingContainerType | _tableNbInstances |
| table holding reference counting | |
| placeOfNamesContainerType | _idToNamesUsingIdContainer |
| table holding the list of PsNames memory spaces using a given id | |
Therefore, it comes in two flavours, depending of the type of allocators used by the underlying standard library.
Definition at line 36 of file PsNameServerT.h.
|
|||||
|
reference data structure type
Definition at line 131 of file PsNameServerT.h. |
|
|||||
|
fast access data structure type
Definition at line 134 of file PsNameServerT.h. |
|
|||||
|
reference counting data structure type
Definition at line 140 of file PsNameServerT.h. |
|
|||||
|
reference counting data structure type
Definition at line 137 of file PsNameServerT.h. |
|
|||||||||
|
||||||||||
|
construction of a name server conformant to a canonical representation
Definition at line 191 of file PsNameServerT.h. References PsNameServerT< STLallocator >::_fastStringAccessTable, PsNameServerT< STLallocator >::_nextIdentifier, PsNameServerT< STLallocator >::_stringToIdCorrespondenceContainer, PsNameServerT< STLallocator >::_tableNbInstances, list< Type, allocator >::begin(), list< Type, allocator >::end(), map< long, typename correspondenceContainerType::iterator, less< long >, STLallocator< pair< const long, typename correspondenceContainerType::iterator > > >::insert(), and hash_map< Key, T, HashFcn, EqualKey, Alloc >::insert().
00193 {
00194 //cerr<<"PsNameServerT<STLallocator>:"<<this<<":PsNameServerT(const PsNameServer::CanonicalRepresentationType * canonicalRepresentation)"<<endl;
00195 for ( CanonicalRepresentationType::const_iterator i = canonicalRepresentation->begin() ;
00196 i != canonicalRepresentation->end() ;
00197 i++ )
00198 {
00199 //(*i) is < <PsName::idType,PsString> , numberOfInstances> therefore
00200 //(*i).first.first is the id,
00201 //(*i).first.second is the associated string
00202 //(*i).second is the number of instances of PsNames with id as id
00203
00204 //first create an entry is the hash_table for the associated string
00205 #ifdef _TYPENAMENOTIMPLICIT
00206 typename correspondenceContainerType::iterator ii=(_stringToIdCorrespondenceContainer.insert(typename correspondenceContainerType::value_type((*i).first.second,(*i).first.first))).first;
00207 // then reference that entry in the iterator table
00208 _fastStringAccessTable.insert(pair<const long, typename correspondenceContainerType::iterator>((*i).first.first,ii));
00209 #else
00210 correspondenceContainerType::iterator ii=(_stringToIdCorrespondenceContainer.insert(correspondenceContainerType::value_type((*i).first.second,(*i).first.first))).first;
00211 // then reference that entry in the iterator table
00212 _fastStringAccessTable.insert(pair<const long, correspondenceContainerType::iterator>((*i).first.first,ii));
00213 #endif
00214 //then take care of keeping care of the number of copies of id in the system
00215 _tableNbInstances[(*i).first.first] = (*i).second ;
00216
00217 //cerr<<"PsNameServerT<STLallocator>::PsNameServerT "<<(*i).second<<" references to "<<(*i).first.first<<endl;
00218
00219 //try and find a reasonnable next id
00220 _nextIdentifier = (*i).first.first + 1 ;
00221 }
|
|
|||||||||
|
destruction
Definition at line 229 of file PsNameServerT.h.
00231 {
00232 //nothing to do
|
|
||||||||||||||||
|
||||||||||||||||
|
|||||||||
|
||||||||||
|
get the id corresponding to a string if the string is unknown to the name server, a new id will be added
Implements PsNameServer. Definition at line 241 of file PsNameServerT.h. References PsNameServerT< STLallocator >::_nextIdentifier, PsNameServerT< STLallocator >::getIdentifierAsFrom(), and PsName::idType.
00243 {
00244 PsName::idType res;
00245 //cerr<<this<<" "<<_nextIdentifier<<" ";
00246 res = getIdentifierAsFrom(name, &_nextIdentifier) ;
00247 //cerr<<"("<<res<<","<<name<<") added to name server "<<_nextIdentifier<<endl;
00248 return res;
|
|
||||||||||||||||
|
get the id corresponding to a string, using a specified nextId counter used to implement getIdentifier and getSystemIdentifier
Reimplemented in PsPvmNameServer. Definition at line 276 of file PsNameServerT.h. References PsNameServerT< STLallocator >::_fastStringAccessTable, PsNameServerT< STLallocator >::_stringToIdCorrespondenceContainer, hash_map< Key, T, HashFcn, EqualKey, Alloc >::end(), hash_map< Key, T, HashFcn, EqualKey, Alloc >::find(), pair< T1, T2 >::first, PsName::idType, hash_map< Key, T, HashFcn, EqualKey, Alloc >::insert(), PsNameServerT< STLallocator >::lock(), and PsNameServerT< STLallocator >::unlock(). Referenced by PsNameServerT< STLallocator >::getIdentifier(), and PsNameServerT< STLallocator >::getSystemIdentifier().
00277 {
00278
00279 #ifdef _TYPENAMENOTIMPLICIT
00280 typename
00281 #endif
00282 correspondenceContainerType::iterator i = _stringToIdCorrespondenceContainer.find( name );
00283
00284 if (i == _stringToIdCorrespondenceContainer.end())
00285 {
00286 //we are going to change the values contained in the PsNameServer
00287 lock() ;
00288
00289 i = _stringToIdCorrespondenceContainer.find( name ) ; //name might have been added by an other process
00290
00291 if (i == _stringToIdCorrespondenceContainer.end() ) //we have to add name
00292 {
00293
00294 #ifdef _TYPENAMENOTIMPLICIT
00295 pair<typename correspondenceContainerType::iterator,bool> res = _stringToIdCorrespondenceContainer.insert(typename correspondenceContainerType::value_type(name,*nextId)) ;
00296 #else
00297 pair<correspondenceContainerType::iterator,bool> res = _stringToIdCorrespondenceContainer.insert(correspondenceContainerType::value_type(name,*nextId)) ;
00298 #endif
00299
00300 _fastStringAccessTable[*nextId] = res.first ;
00301
00302 *nextId = *nextId + 1 ;
00303
00304 i = res.first ;
00305 }
00306
00307 unlock() ;
00308 }
00309 return (*i).second;
|
|
||||||||||
|
get a list of pointers to the PsNames corresponding to an id
Implements PsNameServer. Definition at line 521 of file PsNameServerT.h. References PsNameServerT< STLallocator >::_idToNamesUsingIdContainer, hash_map< PsName::idType, list< PsName * > *, hash< PsName::idType >, equal_to< PsName::idType >, STLallocator< pair< PsName::idType, int > > >::end(), hash_map< PsName::idType, list< PsName * > *, hash< PsName::idType >, equal_to< PsName::idType >, STLallocator< pair< PsName::idType, int > > >::find(), and PsName::idType.
00523 {
00524 #ifdef _TYPENAMENOTIMPLICIT
00525 typename
00526 #endif
00527 placeOfNamesContainerType::const_iterator j = _idToNamesUsingIdContainer.find(id);
00528
00529 assert ( j != _idToNamesUsingIdContainer.end() ) ;
00530
00531 assert ( (*j).second != NULL ) ;
00532
00533 return *(*j).second ;
|
|
||||||||||
|
get the string associated to an id
Implements PsNameServer. Reimplemented in PsPvmNameServer. Definition at line 317 of file PsNameServerT.h. References PsNameServerT< STLallocator >::_fastStringAccessTable, PsNameServerT< STLallocator >::_nextIdentifier, map< long, typename correspondenceContainerType::iterator, less< long >, STLallocator< pair< const long, typename correspondenceContainerType::iterator > > >::find(), and PsName::idType.
00319 {
00320 assert ( id<_nextIdentifier) ;
00321 //assert ( _fastStringAccessTable.find(id) != _fastStringAccessTable.end() ) ;
00322 return (*(*_fastStringAccessTable.find(id)).second).first ;
|
|
||||||||||
|
get the id corresponding to a string the string should correspond to a reserverd string
Implements PsNameServer. Definition at line 257 of file PsNameServerT.h. References PsName::_maxReservedId, PsNameServerT< STLallocator >::_nextSystemIdentifier, PsNameServerT< STLallocator >::getIdentifierAsFrom(), and PsName::idType.
00259 {
00260
00261 PsName::idType result = getIdentifierAsFrom(name, &_nextSystemIdentifier) ;
00262 // this assertion could fail if a PsName corresponding to a reserved id was staticaly created
00263 assert ( result <= PsName::_maxReservedId ) ;
00264 //this would fail if more reserved Id's are created than originaly planned for
00265 assert ( _nextSystemIdentifier <= PsName::_maxReservedId ) ;
00266
00267 return result ;
|
|
|||||||||
|
lock data in a multithread environment
Implements PsNameServer. Definition at line 500 of file PsNameServerT.h. References PsNameServerT< STLallocator >::_ourDataLock, and PsnMutexLock::protect(). Referenced by PsNameServerT< STLallocator >::created(), PsNameServerT< STLallocator >::deleted(), and PsNameServerT< STLallocator >::getIdentifierAsFrom().
00502 {
00503 _ourDataLock.protect() ;
|
|
||||||||||||||||
|
redefine delete 'cause new was redefined
Definition at line 374 of file PsNameServerT.h.
00376 {
00377 STLallocator<PsNameServerT<STLallocator> > anAllocator;
00378 anAllocator.deallocate((PsNameServerT<STLallocator> *)ptr,n);
|
|
||||||||||
|
redefine new so that the nameserver is located in the same memory space than it's data structures and their elements
Definition at line 357 of file PsNameServerT.h.
00359 {
00360 STLallocator<PsNameServerT<STLallocator> > anAllocator;
00361 return anAllocator.allocate(size);
|
|
|||||||||
|
unlock data in a multithread environment
Implements PsNameServer. Definition at line 511 of file PsNameServerT.h. References PsNameServerT< STLallocator >::_ourDataLock, and PsnMutexLock::unprotect(). Referenced by PsNameServerT< STLallocator >::created(), PsNameServerT< STLallocator >::deleted(), and PsNameServerT< STLallocator >::getIdentifierAsFrom().
00513 {
00514 _ourDataLock.unprotect() ;
|
|
|||||
|
fast access data structure
Definition at line 145 of file PsNameServerT.h. Referenced by PsNameServerT< STLallocator >::deleted(), PsNameServerT< STLallocator >::getIdentifierAsFrom(), PsNameServerT< STLallocator >::getStringAssociatedTo(), and PsNameServerT< STLallocator >::PsNameServerT(). |
|
|||||
|
table holding the list of PsNames memory spaces using a given id
Definition at line 154 of file PsNameServerT.h. Referenced by PsNameServerT< STLallocator >::created(), PsNameServerT< STLallocator >::deleted(), and PsNameServerT< STLallocator >::getNamesOfId(). |
|
|||||
|
nextIdentifier to use
Definition at line 108 of file PsNameServerT.h. Referenced by PsNameServerT< STLallocator >::deleted(), PsNameServerT< STLallocator >::getIdentifier(), PsNameServerT< STLallocator >::getStringAssociatedTo(), and PsNameServerT< STLallocator >::PsNameServerT(). |
|
|||||
|
next System Identifier to use
Definition at line 112 of file PsNameServerT.h. Referenced by PsNameServerT< STLallocator >::getSystemIdentifier(), and PsNameServerT< STLallocator >::PsNameServerT(). |
|
|||||
|
the lock for multi-threaded environements
Definition at line 104 of file PsNameServerT.h. Referenced by PsNameServerT< STLallocator >::lock(), and PsNameServerT< STLallocator >::unlock(). |
|
|||||
|
table holding String - id correspondance
Definition at line 148 of file PsNameServerT.h. Referenced by PsNameServerT< STLallocator >::deleted(), PsNameServerT< STLallocator >::getCanonicalRepresentation(), PsNameServerT< STLallocator >::getIdentifierAsFrom(), and PsNameServerT< STLallocator >::PsNameServerT(). |
|
|||||
|
table holding reference counting
Definition at line 151 of file PsNameServerT.h. Referenced by PsNameServerT< STLallocator >::created(), PsNameServerT< STLallocator >::deleted(), PsNameServerT< STLallocator >::getCanonicalRepresentation(), and PsNameServerT< STLallocator >::PsNameServerT(). |
| Documentation generated on Mon Nov 25 15:26:14 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |