UniSet  1.4.0
ObjectIndex.h
См. документацию.
00001 /* File: This file is part of the UniSet project
00002  * Copyright (C) 2002 Vitaly Lipatov
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 // --------------------------------------------------------------------------
00022 // -------------------------------------------------------------------------- 
00023 #ifndef ObjcetIndex_H_
00024 #define ObjcetIndex_H_
00025 // --------------------------------------------------------------------------
00026 #include <ostream>
00027 #include <string>
00028 #include "UniSetTypes.h"
00029 // --------------------------------------------------------------------------
00030 namespace UniSetTypes
00031 {
00032 class ObjectIndex
00033 {
00034     public:
00035         ObjectIndex(){};
00036         virtual ~ObjectIndex(){};
00037 
00038         static const std::string sepName;
00039         static const std::string sepNode;
00040 
00041         // info
00042         virtual const ObjectInfo* getObjectInfo( const ObjectId )=0;
00043         virtual const ObjectInfo* getObjectInfo( const std::string name )=0;
00044 
00045         // создание полного имени в репозитории по паре имя:узел
00046         static std::string mkRepName( const std::string repname, const std::string nodename );
00047         // создание имени узла по реальному и виртуальному
00048         static std::string mkFullNodeName( const std::string realnode, const std::string virtnode );
00049         // получить имя для регистрации в репозитории (т.е. без секции)
00050         static std::string getBaseName( const std::string fname );
00051 
00052         // object id
00053         virtual ObjectId getIdByName(const std::string& name)=0;
00054         virtual std::string getNameById( const ObjectId id );
00055         virtual std::string getNameById( const ObjectId id, const ObjectId node );
00056 
00057         // node
00058         virtual std::string getFullNodeName(const std::string& fullname);
00059         virtual std::string getVirtualNodeName(const std::string& fullNodeName);
00060         virtual std::string getRealNodeName(const std::string& fullNodeName);
00061         virtual std::string getRealNodeName( const ObjectId id );
00062         
00063         virtual std::string getName( const std::string& fullname );
00064 
00065         // src name
00066         virtual std::string getMapName(const ObjectId id)=0;
00067         virtual std::string getTextName(const ObjectId id)=0;
00068 
00069         // 
00070         virtual std::ostream& printMap(std::ostream& os)=0;
00071 
00072         // ext
00073         inline ObjectId getIdByFullName(const std::string& fname)
00074         {
00075             return getIdByName(getName(fname));
00076         }
00077         
00078         inline ObjectId getNodeId( const std::string& fullname )
00079         {
00080             return getIdByName( getFullNodeName(fullname) );
00081         }
00082 
00083         inline std::string getFullNodeName( const ObjectId nodeid )
00084         {
00085             return getMapName(nodeid);  
00086         }
00087 
00088         void initLocalNode( ObjectId nodeid );
00089     
00090     
00091     protected:
00092         std::string nmLocalNode;    // для оптимизации
00093 
00094     private:
00095     
00096 };
00097     
00098 
00099 // -----------------------------------------------------------------------------------------
00100 }   // end of namespace
00101 // -----------------------------------------------------------------------------------------
00102 #endif