libosmscout 1.1.1
Loading...
Searching...
No Matches
ObjectRef.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_OBJECTREF_H
2#define OSMSCOUT_OBJECTREF_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2009 Tim Teulings
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
24
25#include <string>
26#include <tuple>
27
29
31
32namespace osmscout {
33
41
46 class OSMSCOUT_API ObjectOSMRef CLASS_FINAL
47 {
48 public:
49 OSMId id=0; //NOLINT
51
52 public:
53 ObjectOSMRef() = default;
54 ObjectOSMRef(const ObjectOSMRef& ref) = default;
55 ObjectOSMRef(ObjectOSMRef&& ref) = default;
56
59 : id(id),
60 type(type)
61 {
62 // no code
63 }
64
65 ~ObjectOSMRef() = default;
66
67 ObjectOSMRef& operator=(const ObjectOSMRef& other) = default;
68 ObjectOSMRef& operator=(ObjectOSMRef&& other) = default;
69
70 bool operator<(const ObjectOSMRef& reference) const
71 {
72 return std::tie(type, id) < std::tie(reference.type, reference.id);
73 }
74
76 {
77 return type==reference.type && id==reference.id;
78 }
79
81 {
82 return type!=reference.type || id!=reference.id;
83 }
84
85 void Set(const OSMId& id,
86 const OSMRefType& type)
87 {
88 this->id=id;
89 this->type=type;
90 }
91
93 {
94 this->id=0;
95 this->type=osmRefNone;
96 }
97
98 const OSMId& GetId() const
99 {
100 return id;
101 }
102
103 const OSMRefType& GetType() const
104 {
105 return type;
106 }
107
108 std::string GetName() const;
109
110 bool Valid() const
111 {
112 return type!=osmRefNone;
113 }
114
115 bool Invalid() const
116 {
117 return type==osmRefNone;
118 }
119
120 bool IsNode() const
121 {
122 return type==osmRefNode;
123 }
124
125 bool IsWay() const
126 {
127 return type==osmRefWay;
128 }
129
130 bool IsRelation() const
131 {
132 return type==osmRefRelation;
133 }
134
135 const char* GetTypeName() const;
136 };
137
139 {
144 };
145
150 class OSMSCOUT_API ObjectFileRef CLASS_FINAL
151 {
152 public:
153 FileOffset offset=0; // NOLINT
155
156 public:
157 ObjectFileRef() = default;
158 ObjectFileRef(const ObjectFileRef& ref) = default;
159 ObjectFileRef(ObjectFileRef&& ref) = default;
160
163 : offset(offset),
164 type(type)
165 {
166 // no code
167 }
168
169 ~ObjectFileRef() = default;
170
171 ObjectFileRef& operator=(const ObjectFileRef& other) = default;
173
175 {
176 return std::tie(type, offset) < std::tie(reference.type, reference.offset);
177 }
178
180 {
181 return type==reference.type && offset==reference.offset;
182 }
183
185 {
186 return type!=reference.type || offset!=reference.offset;
187 }
188
189 void Set(const FileOffset& offset,
190 const RefType& type)
191 {
192 this->offset=offset;
193 this->type=type;
194 }
195
197 {
198 this->offset=0;
199 this->type=refNone;
200 }
201
203 {
204 return offset;
205 }
206
207 const RefType& GetType() const
208 {
209 return type;
210 }
211
212 std::string GetName() const;
213
214 bool Valid() const
215 {
216 return type!=refNone;
217 }
218
219 bool Invalid() const
220 {
221 return type==refNone;
222 }
223
224 bool IsNode() const
225 {
226 return type==refNode;
227 }
228
229 bool IsWay() const
230 {
231 return type==refWay;
232 }
233
234 bool IsArea() const
235 {
236 return type==refArea;
237 }
238
239 const char* GetTypeName() const;
240 };
241
242
246 class OSMSCOUT_API ObjectFileRefByFileOffsetComparator CLASS_FINAL
247 {
248 public:
250 const ObjectFileRef& b) const
251 {
252 return a.GetFileOffset()<b.GetFileOffset();
253 }
254 };
255}
256
257#endif
#define CLASS_FINAL
Definition Compiler.h:26
#define OSMSCOUT_API
Definition CoreImportExport.h:45
Definition Area.h:88
ObjectOSMRef & operator=(ObjectOSMRef &&other)=default
ObjectFileRef(FileOffset offset, RefType type)
Definition ObjectRef.h:161
const OSMId & GetId() const
Definition ObjectRef.h:98
bool IsWay() const
Definition ObjectRef.h:125
bool Valid() const
Definition ObjectRef.h:110
void Set(const FileOffset &offset, const RefType &type)
Definition ObjectRef.h:189
bool Invalid() const
Definition ObjectRef.h:115
const FileOffset & GetFileOffset() const
Definition ObjectRef.h:202
ObjectOSMRef(ObjectOSMRef &&ref)=default
const OSMRefType & GetType() const
Definition ObjectRef.h:103
const char * GetTypeName() const
ObjectOSMRef(const ObjectOSMRef &ref)=default
std::string GetName() const
bool operator<(const ObjectFileRef &reference) const
Definition ObjectRef.h:174
const RefType & GetType() const
Definition ObjectRef.h:207
ObjectFileRef(ObjectFileRef &&ref)=default
void Invalidate()
Definition ObjectRef.h:92
ObjectOSMRef & operator=(const ObjectOSMRef &other)=default
OSMId id
We are an area.
Definition ObjectRef.h:49
bool IsArea() const
Definition ObjectRef.h:234
bool IsRelation() const
Definition ObjectRef.h:130
bool IsNode() const
Definition ObjectRef.h:120
const TypeInfoRef & reference
Definition TypeInfoSet.h:37
ObjectFileRef(const ObjectFileRef &ref)=default
Type type
The type of the cell.
Definition GroundTile.h:92
bool operator<(const ObjectOSMRef &reference) const
Definition ObjectRef.h:70
ObjectOSMRef(OSMId id, OSMRefType type)
Definition ObjectRef.h:57
bool operator!=(const ObjectFileRef &reference) const
Definition ObjectRef.h:184
bool operator==(const ObjectOSMRef &reference) const
Definition ObjectRef.h:75
bool operator()(const ObjectFileRef &a, const ObjectFileRef &b) const
Definition ObjectRef.h:249
ObjectFileRef & operator=(const ObjectFileRef &other)=default
void Set(const OSMId &id, const OSMRefType &type)
Definition ObjectRef.h:85
bool operator!=(const ObjectOSMRef &reference) const
Definition ObjectRef.h:80
bool operator==(const ObjectFileRef &reference) const
Definition ObjectRef.h:179
ObjectFileRef & operator=(ObjectFileRef &&other)=default
int64_t OSMId
Definition OSMScoutTypes.h:33
uint64_t FileOffset
Definition OSMScoutTypes.h:46
Definition Area.h:39
RefType
Definition ObjectRef.h:139
@ refNode
Definition ObjectRef.h:141
@ refArea
Definition ObjectRef.h:142
@ refWay
Definition ObjectRef.h:143
@ refNone
Definition ObjectRef.h:140
OSMRefType
Definition ObjectRef.h:35
@ osmRefNode
Definition ObjectRef.h:37
@ osmRefWay
Definition ObjectRef.h:38
@ osmRefNone
Definition ObjectRef.h:36
@ osmRefRelation
Definition ObjectRef.h:39