1 #ifndef OSMIUM_VISITOR_HPP
2 #define OSMIUM_VISITOR_HPP
36 #include <type_traits>
48 class RelationMemberList;
58 template <
typename T,
typename U>
61 template <
class THandler,
class TItem>
62 inline void apply_item_recurse(TItem& item, THandler& handler) {
63 switch (item.type()) {
67 handler.osm_object(
static_cast<ConstIfConst<TItem, osmium::OSMObject>&
>(item));
68 handler.node(
static_cast<ConstIfConst<TItem, osmium::Node>&
>(item));
71 handler.osm_object(
static_cast<ConstIfConst<TItem, osmium::OSMObject>&
>(item));
72 handler.way(
static_cast<ConstIfConst<TItem, osmium::Way>&
>(item));
75 handler.osm_object(
static_cast<ConstIfConst<TItem, osmium::OSMObject>&
>(item));
76 handler.relation(
static_cast<ConstIfConst<TItem, osmium::Relation>&
>(item));
79 handler.osm_object(
static_cast<ConstIfConst<TItem, osmium::OSMObject>&
>(item));
80 handler.area(
static_cast<ConstIfConst<TItem, osmium::Area>&
>(item));
83 handler.changeset(
static_cast<ConstIfConst<TItem, osmium::Changeset>&
>(item));
86 handler.tag_list(
static_cast<ConstIfConst<TItem, osmium::TagList>&
>(item));
89 handler.way_node_list(
static_cast<ConstIfConst<TItem, osmium::WayNodeList>&
>(item));
93 handler.relation_member_list(
static_cast<ConstIfConst<TItem, osmium::RelationMemberList>&
>(item));
96 handler.outer_ring(
static_cast<ConstIfConst<TItem, osmium::OuterRing>&
>(item));
99 handler.inner_ring(
static_cast<ConstIfConst<TItem, osmium::InnerRing>&
>(item));
104 template <
class THandler>
105 inline void apply_item_recurse(
const osmium::OSMEntity& item, THandler& handler) {
106 switch (item.
type()) {
108 handler.osm_object(static_cast<const osmium::OSMObject&>(item));
109 handler.node(static_cast<const osmium::Node&>(item));
112 handler.osm_object(static_cast<const osmium::OSMObject&>(item));
113 handler.way(static_cast<const osmium::Way&>(item));
116 handler.osm_object(static_cast<const osmium::OSMObject&>(item));
117 handler.relation(static_cast<const osmium::Relation&>(item));
120 handler.osm_object(static_cast<const osmium::OSMObject&>(item));
121 handler.area(static_cast<const osmium::Area&>(item));
124 handler.changeset(static_cast<const osmium::Changeset&>(item));
131 template <
class THandler>
133 switch (item.
type()) {
135 handler.osm_object(static_cast<osmium::OSMObject&>(item));
136 handler.node(static_cast<osmium::Node&>(item));
139 handler.osm_object(static_cast<osmium::OSMObject&>(item));
140 handler.way(static_cast<osmium::Way&>(item));
143 handler.osm_object(static_cast<osmium::OSMObject&>(item));
144 handler.relation(static_cast<osmium::Relation&>(item));
147 handler.osm_object(static_cast<osmium::OSMObject&>(item));
148 handler.area(static_cast<osmium::Area&>(item));
151 handler.changeset(static_cast<osmium::Changeset&>(item));
158 template <
class THandler>
159 inline void apply_item_recurse(
const osmium::OSMObject& item, THandler& handler) {
160 switch (item.
type()) {
162 handler.osm_object(item);
163 handler.node(static_cast<const osmium::Node&>(item));
166 handler.osm_object(item);
167 handler.way(static_cast<const osmium::Way&>(item));
170 handler.osm_object(item);
171 handler.relation(static_cast<const osmium::Relation&>(item));
174 handler.osm_object(item);
175 handler.area(static_cast<const osmium::Area&>(item));
182 template <
class THandler>
184 switch (item.
type()) {
186 handler.osm_object(item);
187 handler.node(static_cast<osmium::Node&>(item));
190 handler.osm_object(item);
191 handler.way(static_cast<osmium::Way&>(item));
194 handler.osm_object(item);
195 handler.relation(static_cast<osmium::Relation&>(item));
198 handler.osm_object(item);
199 handler.area(static_cast<osmium::Area&>(item));
206 template <
class THandler,
class TItem,
class ...TRest>
207 inline void apply_item_recurse(TItem& item, THandler& handler, TRest&... more) {
208 apply_item_recurse(item, handler);
209 apply_item_recurse(item, more...);
212 template <
class THandler>
213 inline void flush_recurse(THandler& handler) {
217 template <
class THandler,
class ...TRest>
218 inline void flush_recurse(THandler& handler, TRest&... more) {
219 flush_recurse(handler);
220 flush_recurse(more...);
225 template <
class ...THandlers>
227 detail::apply_item_recurse(item, handlers...);
230 template <
class ...THandlers>
232 detail::apply_item_recurse(item, handlers...);
235 template <
class TIterator,
class ...THandlers>
236 inline void apply(TIterator it, TIterator
end, THandlers&... handlers) {
237 for (; it !=
end; ++it) {
238 detail::apply_item_recurse(*it, handlers...);
240 detail::flush_recurse(handlers...);
243 template <
class TContainer,
class ...THandlers>
244 inline void apply(TContainer& c, THandlers&... handlers) {
248 template <
class ...THandlers>
255 #endif // OSMIUM_VISITOR_HPP
t_const_iterator< T > cend() const
Definition: buffer.hpp:453
Definition: item_type.hpp:183
type
Definition: entity_bits.hpp:60
OSMEntity is the abstract base class for the OSMObject and Changeset classes.
Definition: entity.hpp:63
void apply(TIterator it, TIterator end, THandlers &...handlers)
Definition: visitor.hpp:236
void apply_item(const osmium::memory::Item &item, THandlers &...handlers)
Definition: visitor.hpp:226
Namespace for everything in the Osmium library.
Definition: assembler.hpp:55
osmium::io::InputIterator< osmium::io::Reader > end(osmium::io::Reader &)
Definition: reader_iterator.hpp:45
Definition: buffer.hpp:95
t_const_iterator< T > cbegin() const
Definition: buffer.hpp:435
osmium::io::InputIterator< osmium::io::Reader > begin(osmium::io::Reader &reader)
Definition: reader_iterator.hpp:41
item_type type() const noexcept
Definition: item.hpp:156
Definition: object.hpp:58