1#ifndef OSMIUM_DYNAMIC_HANDLER_HPP
2#define OSMIUM_DYNAMIC_HANDLER_HPP
53 class HandlerWrapperBase {
57 HandlerWrapperBase() =
default;
59 HandlerWrapperBase(
const HandlerWrapperBase&) =
default;
60 HandlerWrapperBase& operator=(
const HandlerWrapperBase&) =
default;
62 HandlerWrapperBase(HandlerWrapperBase&&)
noexcept =
default;
63 HandlerWrapperBase& operator=(HandlerWrapperBase&&)
noexcept =
default;
65 virtual ~HandlerWrapperBase()
noexcept =
default;
82 virtual void flush() {
92#define OSMIUM_DYNAMIC_HANDLER_DISPATCH(_name_, _type_) \
93template <typename THandler> \
94auto _name_##_dispatch(THandler& handler, const osmium::_type_& object, int) -> decltype(handler._name_(object), void()) { \
95 handler._name_(object); \
97template <typename THandler> \
98auto _name_##_dispatch(THandler& handler, const osmium::_type_& object, long) -> decltype(handler(object), void()) { \
108 template <
typename THandler>
109 auto flush_dispatch(THandler& handler,
int ) ->
decltype(handler.flush(), void()) {
113 template <
typename THandler>
114 void flush_dispatch(THandler& ,
long ) {
117 template <
typename THandler>
118 class HandlerWrapper :
public HandlerWrapperBase {
124 template <
typename... TArgs>
125 explicit HandlerWrapper(TArgs&&... args) :
129 HandlerWrapper(
const HandlerWrapper&) =
default;
130 HandlerWrapper& operator=(
const HandlerWrapper&) =
default;
132 HandlerWrapper(HandlerWrapper&&) noexcept = default;
133 HandlerWrapper& operator=(HandlerWrapper&&) noexcept = default;
135 ~HandlerWrapper() noexcept override = default;
137 void node(const
osmium::Node& node) final {
138 node_dispatch(m_handler, node, 0);
142 way_dispatch(m_handler, way, 0);
146 relation_dispatch(m_handler, relation, 0);
150 area_dispatch(m_handler, area, 0);
154 changeset_dispatch(m_handler, changeset, 0);
158 flush_dispatch(m_handler, 0);
167 using impl_ptr = std::unique_ptr<osmium::handler::detail::HandlerWrapperBase>;
176 template <
typename THandler,
typename... TArgs>
177 void set(TArgs&&... args) {
178 m_impl.reset(
new osmium::handler::detail::HandlerWrapper<THandler>{std::forward<TArgs>(args)...});
An OSM Changeset, a group of changes made by a single user over a short period of time.
Definition: changeset.hpp:146
Definition: relation.hpp:161
Definition: dynamic_handler.hpp:165
impl_ptr m_impl
Definition: dynamic_handler.hpp:168
void node(const osmium::Node &node)
Definition: dynamic_handler.hpp:181
void changeset(const osmium::Changeset &changeset)
Definition: dynamic_handler.hpp:197
void set(TArgs &&... args)
Definition: dynamic_handler.hpp:177
void way(const osmium::Way &way)
Definition: dynamic_handler.hpp:185
void flush()
Definition: dynamic_handler.hpp:201
void area(const osmium::Area &area)
Definition: dynamic_handler.hpp:193
std::unique_ptr< osmium::handler::detail::HandlerWrapperBase > impl_ptr
Definition: dynamic_handler.hpp:167
DynamicHandler()
Definition: dynamic_handler.hpp:172
void relation(const osmium::Relation &relation)
Definition: dynamic_handler.hpp:189
Definition: handler.hpp:71
#define OSMIUM_DYNAMIC_HANDLER_DISPATCH(_name_, _type_)
Definition: dynamic_handler.hpp:92
@ forward
Linestring has same direction as way.
@ changeset
Definition: entity_bits.hpp:75
@ relation
Definition: entity_bits.hpp:70
@ area
Definition: entity_bits.hpp:72
@ way
Definition: entity_bits.hpp:69
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
Definition: location.hpp:555