source: subversion/applications/lib/libosm/Object.h @ 11682

Last change on this file since 11682 was 11682, checked in by nienhueser, 10 years ago

No 'using xy' declarations in headers
Reorder includes with local files on top, and methods by decreasing publicity

File size: 1.6 KB
Line 
1#ifndef OSMOBJECT_H
2#define OSMOBJECT_H
3
4/*
5 Copyright (C) 2006 Nick Whitelegg, Hogweed Software, nick@hogweed.org
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
20
21 */
22
23#include <vector>
24#include <map>
25#include <string>
26
27// based on osmeditor2 code - changed qt stuff to std::b stuff
28
29namespace OSM
30{
31
32class Object
33{
34protected:
35
36public:
37        // violates encapsulation but for ease of use...
38        int id;
39        std::map<std::string, std::string> tags;
40
41        Object()
42        {
43                id = 0;
44        }
45
46        void setName(const std::string& n)
47        {
48                //name = n;
49                tags["name"] = n;
50        }
51
52        std::string getName()
53        {
54                //return name;
55                return (tags.find("name") != tags.end()) ? tags["name"] : "";
56        }
57
58        bool isFromOSM()
59        {
60                return id > 0;
61        }
62
63        void addTag(std::string key, std::string value)
64        {
65                tags[key] = value;
66        }
67
68        std::string getTag(const std::string& tag)
69        {
70                return (tags.find(tag) != tags.end()) ? tags[tag] : "";
71        }
72
73        std::vector<std::string> getTags();
74
75        bool hasTags()
76        {
77                return tags.size() > 0;
78        }
79
80        void tagsToXML(std::ostream &strm);
81};
82
83}
84
85#endif
Note: See TracBrowser for help on using the repository browser.