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


Public Methods | |
| virtual | ~PsNoRefCountingNameServer () |
| destructor | |
| PsNoRefCountingNameServer (const PsNameServer::CanonicalRepresentationType *canonicalRepresentation) | |
| construction of a name server conformant to a canonical representation | |
| 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 | |
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 | |
Therefore, it comes in two flavours, depending of the type of allocators used by the underlying standard library.
Definition at line 37 of file PsNoRefCountingNameServer.h.
|
|||||
|
reference data structure type
Definition at line 115 of file PsNoRefCountingNameServer.h. |
|
|||||
|
fast access data structure type
Definition at line 118 of file PsNoRefCountingNameServer.h. |
|
|||||||||
|
destructor
Definition at line 168 of file PsNoRefCountingNameServer.h.
00170 {
00171 //nothing to do
|
|
||||||||||
|
construction of a name server conformant to a canonical representation
Definition at line 134 of file PsNoRefCountingNameServer.h. References PsNoRefCountingNameServer< STLallocator >::_fastStringAccessTable, PsNoRefCountingNameServer< STLallocator >::_nextIdentifier, PsNoRefCountingNameServer< STLallocator >::_stringToIdCorrespondenceContainer, 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().
00136 {
00137 //cerr<<"PsNoRefCountingNameServer<STLallocator>:"<<this<<":PsNoRefCountingNameServer(const PsNameServer::CanonicalRepresentationType * canonicalRepresentation)"<<endl;
00138 for ( CanonicalRepresentationType::const_iterator i = canonicalRepresentation->begin() ;
00139 i != canonicalRepresentation->end() ;
00140 i++ )
00141 {
00142 //(*i) is < <PsName::idType,PsString> , numberOfInstances> therefore
00143 //(*i).first.first is the id,
00144 //(*i).first.second is the associated string
00145 //(*i).second is the number of instances of PsNames with id as id
00146
00147 //first create an entry in the hash_table for the associated string
00148 #ifdef _TYPENAMENOTIMPLICIT
00149 typename correspondenceContainerType::iterator ii=(_stringToIdCorrespondenceContainer.insert(typename correspondenceContainerType::value_type((*i).first.second,(*i).first.first))).first;
00150 // then reference that entry in the iterator table
00151 _fastStringAccessTable.insert(pair<const long, typename correspondenceContainerType::iterator>((*i).first.first,ii));
00152 #else
00153 correspondenceContainerType::iterator ii=(_stringToIdCorrespondenceContainer.insert(correspondenceContainerType::value_type((*i).first.second,(*i).first.first))).first;
00154 // then reference that entry in the iterator table
00155 _fastStringAccessTable.insert(pair<const long, correspondenceContainerType::iterator>((*i).first.first,ii));
00156 #endif
00157
00158 //try and find a reasonnable next id
00159 _nextIdentifier = (*i).first.first + 1 ;
00160 }
|
|
||||||||||||||||
|
a new PsName of id id was created
Implements PsNameServer. Definition at line 325 of file PsNoRefCountingNameServer.h. References PsName::idType.
00327 {
|
|
||||||||||||||||
|
a PsName of id id was deleted
Implements PsNameServer. Definition at line 334 of file PsNoRefCountingNameServer.h. References PsName::idType.
00336 {
|
|
|||||||||
|
||||||||||
|
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 180 of file PsNoRefCountingNameServer.h. References PsNoRefCountingNameServer< STLallocator >::_nextIdentifier, PsNoRefCountingNameServer< STLallocator >::getIdentifierAsFrom(), and PsName::idType.
00182 {
00183 PsName::idType res;
00184 //cerr<<this<<" "<<_nextIdentifier<<" ";
00185 res = getIdentifierAsFrom(name, &_nextIdentifier) ;
00186 //cerr<<"("<<res<<","<<name<<") added to name server "<<_nextIdentifier<<endl;
00187 return res;
|
|
||||||||||||||||
|
get the id corresponding to a string, using a specified nextId counter used to implement getIdentifier and getSystemIdentifier
Definition at line 215 of file PsNoRefCountingNameServer.h. References PsNoRefCountingNameServer< STLallocator >::_fastStringAccessTable, PsNoRefCountingNameServer< 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(), PsNoRefCountingNameServer< STLallocator >::lock(), and PsNoRefCountingNameServer< STLallocator >::unlock(). Referenced by PsNoRefCountingNameServer< STLallocator >::getIdentifier(), and PsNoRefCountingNameServer< STLallocator >::getSystemIdentifier().
00216 {
00217
00218 #ifdef _TYPENAMENOTIMPLICIT
00219 typename
00220 #endif
00221 correspondenceContainerType::iterator i = _stringToIdCorrespondenceContainer.find( name );
00222
00223 if (i == _stringToIdCorrespondenceContainer.end())
00224 {
00225 //we are going to change the values contained in the PsNameServer
00226 lock() ;
00227
00228 i = _stringToIdCorrespondenceContainer.find( name ) ; //name might have been added by an other process
00229
00230 if (i == _stringToIdCorrespondenceContainer.end() ) //we have to add name
00231 {
00232
00233 #ifdef _TYPENAMENOTIMPLICIT
00234 pair<typename correspondenceContainerType::iterator,bool> res = _stringToIdCorrespondenceContainer.insert(typename correspondenceContainerType::value_type(name,*nextId)) ;
00235 #else
00236 pair<correspondenceContainerType::iterator,bool> res = _stringToIdCorrespondenceContainer.insert(correspondenceContainerType::value_type(name,*nextId)) ;
00237 #endif
00238
00239 _fastStringAccessTable[*nextId] = res.first ;
00240
00241 *nextId = *nextId + 1 ;
00242
00243 i = res.first ;
00244 }
00245
00246 unlock() ;
00247 }
00248 return (*i).second;
|
|
||||||||||
|
get a list of pointers to the PsNames corresponding to an id
Implements PsNameServer. Definition at line 365 of file PsNoRefCountingNameServer.h. References PsName::idType.
00367 {
00368 static list<PsName *> emptyResult ;
00369 return emptyResult ;
|
|
||||||||||
|
get the string associated to an id
Implements PsNameServer. Definition at line 256 of file PsNoRefCountingNameServer.h. References PsNoRefCountingNameServer< STLallocator >::_fastStringAccessTable, PsNoRefCountingNameServer< STLallocator >::_nextIdentifier, map< long, typename correspondenceContainerType::iterator, less< long >, STLallocator< pair< const long, typename correspondenceContainerType::iterator > > >::find(), and PsName::idType.
00258 {
00259 assert ( id<_nextIdentifier) ;
00260 //assert ( _fastStringAccessTable.find(id) != _fastStringAccessTable.end() ) ;
00261 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 196 of file PsNoRefCountingNameServer.h. References PsName::_maxReservedId, PsNoRefCountingNameServer< STLallocator >::_nextSystemIdentifier, PsNoRefCountingNameServer< STLallocator >::getIdentifierAsFrom(), and PsName::idType.
00198 {
00199
00200 PsName::idType result = getIdentifierAsFrom(name, &_nextSystemIdentifier) ;
00201 // this assertion could fail if a PsName corresponding to a reserved id was staticaly created
00202 assert ( result <= PsName::_maxReservedId ) ;
00203 //this would fail if more reserved Id's are created than originaly planned for
00204 assert ( _nextSystemIdentifier <= PsName::_maxReservedId ) ;
00205
00206 return result ;
|
|
|||||||||
|
lock data in a multithread environment
Implements PsNameServer. Definition at line 345 of file PsNoRefCountingNameServer.h. References PsNoRefCountingNameServer< STLallocator >::_ourDataLock, and PsnMutexLock::protect(). Referenced by PsNoRefCountingNameServer< STLallocator >::getIdentifierAsFrom().
00347 {
00348 _ourDataLock.protect() ;
|
|
||||||||||||||||
|
redefine delete 'cause new was redefined
Definition at line 313 of file PsNoRefCountingNameServer.h.
00315 {
00316 STLallocator<PsNoRefCountingNameServer<STLallocator> > anAllocator;
00317 anAllocator.deallocate((PsNoRefCountingNameServer<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 296 of file PsNoRefCountingNameServer.h.
00298 {
00299 STLallocator<PsNoRefCountingNameServer<STLallocator> > anAllocator;
00300 return anAllocator.allocate(size);
|
|
|||||||||
|
unlock data in a multithread environment
Implements PsNameServer. Definition at line 356 of file PsNoRefCountingNameServer.h. References PsNoRefCountingNameServer< STLallocator >::_ourDataLock, and PsnMutexLock::unprotect(). Referenced by PsNoRefCountingNameServer< STLallocator >::getIdentifierAsFrom().
00358 {
00359 _ourDataLock.unprotect() ;
|
|
|||||
|
fast access data structure
Definition at line 121 of file PsNoRefCountingNameServer.h. Referenced by PsNoRefCountingNameServer< STLallocator >::getIdentifierAsFrom(), PsNoRefCountingNameServer< STLallocator >::getStringAssociatedTo(), and PsNoRefCountingNameServer< STLallocator >::PsNoRefCountingNameServer(). |
|
|||||
|
nextIdentifier to use
Definition at line 102 of file PsNoRefCountingNameServer.h. Referenced by PsNoRefCountingNameServer< STLallocator >::getIdentifier(), PsNoRefCountingNameServer< STLallocator >::getStringAssociatedTo(), and PsNoRefCountingNameServer< STLallocator >::PsNoRefCountingNameServer(). |
|
|||||
|
next System Identifier to use
Definition at line 106 of file PsNoRefCountingNameServer.h. Referenced by PsNoRefCountingNameServer< STLallocator >::getSystemIdentifier(). |
|
|||||
|
the lock for multi-threaded environements
Definition at line 98 of file PsNoRefCountingNameServer.h. Referenced by PsNoRefCountingNameServer< STLallocator >::lock(), and PsNoRefCountingNameServer< STLallocator >::unlock(). |
|
|||||
|
table holding String - id correspondance
Definition at line 124 of file PsNoRefCountingNameServer.h. Referenced by PsNoRefCountingNameServer< STLallocator >::getCanonicalRepresentation(), PsNoRefCountingNameServer< STLallocator >::getIdentifierAsFrom(), and PsNoRefCountingNameServer< STLallocator >::PsNoRefCountingNameServer(). |
| Documentation generated on Mon Nov 25 15:26:15 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |