2014-11-28 09:00:48 -05:00
|
|
|
#ifndef EXTRACTOR_CALLBACKS_HPP
|
|
|
|
#define EXTRACTOR_CALLBACKS_HPP
|
2012-08-29 12:33:18 -04:00
|
|
|
|
2017-06-27 18:01:05 -04:00
|
|
|
#include "extractor/class_data.hpp"
|
2016-06-21 04:41:08 -04:00
|
|
|
#include "extractor/guidance/turn_lane_types.hpp"
|
2016-07-26 09:00:58 -04:00
|
|
|
#include "util/typedefs.hpp"
|
2016-06-21 04:41:08 -04:00
|
|
|
|
2016-05-26 18:47:46 -04:00
|
|
|
#include <boost/functional/hash.hpp>
|
2016-06-02 07:14:33 -04:00
|
|
|
#include <boost/optional/optional_fwd.hpp>
|
2014-08-29 05:27:51 -04:00
|
|
|
|
2014-01-09 10:13:35 -05:00
|
|
|
#include <string>
|
2014-08-26 11:50:34 -04:00
|
|
|
#include <unordered_map>
|
2012-08-29 12:33:18 -04:00
|
|
|
|
2015-09-18 08:26:32 -04:00
|
|
|
namespace osmium
|
|
|
|
{
|
|
|
|
class Node;
|
|
|
|
class Way;
|
|
|
|
}
|
2014-01-09 10:13:35 -05:00
|
|
|
|
2016-09-05 09:01:51 -04:00
|
|
|
namespace std
|
|
|
|
{
|
2017-06-29 16:12:25 -04:00
|
|
|
template <> struct hash<std::tuple<std::string, std::string, std::string, std::string, std::string>>
|
2016-09-05 09:01:51 -04:00
|
|
|
{
|
2017-06-29 16:12:25 -04:00
|
|
|
std::size_t operator()(
|
|
|
|
const std::tuple<std::string, std::string, std::string, std::string, std::string> &mk) const
|
2016-09-09 12:28:44 -04:00
|
|
|
noexcept
|
2016-09-05 09:01:51 -04:00
|
|
|
{
|
|
|
|
std::size_t seed = 0;
|
|
|
|
boost::hash_combine(seed, std::get<0>(mk));
|
|
|
|
boost::hash_combine(seed, std::get<1>(mk));
|
|
|
|
boost::hash_combine(seed, std::get<2>(mk));
|
2016-09-09 12:28:44 -04:00
|
|
|
boost::hash_combine(seed, std::get<3>(mk));
|
2017-06-29 16:12:25 -04:00
|
|
|
boost::hash_combine(seed, std::get<4>(mk));
|
2016-09-05 09:01:51 -04:00
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
|
|
|
|
class ExtractionContainers;
|
|
|
|
struct ExtractionNode;
|
|
|
|
struct ExtractionWay;
|
2016-05-12 12:50:10 -04:00
|
|
|
struct ProfileProperties;
|
2017-07-06 11:09:24 -04:00
|
|
|
struct InputConditionalTurnRestriction;
|
2016-01-05 10:51:13 -05:00
|
|
|
|
2015-04-10 06:35:24 -04:00
|
|
|
/**
|
2016-09-05 09:01:51 -04:00
|
|
|
* This class is used by the extractor with the results of the
|
2015-04-10 06:35:24 -04:00
|
|
|
* 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.
|
|
|
|
*/
|
2014-05-09 10:17:31 -04:00
|
|
|
class ExtractorCallbacks
|
|
|
|
{
|
|
|
|
private:
|
2017-06-29 16:12:25 -04:00
|
|
|
// used to deduplicate street names, refs, destinations, pronunciation, exits:
|
|
|
|
// actually maps to name ids
|
|
|
|
using MapKey = std::tuple<std::string, std::string, std::string, std::string, std::string>;
|
2016-05-26 18:47:46 -04:00
|
|
|
using MapVal = unsigned;
|
2016-09-05 09:01:51 -04:00
|
|
|
std::unordered_map<MapKey, MapVal> string_map;
|
2014-05-09 10:17:31 -04:00
|
|
|
ExtractionContainers &external_memory;
|
2017-06-27 18:01:05 -04:00
|
|
|
std::unordered_map<std::string, ClassData> &classes_map;
|
|
|
|
guidance::LaneDescriptionMap &lane_description_map;
|
2016-05-12 12:50:10 -04:00
|
|
|
bool fallback_to_duration;
|
2017-03-29 17:48:57 -04:00
|
|
|
bool force_split_edges;
|
2014-01-09 10:13:35 -05:00
|
|
|
|
2014-05-09 10:17:31 -04:00
|
|
|
public:
|
2017-06-27 18:01:05 -04:00
|
|
|
using ClassesMap = std::unordered_map<std::string, ClassData>;
|
|
|
|
|
2016-05-12 12:50:10 -04:00
|
|
|
explicit ExtractorCallbacks(ExtractionContainers &extraction_containers,
|
2017-06-27 18:01:05 -04:00
|
|
|
std::unordered_map<std::string, ClassData> &classes_map,
|
|
|
|
guidance::LaneDescriptionMap &lane_description_map,
|
2016-05-12 12:50:10 -04:00
|
|
|
const ProfileProperties &properties);
|
2012-08-29 12:33:18 -04:00
|
|
|
|
Takes care of proper special member generation globally, fixes #1689
Phew, a lot of classes were affected by this. The rationale for the
changes are as follows:
- When a type X declares any constructor, the default constructor is
not declared, so there is no need for X() = delete there. In fact,
there is brutal difference between those two: deleted members
participate in overload resolution, but not-declared members do not!
- When a type X wants to be non-copyable (e.g. to be only movable, like
threads, unique_ptrs, and so on), you can either do it by inheriting
from boost::noncopyable (the old way), or better declare both (!) the
copy constructor _and_ the copy assignment operator as deleted:
X(X const&) = delete;
X& operator=(X const&) = delete;
We had tons of types with deleted copy constructors that were lacking
a corresponding deleted copy assignment operator, making them still
copyable and you wouldn't even notice (read: scary)!
References:
- http://accu.org/content/conf2014/Howard_Hinnant_Accu_2014.pdf
- http://www.boost.org/doc/libs/master/libs/core/doc/html/core/noncopyable.html
Note: I know, I'm quoting Hinnant's extraordinary slides a lot, but
getting the sematic right here is so incredibly important.
2016-01-27 05:20:55 -05:00
|
|
|
ExtractorCallbacks(const ExtractorCallbacks &) = delete;
|
|
|
|
ExtractorCallbacks &operator=(const ExtractorCallbacks &) = delete;
|
|
|
|
|
2014-05-09 10:17:31 -04:00
|
|
|
// warning: caller needs to take care of synchronization!
|
2014-10-13 07:53:06 -04:00
|
|
|
void ProcessNode(const osmium::Node ¤t_node, const ExtractionNode &result_node);
|
2012-08-29 12:33:18 -04:00
|
|
|
|
2014-05-09 10:17:31 -04:00
|
|
|
// warning: caller needs to take care of synchronization!
|
2017-07-06 11:09:24 -04:00
|
|
|
void ProcessRestriction(const InputConditionalTurnRestriction &restriction);
|
2012-08-29 12:33:18 -04:00
|
|
|
|
2014-05-09 10:17:31 -04:00
|
|
|
// warning: caller needs to take care of synchronization!
|
2014-10-13 07:53:06 -04:00
|
|
|
void ProcessWay(const osmium::Way ¤t_way, const ExtractionWay &result_way);
|
2012-08-29 12:33:18 -04:00
|
|
|
};
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#endif /* EXTRACTOR_CALLBACKS_HPP */
|