00001 /* 00002 * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software 00003 * 00004 * The Software has been developped within the Siames Project. 00005 * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights 00006 * 00007 * The Software has been registered with the Agence pour la Protection des 00008 * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200 00009 * 00010 * This file may be distributed under the terms of the Q Public License 00011 * version 1.0 as defined by Trolltech AS of Norway and appearing in the file 00012 * LICENSE.QPL included in the packaging of this file. 00013 * 00014 * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 00015 * for the software may use this file in accordance with that specific license 00016 * 00017 */ 00018 #include <PsNameServer.h> 00019 //#include <PsnLock.h> 00020 #include <unistd.h> 00021 00022 PsNameServer::PsNameServer() 00023 { 00024 } 00025 00026 00027 PsNameServer::~PsNameServer() 00028 { 00029 } 00030 00031 00032 bool operator == (const PsNameServer & source1, const PsNameServer & source2) 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 } 00041 00042 00043 00044 bool PsNameServer::includes (const PsNameServer & otherNameServer ) 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 } 00096 00097 00098 00099 void 00100 PsNameServer::printToStream ( ostream & out , const string & separator) const 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 } 00113 00114 void PsNameServer::changeNamesId ( PsName * namePointer, PsName::idType oldId, PsName::idType newId ) 00115 { 00116 assert (namePointer != NULL ) ; 00117 namePointer->changeId ( oldId, newId ) ; 00118 } 00119 00120 00121 00122 00123 00124 00125 00126
| Documentation generated on Mon Nov 25 15:25:00 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |