libosmscout 1.1.1
Loading...
Searching...
No Matches
AccessRestrictedFeature.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_FEATURE_ACCESS_RESTRICTED_FEATURE_H
2#define OSMSCOUT_FEATURE_ACCESS_RESTRICTED_FEATURE_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2014 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
23#include <osmscout/TypeConfig.h>
25
27
28namespace osmscout {
29
31 {
32 public:
33 enum Access : uint8_t {
34 foot = 1u << 0u,
35 bicycle = 1u << 1u,
36 car = 1u << 2u,
37 };
38
39 private:
40 uint8_t access=0;
41
42 public:
44
45 explicit AccessRestrictedFeatureValue(uint8_t access)
46 : access(access)
47 {
48 // no code
49 }
50
51 void SetAccess(uint8_t access)
52 {
53 this->access=access;
54 }
55
56 uint8_t GetAccess() const
57 {
58 return access;
59 }
60
61 bool CanAccess() const
62 {
63 return (access & (foot|bicycle|car))!=0;
64 }
65
66 bool CanAccess(Vehicle vehicle) const
67 {
68 switch (vehicle)
69 {
70 case vehicleFoot:
71 return (access &foot)!=0;
72 case vehicleBicycle:
73 return (access & bicycle)!=0;
74 case vehicleCar:
75 return (access & car)!=0;
76 }
77
78 return false;
79 }
80
81 bool CanAccess(VehicleMask vehicleMask) const
82 {
83 if ((vehicleMask & vehicleFoot)!=0 &&
84 (access & foot)!=0) {
85 return true;
86 }
87
88 if ((vehicleMask & vehicleBicycle)!=0 &&
89 (access & bicycle)!=0) {
90 return true;
91 }
92
93 return (vehicleMask & vehicleCar)!=0 &&
94 (access & car)!=0;
95 }
96
97 bool CanAccessFoot() const
98 {
99 return (access & foot)!=0;
100 }
101
102 bool CanAccessBicycle() const
103 {
104 return (access & bicycle)!=0;
105 }
106
107 bool CanAccessCar() const
108 {
109 return (access & car)!=0;
110 }
111
112 void Read(FileScanner& scanner) override;
113 void Write(FileWriter& writer) override;
114
116 bool operator==(const FeatureValue& other) const override;
117 };
118
130 {
131 private:
132 TagId tagAccess;
133 TagId tagFoot;
134 TagId tagBicycle;
135 TagId tagMotorVehicle;
136
137 public:
139 static const char* const NAME;
140
141 public:
142 void Initialize(TagRegistry& tagRegistry) override;
143
144 std::string GetName() const override;
145
146 size_t GetValueAlignment() const override;
147 size_t GetValueSize() const override;
148 FeatureValue* AllocateValue(void* buffer) override;
149
150 void Parse(TagErrorReporter& reporter,
151 const TagRegistry& tagRegistry,
152 const FeatureInstance& feature,
153 const ObjectOSMRef& object,
154 const TagMap& tags,
155 FeatureValueBuffer& buffer) const override;
156 };
157
160}
161
162#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
Definition AccessRestrictedFeature.h:130
size_t GetValueAlignment() const override
FeatureValue * AllocateValue(void *buffer) override
std::string GetName() const override
size_t GetValueSize() const override
static const char *const NAME
Definition AccessRestrictedFeature.h:139
void Initialize(TagRegistry &tagRegistry) override
void Parse(TagErrorReporter &reporter, const TagRegistry &tagRegistry, const FeatureInstance &feature, const ObjectOSMRef &object, const TagMap &tags, FeatureValueBuffer &buffer) const override
uint8_t GetAccess() const
Definition AccessRestrictedFeature.h:56
bool operator==(const FeatureValue &other) const override
void Write(FileWriter &writer) override
Access
Definition AccessRestrictedFeature.h:33
@ car
Definition AccessRestrictedFeature.h:36
@ bicycle
Definition AccessRestrictedFeature.h:35
@ foot
Definition AccessRestrictedFeature.h:34
void Read(FileScanner &scanner) override
AccessRestrictedFeatureValue(uint8_t access)
Definition AccessRestrictedFeature.h:45
bool CanAccessBicycle() const
Definition AccessRestrictedFeature.h:102
bool CanAccess(Vehicle vehicle) const
Definition AccessRestrictedFeature.h:66
void SetAccess(uint8_t access)
Definition AccessRestrictedFeature.h:51
bool CanAccess(VehicleMask vehicleMask) const
Definition AccessRestrictedFeature.h:81
bool CanAccess() const
Definition AccessRestrictedFeature.h:61
bool CanAccessCar() const
Definition AccessRestrictedFeature.h:107
AccessRestrictedFeatureValue & operator=(const FeatureValue &other) override
bool CanAccessFoot() const
Definition AccessRestrictedFeature.h:97
Definition FeatureReader.h:40
Definition TypeFeature.h:41
Definition FeatureReader.h:143
Definition TagErrorReporter.h:33
Definition Area.h:39
FeatureReader< AccessRestrictedFeature > AccessRestrictedFeatureReader
Definition AccessRestrictedFeature.h:158
std::unordered_map< TagId, std::string > TagMap
Definition Tag.h:41
uint8_t VehicleMask
Definition OSMScoutTypes.h:61
FeatureValueReader< AccessRestrictedFeature, AccessRestrictedFeatureValue > AccessRestrictedFeatureValueReader
Definition AccessRestrictedFeature.h:159
Vehicle
Definition OSMScoutTypes.h:55
@ vehicleBicycle
Definition OSMScoutTypes.h:57
@ vehicleFoot
Definition OSMScoutTypes.h:56
@ vehicleCar
Definition OSMScoutTypes.h:58
uint16_t TagId
Definition Tag.h:39