UniSet  2.6.0
ObjectIndex.h
1 /*
2  * Copyright (c) 2015 Pavel Vainerman.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, version 2.1.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Lesser Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 // --------------------------------------------------------------------------
20 // --------------------------------------------------------------------------
21 #ifndef ObjcetIndex_H_
22 #define ObjcetIndex_H_
23 // --------------------------------------------------------------------------
24 #include <ostream>
25 #include <string>
26 #include "UniSetTypes.h"
27 // --------------------------------------------------------------------------
28 namespace uniset
29 {
31  {
32  public:
33  ObjectIndex() {};
34  virtual ~ObjectIndex() {};
35 
36  // info
37  // \return nullptr if not found
38  virtual const ObjectInfo* getObjectInfo( const uniset::ObjectId ) const noexcept = 0;
39  virtual const ObjectInfo* getObjectInfo( const std::string& name ) const noexcept = 0;
40 
41  static std::string getBaseName( const std::string& fname ) noexcept;
42 
43  // object id
44 
46  virtual ObjectId getIdByName(const std::string& name) const noexcept = 0;
47 
49  virtual std::string getNameById( const uniset::ObjectId id ) const noexcept;
50 
51  // node
53  inline std::string getNodeName( const uniset::ObjectId id ) const noexcept
54  {
55  return getNameById(id);
56  }
57 
59  inline ObjectId getNodeId( const std::string& name ) const noexcept
60  {
61  return getIdByName(name);
62  }
63 
64  // src name
66  virtual std::string getMapName( const uniset::ObjectId id ) const noexcept = 0;
68  virtual std::string getTextName( const uniset::ObjectId id ) const noexcept = 0;
69 
70  //
71  virtual std::ostream& printMap(std::ostream& os) const noexcept = 0;
72 
73  void initLocalNode( const uniset::ObjectId nodeid ) noexcept;
74 
75  protected:
76  std::string nmLocalNode = {""}; // поле для оптимизации получения LocalNode
77 
78  private:
79 
80  };
81 
82 
83  // -----------------------------------------------------------------------------------------
84 } // end of namespace
85 // -----------------------------------------------------------------------------------------
86 #endif
Definition: CallbackTimer.h:29
std::string getNodeName(const uniset::ObjectId id) const noexcept
Definition: ObjectIndex.h:53
Definition: ObjectIndex.h:30
virtual std::string getNameById(const uniset::ObjectId id) const noexcept
Definition: ObjectIndex.cc:32
virtual std::string getTextName(const uniset::ObjectId id) const noexcept=0
virtual std::string getMapName(const uniset::ObjectId id) const noexcept=0
virtual ObjectId getIdByName(const std::string &name) const noexcept=0
Definition: UniSetTypes.h:141
ObjectId getNodeId(const std::string &name) const noexcept
Definition: ObjectIndex.h:59
long ObjectId
Definition: UniSetTypes_i.idl:30