UniSet  2.24.2
ObjectIndex_idXML.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 // --------------------------------------------------------------------------
17 #ifndef ObjectIndex_idXML_H_
18 #define ObjectIndex_idXML_H_
19 // --------------------------------------------------------------------------
20 #include <unordered_map>
21 #include <string>
22 #include "ObjectIndex.h"
23 #include "UniXML.h"
24 // --------------------------------------------------------------------------
25 namespace uniset
26 {
29  public uniset::ObjectIndex
30  {
31  public:
32  ObjectIndex_idXML( const std::string& xmlfile );
33  ObjectIndex_idXML( const std::shared_ptr<UniXML>& xml );
34  virtual ~ObjectIndex_idXML();
35 
36  virtual const uniset::ObjectInfo* getObjectInfo( const uniset::ObjectId ) const noexcept override;
37  virtual const uniset::ObjectInfo* getObjectInfo( const std::string& name ) const noexcept override;
38  virtual uniset::ObjectId getIdByName( const std::string& name ) const noexcept override;
39  virtual std::string getMapName( const uniset::ObjectId id ) const noexcept override;
40  virtual std::string getTextName( const uniset::ObjectId id ) const noexcept override;
41 
42  virtual std::ostream& printMap( std::ostream& os ) const noexcept override;
43  friend std::ostream& operator<<(std::ostream& os, ObjectIndex_idXML& oi );
44 
45  protected:
46  void build( const std::shared_ptr<UniXML>& xml );
47  void read_section( const std::shared_ptr<UniXML>& xml, const std::string& sec );
48  void read_nodes( const std::shared_ptr<UniXML>& xml, const std::string& sec );
49 
50  private:
51  typedef std::unordered_map<uniset::ObjectId, uniset::ObjectInfo> MapObjects;
52  MapObjects omap;
53 
54  typedef std::unordered_map<std::string, uniset::ObjectId> MapObjectKey;
55  MapObjectKey mok; // для обратного писка
56  };
57  // -------------------------------------------------------------------------
58 } // end of uniset namespace
59 // -----------------------------------------------------------------------------------------
60 #endif
Definition: ObjectIndex_idXML.h:30
virtual uniset::ObjectId getIdByName(const std::string &name) const noexcept override
Definition: ObjectIndex_idXML.cc:47
virtual std::string getMapName(const uniset::ObjectId id) const noexcept override
Definition: ObjectIndex_idXML.cc:61
virtual std::string getTextName(const uniset::ObjectId id) const noexcept override
Definition: ObjectIndex_idXML.cc:75
Definition: ObjectIndex.h:32
Definition: CommonEventLoop.h:15
long ObjectId
Definition: UniSetTypes_i.idl:30
Definition: UniSetTypes.h:151