UniSet 2.32.1
ObjectIndex_XML.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_XML_H_
22#define ObjectIndex_XML_H_
23// --------------------------------------------------------------------------
24#include <unordered_map>
25#include <memory>
26#include <vector>
27#include <string>
28#include "ObjectIndex.h"
29#include "UniXML.h"
30// --------------------------------------------------------------------------
31namespace uniset
32{
33
40 public ObjectIndex
41 {
42 public:
43 ObjectIndex_XML(const std::string& xmlfile, size_t minSize = 1000 );
44 ObjectIndex_XML( const std::shared_ptr<UniXML>& xml, size_t minSize = 1000 );
45 virtual ~ObjectIndex_XML();
46
47 virtual const uniset::ObjectInfo* getObjectInfo( const ObjectId ) const noexcept override;
48 virtual const uniset::ObjectInfo* getObjectInfo( const std::string& name ) const noexcept override;
49 virtual ObjectId getIdByName( const std::string& name ) const noexcept override;
50 virtual std::string getMapName( const ObjectId id ) const noexcept override;
51 virtual std::string getTextName( const ObjectId id ) const noexcept override;
52
53 virtual std::ostream& printMap(std::ostream& os) const noexcept override;
54 friend std::ostream& operator<<(std::ostream& os, ObjectIndex_XML& oi );
55
56 protected:
57 void build( const std::shared_ptr<UniXML>& xml );
58 size_t read_section(const std::shared_ptr<UniXML>& xml, const std::string& sec, size_t ind );
59 size_t read_nodes( const std::shared_ptr<UniXML>& xml, const std::string& sec, size_t ind );
60
61 private:
62 typedef std::unordered_map<std::string, ObjectId> MapObjectKey;
63 MapObjectKey mok; // для обратного писка
64 std::vector<ObjectInfo> omap; // для прямого поиска
65 };
66 // -----------------------------------------------------------------------------------------
67} // end of namespace
68// -----------------------------------------------------------------------------------------
69#endif
Definition ObjectIndex_XML.h:41
virtual std::string getTextName(const ObjectId id) const noexcept override
Definition ObjectIndex_XML.cc:73
virtual std::string getMapName(const ObjectId id) const noexcept override
Definition ObjectIndex_XML.cc:65
virtual ObjectId getIdByName(const std::string &name) const noexcept override
Definition ObjectIndex_XML.cc:51
Definition ObjectIndex.h:32
Definition Calibration.h:27
long ObjectId
Definition UniSetTypes_i.idl:30
Definition UniSetTypes.h:156