diff --git a/include/extractor/name_table.hpp b/include/extractor/name_table.hpp index cc26cc1819..fde1473292 100644 --- a/include/extractor/name_table.hpp +++ b/include/extractor/name_table.hpp @@ -1,5 +1,5 @@ -#ifndef OSRM_EXTRACTOR_NAME_TABLE_HPP -#define OSRM_EXTRACTOR_NAME_TABLE_HPP +#ifndef OSRM_EXTRACTOR_STRING_TABLE_HPP +#define OSRM_EXTRACTOR_STRING_TABLE_HPP #include "util/indexed_data.hpp" #include "util/typedefs.hpp" @@ -12,7 +12,7 @@ namespace osrm::extractor namespace detail { -template class NameTableImpl; +template class StringTableImpl; } // namespace detail namespace serialization @@ -20,12 +20,12 @@ namespace serialization template inline void read(storage::tar::FileReader &reader, const std::string &name, - detail::NameTableImpl &index_data); + detail::StringTableImpl &index_data); template inline void write(storage::tar::FileWriter &writer, const std::string &name, - const detail::NameTableImpl &index_data); + const detail::StringTableImpl &index_data); } // namespace serialization namespace detail @@ -44,7 +44,7 @@ namespace detail // // Offset 0 is name, 1 is destination, 2 is pronunciation, 3 is ref, 4 is exits // See datafacades and extractor callbacks for details. -template class NameTableImpl +template class StringTableImpl { public: using IndexedData = @@ -52,46 +52,46 @@ template class NameTableImpl using ResultType = typename IndexedData::ResultType; using ValueType = typename IndexedData::ValueType; - NameTableImpl() {} + StringTableImpl() {} - NameTableImpl(IndexedData indexed_data_) : indexed_data{std::move(indexed_data_)} {} + StringTableImpl(IndexedData indexed_data_) : indexed_data{std::move(indexed_data_)} {} - std::string_view GetNameForID(const NameID id) const + std::string_view GetNameForID(const StringViewID id) const { - if (id == INVALID_NAMEID) + if (id == INVALID_STRINGVIEWID) return {}; return indexed_data.at(id + 0); } - std::string_view GetDestinationsForID(const NameID id) const + std::string_view GetDestinationsForID(const StringViewID id) const { - if (id == INVALID_NAMEID) + if (id == INVALID_STRINGVIEWID) return {}; return indexed_data.at(id + 1); } - std::string_view GetExitsForID(const NameID id) const + std::string_view GetExitsForID(const StringViewID id) const { - if (id == INVALID_NAMEID) + if (id == INVALID_STRINGVIEWID) return {}; return indexed_data.at(id + 4); } - std::string_view GetRefForID(const NameID id) const + std::string_view GetRefForID(const StringViewID id) const { - if (id == INVALID_NAMEID) + if (id == INVALID_STRINGVIEWID) return {}; const constexpr auto OFFSET_REF = 3u; return indexed_data.at(id + OFFSET_REF); } - std::string_view GetPronunciationForID(const NameID id) const + std::string_view GetPronunciationForID(const StringViewID id) const { - if (id == INVALID_NAMEID) + if (id == INVALID_STRINGVIEWID) return {}; const constexpr auto OFFSET_PRONUNCIATION = 2u; @@ -100,19 +100,25 @@ template class NameTableImpl friend void serialization::read(storage::tar::FileReader &reader, const std::string &name, - NameTableImpl &index_data); + StringTableImpl &index_data); friend void serialization::write(storage::tar::FileWriter &writer, const std::string &name, - const NameTableImpl &index_data); + const StringTableImpl &index_data); private: IndexedData indexed_data; }; } // namespace detail -using NameTable = detail::NameTableImpl; -using NameTableView = detail::NameTableImpl; +using StringTable = detail::StringTableImpl; +using StringTableView = detail::StringTableImpl; + +// Backwards compatibility aliases (deprecated) +using NameTable = StringTable; +using NameTableView = StringTableView; +using PreDatafacadeStringViewer = StringTable; +using PreDatafacadeStringViewerView = StringTableView; } // namespace osrm::extractor -#endif // OSRM_EXTRACTOR_NAME_TABLE_HPP +#endif // OSRM_EXTRACTOR_STRING_TABLE_HPP diff --git a/include/extractor/node_based_edge.hpp b/include/extractor/node_based_edge.hpp index d98e2283e6..f6388b4f84 100644 --- a/include/extractor/node_based_edge.hpp +++ b/include/extractor/node_based_edge.hpp @@ -65,7 +65,7 @@ struct NodeBasedEdgeClassification // see as part of the API output but that does not influence navigation struct NodeBasedEdgeAnnotation { - NameID name_id; // 32 4 + StringViewID string_view_id; // 32 4 LaneDescriptionID lane_description_id; // 16 2 ClassData classes; // 8 1 TravelMode travel_mode : 4; // 4 @@ -73,19 +73,23 @@ struct NodeBasedEdgeAnnotation bool CanCombineWith(const NodeBasedEdgeAnnotation &other) const { - return ( - std::tie(name_id, classes, travel_mode, is_left_hand_driving) == - std::tie(other.name_id, other.classes, other.travel_mode, other.is_left_hand_driving)); + return (std::tie(string_view_id, classes, travel_mode, is_left_hand_driving) == + std::tie(other.string_view_id, + other.classes, + other.travel_mode, + other.is_left_hand_driving)); } bool operator<(const NodeBasedEdgeAnnotation &other) const { - return (std::tie(name_id, lane_description_id, classes, travel_mode, is_left_hand_driving) < - std::tie(other.name_id, - other.lane_description_id, - other.classes, - other.travel_mode, - other.is_left_hand_driving)); + return ( + std::tie( + string_view_id, lane_description_id, classes, travel_mode, is_left_hand_driving) < + std::tie(other.string_view_id, + other.lane_description_id, + other.classes, + other.travel_mode, + other.is_left_hand_driving)); } }; diff --git a/include/util/typedefs.hpp b/include/util/typedefs.hpp index ab6abc750f..e3ae875d03 100644 --- a/include/util/typedefs.hpp +++ b/include/util/typedefs.hpp @@ -97,10 +97,13 @@ static const OSMWayID MIN_OSM_WAYID = OSMWayID{std::numeric_limits; using EdgeDuration = osrm::Alias; using EdgeDistance = osrm::Alias; @@ -128,9 +131,13 @@ static const PackedGeometryID SPECIAL_GEOMETRYID = std::numeric_limits::max() >> 1; static const EdgeID SPECIAL_EDGEID = std::numeric_limits::max(); static const RestrictionID SPECIAL_RESTRICTIONID = std::numeric_limits::max(); -static const NameID INVALID_NAMEID = std::numeric_limits::max(); -static const NameID EMPTY_NAMEID = 0; +static const StringViewID INVALID_STRINGVIEWID = std::numeric_limits::max(); +static const StringViewID EMPTY_STRINGVIEWID = 0; static const unsigned INVALID_COMPONENTID = 0; + +// Backwards compatibility aliases (deprecated) +static const auto INVALID_NAMEID = INVALID_STRINGVIEWID; +static const auto EMPTY_NAMEID = EMPTY_STRINGVIEWID; static const std::size_t SEGMENT_WEIGHT_BITS = 22; static const std::size_t SEGMENT_DURATION_BITS = 22; static const SegmentWeight INVALID_SEGMENT_WEIGHT = SegmentWeight{(1u << SEGMENT_WEIGHT_BITS) - 1};