OMKNameServer.h

Go to the documentation of this file.
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 #ifndef NameServerHEADER
00019 #define NameServerHEADER
00020 
00021 #include "OMKName.h"
00022 #include <map>
00023 #include <list>
00024 #ifdef _MSC_VER
00025 #include <hash_map>
00026 #define HASH_NAME_SPACE stdext
00027 #else
00028 #include <ext/hash_map>
00029 #define HASH_NAME_SPACE __gnu_cxx
00030 #endif
00031 namespace OMK
00032 {
00040 class OMK_API NameServer 
00041 {
00043   typedef std::pair<std::pair<Name::idType,std::string>, int > CanonicalRepresentationItemType ;
00044   typedef std::list< CanonicalRepresentationItemType > CanonicalRepresentationType ;
00045 
00046 public :
00047 
00049         NameServer();
00050 
00052         NameServer(const NameServer::CanonicalRepresentationType * );
00053 
00055    virtual ~NameServer() ;
00056 
00059    virtual void printToStream (std::ostream & out, const std::string & separator ) const ;
00060 
00062    virtual bool includes ( const NameServer & otherNameServer );
00063 
00065    friend OMK_API bool operator == (const NameServer & , const NameServer &);
00066 
00069    virtual Name::idType getIdentifier(const std::string &);
00070 
00073         virtual Name::idType getSystemIdentifier(const std::string &);
00074 
00077         virtual Name::idType getIdentifierAsFrom(const std::string &, Name::idType * nextId);
00078 
00081         virtual const std::string& getStringAssociatedTo( Name::idType id ) const;
00082 
00084         virtual void created(Name::idType id, Name * );
00085 
00087         virtual void deleted(Name::idType id, Name * );
00088 
00092         CanonicalRepresentationType * getCanonicalRepresentation () const ;
00093 
00095         virtual const std::list<Name *> & getNamesOfId (Name::idType) const ;
00096 
00097 protected:
00098 
00100         //virtual void lock() const ;
00101 
00103         //virtual void unlock() const ;
00104 
00107         Name::idType _nextIdentifier ;
00108 
00111         Name::idType _nextSystemIdentifier ;
00112 
00113 
00114 #ifdef _MSC_VER
00115 
00116   typedef HASH_NAME_SPACE::hash_map<std::string, Name::idType > correspondenceContainerType;
00117 
00119         typedef HASH_NAME_SPACE::hash_map<Name::idType, int> referenceCountingContainerType;
00120 
00122         typedef HASH_NAME_SPACE::hash_map<Name::idType, std::list<Name *> * > placeOfNamesContainerType ;
00123 #else
00124   struct hash_compare_string : public __gnu_cxx::hash<std::string>
00125   {
00126     //dont't hash on _identifiers, because they might change, breaking all hash maps
00127     size_t operator() ( const std::string& s ) const
00128     {
00129       return __gnu_cxx::hash<const char*>()( s.c_str() ) ;
00130     }
00131 
00132     bool operator()( const std::string& x, const std::string& y ) const 
00133     {
00134       return x < y ;
00135     }
00136   } ;
00138   typedef HASH_NAME_SPACE::hash_map<std::string, Name::idType, hash_compare_string > correspondenceContainerType;
00139 
00141         typedef HASH_NAME_SPACE::hash_map<Name::idType, int, HASH_NAME_SPACE::hash<Name::idType> > referenceCountingContainerType;
00142 
00144   typedef HASH_NAME_SPACE::hash_map<Name::idType, std::list<Name *> *, HASH_NAME_SPACE::hash<Name::idType> > placeOfNamesContainerType ;
00145 #endif
00146 
00147   typedef std::map<Name::idType, correspondenceContainerType::iterator > fastStringAccessTableType;
00148 
00149 
00151         fastStringAccessTableType _fastStringAccessTable ;
00152 
00154         correspondenceContainerType _stringToIdCorrespondenceContainer ;
00155 
00157         referenceCountingContainerType _tableNbInstances;
00158 
00160         placeOfNamesContainerType _idToNamesUsingIdContainer ;
00161 
00167    void changeNamesId ( Name * namePointer, Name::idType oldId, Name::idType newId ) ;
00168 
00169 }; 
00170 } // namespace OMK
00171 
00172 #endif
00173 
00174 
00175 
00176 
00177 
00178 
00179 

logo OpenMask

Documentation generated on Mon Jun 9 11:45:57 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007