2016-01-11 10:55:22 -05:00
|
|
|
#ifndef EDGE_BASED_EDGE_HPP
|
|
|
|
#define EDGE_BASED_EDGE_HPP
|
|
|
|
|
|
|
|
#include "extractor/travel_mode.hpp"
|
|
|
|
#include "util/typedefs.hpp"
|
2016-11-18 03:38:26 -05:00
|
|
|
#include <tuple>
|
2016-01-11 10:55:22 -05:00
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
|
|
|
|
struct EdgeBasedEdge
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EdgeBasedEdge();
|
|
|
|
|
|
|
|
template <class EdgeT> explicit EdgeBasedEdge(const EdgeT &other);
|
|
|
|
|
|
|
|
EdgeBasedEdge(const NodeID source,
|
|
|
|
const NodeID target,
|
|
|
|
const NodeID edge_id,
|
|
|
|
const EdgeWeight weight,
|
2017-01-19 16:52:09 -05:00
|
|
|
const EdgeWeight duration,
|
2016-01-11 10:55:22 -05:00
|
|
|
const bool forward,
|
|
|
|
const bool backward);
|
|
|
|
|
|
|
|
bool operator<(const EdgeBasedEdge &other) const;
|
|
|
|
|
|
|
|
NodeID source;
|
|
|
|
NodeID target;
|
|
|
|
NodeID edge_id;
|
2017-01-19 16:52:09 -05:00
|
|
|
EdgeWeight weight;
|
|
|
|
EdgeWeight duration : 30;
|
2016-05-12 12:50:10 -04:00
|
|
|
std::uint32_t forward : 1;
|
|
|
|
std::uint32_t backward : 1;
|
2016-01-11 10:55:22 -05:00
|
|
|
};
|
2017-01-19 16:52:09 -05:00
|
|
|
static_assert(sizeof(extractor::EdgeBasedEdge) == 20,
|
2016-05-12 12:50:10 -04:00
|
|
|
"Size of extractor::EdgeBasedEdge type is "
|
|
|
|
"bigger than expected. This will influence "
|
|
|
|
"memory consumption.");
|
2016-01-11 10:55:22 -05:00
|
|
|
|
|
|
|
// Impl.
|
|
|
|
|
|
|
|
inline EdgeBasedEdge::EdgeBasedEdge()
|
2017-01-19 16:52:09 -05:00
|
|
|
: source(0), target(0), edge_id(0), weight(0), duration(0), forward(false), backward(false)
|
2016-01-11 10:55:22 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
inline EdgeBasedEdge::EdgeBasedEdge(const NodeID source,
|
|
|
|
const NodeID target,
|
|
|
|
const NodeID edge_id,
|
|
|
|
const EdgeWeight weight,
|
2017-01-19 16:52:09 -05:00
|
|
|
const EdgeWeight duration,
|
2016-01-11 10:55:22 -05:00
|
|
|
const bool forward,
|
|
|
|
const bool backward)
|
2017-01-19 16:52:09 -05:00
|
|
|
: source(source), target(target), edge_id(edge_id), weight(weight), duration(duration),
|
|
|
|
forward(forward), backward(backward)
|
2016-01-11 10:55:22 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool EdgeBasedEdge::operator<(const EdgeBasedEdge &other) const
|
|
|
|
{
|
2016-11-18 03:38:26 -05:00
|
|
|
const auto unidirectional = (!forward || !backward);
|
|
|
|
const auto other_is_unidirectional = (!other.forward || !other.backward);
|
|
|
|
// if all items are the same, we want to keep bidirectional edges. due to the `<` operator,
|
|
|
|
// preferring 0 (false) over 1 (true), we need to compare the inverse of `bidirectional`
|
|
|
|
return std::tie(source, target, weight, unidirectional) <
|
|
|
|
std::tie(other.source, other.target, other.weight, other_is_unidirectional);
|
2016-01-11 10:55:22 -05:00
|
|
|
}
|
|
|
|
} // ns extractor
|
|
|
|
} // ns osrm
|
|
|
|
|
|
|
|
#endif /* EDGE_BASED_EDGE_HPP */
|