This switches out the `<variant/optional.hpp>` implementation of the optional monad to the one from Boost. The following trick makes sure we keep compile times down: - use `<boost/optional/optional_fwd.hpp>` to forward declare the optional type in header, then include the full blown optional header only in the implementation file. - do the same for the files we touch, e.g. forward declare osmium types, allowing us to remove the osmium header dependency from our headers: `namespace osmium { class Relation; } and then include the appropriate osmium headers in the implementation file only. We should do this globally... References: - http://www.boost.org/doc/libs/1_59_0/libs/optional/doc/html/index.html - https://github.com/osmcode/libosmium/issues/123
78 lines
2.8 KiB
C++
78 lines
2.8 KiB
C++
/*
|
|
|
|
Copyright (c) 2014, Project OSRM contributors
|
|
All rights reserved.
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
are permitted provided that the following conditions are met:
|
|
|
|
Redistributions of source code must retain the above copyright notice, this list
|
|
of conditions and the following disclaimer.
|
|
Redistributions in binary form must reproduce the above copyright notice, this
|
|
list of conditions and the following disclaimer in the documentation and/or
|
|
other materials provided with the distribution.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
#ifndef EXTRACTOR_CALLBACKS_HPP
|
|
#define EXTRACTOR_CALLBACKS_HPP
|
|
|
|
#include "../typedefs.h"
|
|
#include <boost/optional/optional_fwd.hpp>
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
struct ExternalMemoryNode;
|
|
class ExtractionContainers;
|
|
struct InputRestrictionContainer;
|
|
struct ExtractionNode;
|
|
struct ExtractionWay;
|
|
namespace osmium
|
|
{
|
|
class Node;
|
|
class Way;
|
|
}
|
|
|
|
/**
|
|
* This class is uses by the extractor with the results of the
|
|
* osmium based parsing and the customization through the lua profile.
|
|
*
|
|
* It mediates between the multi-threaded extraction process and the external memory containers.
|
|
* Thus the synchronization is handled inside of the extractor.
|
|
*/
|
|
class ExtractorCallbacks
|
|
{
|
|
private:
|
|
// used to deduplicate street names: actually maps to name ids
|
|
std::unordered_map<std::string, NodeID> string_map;
|
|
ExtractionContainers &external_memory;
|
|
|
|
public:
|
|
ExtractorCallbacks() = delete;
|
|
ExtractorCallbacks(const ExtractorCallbacks &) = delete;
|
|
explicit ExtractorCallbacks(ExtractionContainers &extraction_containers);
|
|
|
|
// warning: caller needs to take care of synchronization!
|
|
void ProcessNode(const osmium::Node ¤t_node, const ExtractionNode &result_node);
|
|
|
|
// warning: caller needs to take care of synchronization!
|
|
void ProcessRestriction(const boost::optional<InputRestrictionContainer> &restriction);
|
|
|
|
// warning: caller needs to take care of synchronization!
|
|
void ProcessWay(const osmium::Way ¤t_way, const ExtractionWay &result_way);
|
|
};
|
|
|
|
#endif /* EXTRACTOR_CALLBACKS_HPP */
|