UniSet  2.6.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 {
39  public ObjectIndex
40  {
41  public:
42  ObjectIndex_Array(const ObjectInfo* objectInfo);
43  virtual ~ObjectIndex_Array();
44 
45  virtual const ObjectInfo* getObjectInfo( const ObjectId ) const noexcept override;
46  virtual const ObjectInfo* getObjectInfo( const std::string& name ) const noexcept override;
47  virtual ObjectId getIdByName( const std::string& name ) const noexcept override;
48  virtual std::string getMapName( const ObjectId id ) const noexcept override;
49  virtual std::string getTextName( const ObjectId id ) const noexcept override;
50 
51  virtual std::ostream& printMap(std::ostream& os) const noexcept override;
52  friend std::ostream& operator<<(std::ostream& os, ObjectIndex_Array& oi );
53 
54  private:
55 
56  size_t numOfObject;
57  typedef std::unordered_map<std::string, ObjectId> MapObjectKey;
58  MapObjectKey::iterator MapObjectKeyIterator;
59  MapObjectKey mok;
60  const ObjectInfo* objectInfo;
61  size_t maxId;
62  };
63  // -----------------------------------------------------------------------------------------
64 } // end of namespace
65 // -----------------------------------------------------------------------------------------
66 #endif
Definition: CallbackTimer.h:29
virtual ObjectId getIdByName(const std::string &name) const noexceptoverride
Definition: ObjectIndex_Array.cc:50
Definition: ObjectIndex.h:30
virtual std::string getMapName(const ObjectId id) const noexceptoverride
Definition: ObjectIndex_Array.cc:61
virtual std::string getTextName(const ObjectId id) const noexceptoverride
Definition: ObjectIndex_Array.cc:70
Definition: UniSetTypes.h:141
Definition: ObjectIndex_Array.h:38
long ObjectId
Definition: UniSetTypes_i.idl:30