#include <PsNameServer.h>
Inheritance diagram for PsNameServer:

Public Types | |
| typedef PsList< PsPair< PsPair< PsName::idType, PsString >, int > > | CanonicalRepresentationType |
| define what the canonical representation is | |
Public Methods | |
| PsNameServer () | |
| constructor, empty | |
| virtual | ~PsNameServer () |
| destructor, empty but needed because the default destructor is not created virtual | |
| virtual long | getIdentifier (const PsString &)=0 |
| 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 &)=0 |
| get the id corresponding to a string the string should correspond to a reserverd string | |
| virtual const PsString & | getStringAssociatedTo (PsName::idType id) const=0 |
| get the string associated to an id | |
| virtual void | printToStream (ostream &out, const string &separator) const |
| print contents. | |
| virtual bool | includes (const PsNameServer &otherNameServer) |
| does the current name server include all the <id, string> pairs of otherNameServer | |
| virtual void | created (PsName::idType, PsName *)=0 |
| used by PsName for reference counting | |
| virtual void | deleted (PsName::idType, PsName *)=0 |
| used by PsName for referenve counting | |
| virtual CanonicalRepresentationType * | getCanonicalRepresentation () const=0 |
| get the canonical representation once used, the result should be deleted | |
| virtual const list< PsName * > & | getNamesOfId (PsName::idType) const=0 |
| get a list of pointers to the PsNames corresponding to an id | |
Protected Methods | |
| virtual void | lock () const=0 |
| lock data in a multithread environment | |
| virtual void | unlock () const=0 |
| unlock data in a multithread environment | |
| void | changeNamesId (PsName *namePointer, PsName::idType oldId, PsName::idType newId) |
| change the id of a name | |
Friends | |
| bool | operator== (const PsNameServer &, const PsNameServer &) |
| Compare two name servers. | |
A name server is used so that instances of the PsName class only store an Id. The name server keeps track of the corresponding string used at the creation of the PsName. This enables fast creation and comparaison for equality between PsNames. It also means that comparaison is _not_ done using lexicographic order. the PsName class acts as a singleton ( see singleton pattern ) for name servers, so only one instance of a name server can be used at a time, and making sure the change of name server doesn't affect the string associated to the name ids. This is an abstract class, defining a canonical external representation for name servers so that they can be compared. This canonical representation is a list of pairs of id and their associated PsString, pair with the numer of occurences of the pair, ordered on the first element of the pair (the id). This representation is used for the construction of new name servers that don't change any string associated with a given id.
Definition at line 41 of file PsNameServer.h.
|
|
define what the canonical representation is
Definition at line 91 of file PsNameServer.h. Referenced by PsNoRefCountingNameServer< STLallocator >::getCanonicalRepresentation(), and PsNameServerT< STLallocator >::getCanonicalRepresentation(). |
|
|
constructor, empty
Definition at line 22 of file PsNameServer.cxx.
00023 {
00024 }
|
|
|
destructor, empty but needed because the default destructor is not created virtual
Definition at line 27 of file PsNameServer.cxx.
00028 {
00029 }
|
|
||||||||||||||||
|
change the id of a name
Definition at line 114 of file PsNameServer.cxx. References PsName::changeId(), and PsName::idType.
00115 {
00116 assert (namePointer != NULL ) ;
00117 namePointer->changeId ( oldId, newId ) ;
00118 }
|
|
||||||||||||
|
used by PsName for reference counting
Implemented in PsNameServerT< STLallocator >, PsNoRefCountingNameServer< STLallocator >, PsPvmNameServer, and PsNameServerT< STL_ALLOC >. Referenced by PsName::extract(), PsName::operator=(), PsName::PsName(), and PsName::unpack(). |
|
||||||||||||
|
used by PsName for referenve counting
Implemented in PsNameServerT< STLallocator >, PsNoRefCountingNameServer< STLallocator >, PsPvmNameServer, and PsNameServerT< STL_ALLOC >. Referenced by PsName::extract(), PsName::operator=(), PsName::unpack(), and PsName::~PsName(). |
|
|
get the canonical representation once used, the result should be deleted
Implemented in PsNameServerT< STLallocator >, PsNoRefCountingNameServer< STLallocator >, and PsNameServerT< STL_ALLOC >. Referenced by includes(), operator==(), printToStream(), and PsMultiThreadedController::PsMultiThreadedController(). |
|
|
get the id corresponding to a string if the string is unknown to the name server, a new id will be added
Implemented in PsNameServerT< STLallocator >, PsNoRefCountingNameServer< STLallocator >, and PsNameServerT< STL_ALLOC >. Referenced by PsName::extract(), PsName::operator=(), and PsName::PsName(). |
|
|
get a list of pointers to the PsNames corresponding to an id
Implemented in PsNameServerT< STLallocator >, PsNoRefCountingNameServer< STLallocator >, and PsNameServerT< STL_ALLOC >. |
|
|
get the string associated to an id
Implemented in PsNameServerT< STLallocator >, PsNoRefCountingNameServer< STLallocator >, PsPvmNameServer, and PsNameServerT< STL_ALLOC >. Referenced by PsName::getPsString(), and PsName::insertInStream(). |
|
|
get the id corresponding to a string the string should correspond to a reserverd string
Implemented in PsNameServerT< STLallocator >, PsNoRefCountingNameServer< STLallocator >, and PsNameServerT< STL_ALLOC >. |
|
|
does the current name server include all the <id, string> pairs of otherNameServer
Reimplemented in PsPvmNameServer. Definition at line 44 of file PsNameServer.cxx. References list< Type, allocator >::begin(), list< Type, allocator >::end(), getCanonicalRepresentation(), and printToStream(). Referenced by PsName::setNameServer().
00045 {
00046 #ifdef _DEBUGDISTRIBUTEDNAMESERVER
00047 cerr<<"PsNameServer::includes"<<endl;
00048 #endif
00049 PsNameServer::CanonicalRepresentationType * canonicalRepresentation1 = otherNameServer.getCanonicalRepresentation() ;
00050 PsNameServer::CanonicalRepresentationType * canonicalRepresentation2 = getCanonicalRepresentation() ;
00051 PsNameServer::CanonicalRepresentationType::const_iterator iter1 = canonicalRepresentation1->begin() ;
00052 PsNameServer::CanonicalRepresentationType::const_iterator iter2 = canonicalRepresentation2->begin() ;
00053 bool noMissingPairFound = true ;
00054 bool found ;
00055 while ( noMissingPairFound &&
00056 (iter1 != canonicalRepresentation1->end() ) )
00057 {
00058 // make sure (*iter1).first is in canonicalRepresentation2
00059 #ifdef _DEBUGDISTRIBUTEDNAMESERVER
00060 cerr<<"looking for <"<<(*iter1).first.first<<","<<(*iter1).first.second<<">"<<endl;
00061 #endif
00062 found = false ;
00063 while ( (iter2 != canonicalRepresentation2->end()) &&
00064 !found )
00065 {
00066 #ifdef _DEBUGDISTRIBUTEDNAMESERVER
00067 cerr<<" examined <"<<(*iter2).first.first<<","<<(*iter2).first.second<<"> ";
00068 #endif
00069 if ( (*iter2).first == (*iter1).first )
00070 {
00071 #ifdef _DEBUGDISTRIBUTEDNAMESERVER
00072 cerr<<"identic"<<endl;
00073 #endif
00074 found = true ;
00075 }
00076 ++iter2 ;
00077 }
00078 if ( (iter2 == canonicalRepresentation2->end())
00079 && !found )
00080 {
00081 noMissingPairFound = false ;
00082 #ifdef _DEBUGDISTRIBUTEDNAMESERVER
00083 cerr<<"<"<<(*iter1).first.first<<","<<(*iter1).first.second<<"> not found in ";
00084 otherNameServer.printToStream (cout, " ");
00085 #endif
00086 }
00087 else
00088 {
00089 ++iter1 ;
00090 }
00091 }
00092 delete canonicalRepresentation1 ;
00093 delete canonicalRepresentation2 ;
00094 return noMissingPairFound ;
00095 }
|
|
|
lock data in a multithread environment
Implemented in PsNameServerT< STLallocator >, PsNoRefCountingNameServer< STLallocator >, and PsNameServerT< STL_ALLOC >. Referenced by printToStream(). |
|
||||||||||||
|
print contents. The default version prints the canonical representation Definition at line 100 of file PsNameServer.cxx. References list< Type, allocator >::begin(), list< Type, allocator >::end(), getCanonicalRepresentation(), lock(), and unlock(). Referenced by PsController::destroyObject(), and includes().
00101 {
00102 lock() ;
00103 CanonicalRepresentationType * canonicalRepresentation = getCanonicalRepresentation() ;
00104 for ( CanonicalRepresentationType::const_iterator i = canonicalRepresentation->begin() ;
00105 i != canonicalRepresentation->end() ;
00106 i++ )
00107 {
00108 out<<*i<<separator;
00109 }
00110 out<<endl;
00111 unlock() ;
00112 }
|
|
|
unlock data in a multithread environment
Implemented in PsNameServerT< STLallocator >, PsNoRefCountingNameServer< STLallocator >, and PsNameServerT< STL_ALLOC >. Referenced by printToStream(). |
|
||||||||||||
|
Compare two name servers.
Definition at line 32 of file PsNameServer.cxx.
00033 {
00034 PsNameServer::CanonicalRepresentationType * canonicalRepresentation1 = source1.getCanonicalRepresentation() ;
00035 PsNameServer::CanonicalRepresentationType * canonicalRepresentation2 = source2.getCanonicalRepresentation() ;
00036 bool resul = *canonicalRepresentation1 == *canonicalRepresentation2 ;
00037 delete canonicalRepresentation1 ;
00038 delete canonicalRepresentation2 ;
00039 return resul ;
00040 }
|
| Documentation generated on Mon Nov 25 15:26:14 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |