UniSet  2.7.0
ObjectIndex_Array.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 ObjectIndex_Array_H_
22 #define ObjectIndex_Array_H_
23 // --------------------------------------------------------------------------
24 #include <string>
25 #include <unordered_map>
26 #include <ostream>
27 #include "UniSetTypes.h"
28 #include "Exceptions.h"
29 #include "ObjectIndex.h"
30 // --------------------------------------------------------------------------
31 namespace uniset
32 {
43  public ObjectIndex
44  {
45  public:
46  ObjectIndex_Array(const ObjectInfo* objectInfo);
47  virtual ~ObjectIndex_Array();
48 
49  virtual const ObjectInfo* getObjectInfo( const ObjectId ) const noexcept override;
50  virtual const ObjectInfo* getObjectInfo( const std::string& name ) const noexcept override;
51  virtual ObjectId getIdByName( const std::string& name ) const noexcept override;
52  virtual std::string getMapName( const ObjectId id ) const noexcept override;
53  virtual std::string getTextName( const ObjectId id ) const noexcept override;
54 
55  virtual std::ostream& printMap(std::ostream& os) const noexcept override;
56  friend std::ostream& operator<<(std::ostream& os, ObjectIndex_Array& oi );
57 
58  private:
59 
60  size_t numOfObject;
61  typedef std::unordered_map<std::string, ObjectId> MapObjectKey;
62  MapObjectKey::iterator MapObjectKeyIterator;
63  MapObjectKey mok;
64  const ObjectInfo* objectInfo;
65  size_t maxId;
66  };
67  // -----------------------------------------------------------------------------------------
68 } // end of namespace
69 // -----------------------------------------------------------------------------------------
70 #endif
Definition: CallbackTimer.h:29
Definition: ObjectIndex.h:31
virtual std::string getMapName(const ObjectId id) const noexcept override
Definition: ObjectIndex_Array.cc:61
virtual std::string getTextName(const ObjectId id) const noexcept override
Definition: ObjectIndex_Array.cc:70
Definition: UniSetTypes.h:153
virtual ObjectId getIdByName(const std::string &name) const noexcept override
Definition: ObjectIndex_Array.cc:50
Definition: ObjectIndex_Array.h:42
long ObjectId
Definition: UniSetTypes_i.idl:30