diff --git a/include/contractor/contractor.hpp b/include/contractor/contractor.hpp index 71577d6ae..d4b3d1fec 100644 --- a/include/contractor/contractor.hpp +++ b/include/contractor/contractor.hpp @@ -68,9 +68,8 @@ class Contractor void WriteCoreNodeMarker(std::vector &&is_core_node) const; void WriteNodeLevels(std::vector &&node_levels) const; void ReadNodeLevels(std::vector &contraction_order) const; - void - WriteContractedGraph(unsigned number_of_edge_based_nodes, - util::DeallocatingVector contracted_edge_list); + void WriteContractedGraph(unsigned number_of_edge_based_nodes, + util::DeallocatingVector contracted_edge_list); void FindComponents(unsigned max_edge_id, const util::DeallocatingVector &edges, std::vector &nodes) const; diff --git a/include/contractor/query_graph.hpp b/include/contractor/query_graph.hpp index fc8a45720..e5758dcfe 100644 --- a/include/contractor/query_graph.hpp +++ b/include/contractor/query_graph.hpp @@ -3,10 +3,8 @@ #include "contractor/query_edge.hpp" -#include "util/typedefs.hpp" #include "util/static_graph.hpp" - -#include +#include "util/typedefs.hpp" namespace osrm { @@ -15,12 +13,12 @@ namespace contractor namespace detail { -template using QueryGraph = util::StaticGraph; +template +using QueryGraph = util::StaticGraph; } using QueryGraph = detail::QueryGraph; using QueryGraphView = detail::QueryGraph; - } } diff --git a/include/extractor/edge_based_graph_factory.hpp b/include/extractor/edge_based_graph_factory.hpp index 654448a76..f813c09e2 100644 --- a/include/extractor/edge_based_graph_factory.hpp +++ b/include/extractor/edge_based_graph_factory.hpp @@ -17,11 +17,11 @@ #include "extractor/restriction_map.hpp" #include "util/deallocating_vector.hpp" -#include "util/packed_vector.hpp" #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" #include "util/name_table.hpp" #include "util/node_based_graph.hpp" +#include "util/packed_vector.hpp" #include "util/typedefs.hpp" #include "storage/io.hpp" diff --git a/include/extractor/files.hpp b/include/extractor/files.hpp index a34899677..be2b39020 100644 --- a/include/extractor/files.hpp +++ b/include/extractor/files.hpp @@ -18,10 +18,10 @@ namespace files { // reads .osrm.nodes -template +template inline void readNodes(const boost::filesystem::path &path, - util::ViewOrVector &coordinates, - util::detail::PackedVector &osm_node_ids) + util::ViewOrVector &coordinates, + util::detail::PackedVector &osm_node_ids) { const auto fingerprint = storage::io::FileReader::VerifyFingerprint; storage::io::FileReader reader{path, fingerprint}; @@ -31,10 +31,10 @@ inline void readNodes(const boost::filesystem::path &path, } // writes .osrm.nodes -template +template inline void writeNodes(const boost::filesystem::path &path, - const util::ViewOrVector &coordinates, - const util::detail::PackedVector &osm_node_ids) + const util::ViewOrVector &coordinates, + const util::detail::PackedVector &osm_node_ids) { const auto fingerprint = storage::io::FileWriter::GenerateFingerprint; storage::io::FileWriter writer{path, fingerprint}; @@ -126,9 +126,10 @@ inline void writeTurnData(const boost::filesystem::path &path, // reads .osrm.tls template -inline void readTurnLaneDescriptions(const boost::filesystem::path &path, - util::ViewOrVector &turn_offsets, - util::ViewOrVector &turn_masks) +inline void readTurnLaneDescriptions( + const boost::filesystem::path &path, + util::ViewOrVector &turn_offsets, + util::ViewOrVector &turn_masks) { const auto fingerprint = storage::io::FileReader::HasNoFingerprint; storage::io::FileReader reader{path, fingerprint}; @@ -139,9 +140,10 @@ inline void readTurnLaneDescriptions(const boost::filesystem::path &path, // writes .osrm.tls template -inline void writeTurnLaneDescriptions(const boost::filesystem::path &path, - const util::ViewOrVector &turn_offsets, - const util::ViewOrVector &turn_masks) +inline void writeTurnLaneDescriptions( + const boost::filesystem::path &path, + const util::ViewOrVector &turn_offsets, + const util::ViewOrVector &turn_masks) { const auto fingerprint = storage::io::FileWriter::HasNoFingerprint; storage::io::FileWriter writer{path, fingerprint}; @@ -149,7 +151,6 @@ inline void writeTurnLaneDescriptions(const boost::filesystem::path &path, storage::serialization::write(writer, turn_offsets); storage::serialization::write(writer, turn_masks); } - } } } diff --git a/include/extractor/guidance/mergable_road_detector.hpp b/include/extractor/guidance/mergable_road_detector.hpp index ff4772032..a5c661c66 100644 --- a/include/extractor/guidance/mergable_road_detector.hpp +++ b/include/extractor/guidance/mergable_road_detector.hpp @@ -2,9 +2,9 @@ #define OSRM_EXTRACTOR_GUIDANCE_MERGEABLE_ROADS #include "extractor/guidance/intersection.hpp" +#include "util/coordinate.hpp" #include "util/node_based_graph.hpp" #include "util/typedefs.hpp" -#include "util/coordinate.hpp" #include #include diff --git a/include/extractor/segment_data_container.hpp b/include/extractor/segment_data_container.hpp index c6633a3a2..0d27202e2 100644 --- a/include/extractor/segment_data_container.hpp +++ b/include/extractor/segment_data_container.hpp @@ -1,8 +1,8 @@ #ifndef OSRM_EXTRACTOR_SEGMENT_DATA_CONTAINER_HPP_ #define OSRM_EXTRACTOR_SEGMENT_DATA_CONTAINER_HPP_ -#include "util/vector_view.hpp" #include "util/typedefs.hpp" +#include "util/vector_view.hpp" #include "storage/shared_memory_ownership.hpp" diff --git a/include/partition/cell_storage.hpp b/include/partition/cell_storage.hpp index c36e779ab..157434aec 100644 --- a/include/partition/cell_storage.hpp +++ b/include/partition/cell_storage.hpp @@ -6,8 +6,8 @@ #include "util/assert.hpp" #include "util/for_each_range.hpp" #include "util/log.hpp" -#include "util/vector_view.hpp" #include "util/typedefs.hpp" +#include "util/vector_view.hpp" #include "storage/io.hpp" #include "storage/shared_memory_ownership.hpp" diff --git a/include/partition/files.hpp b/include/partition/files.hpp index 7c0a25da8..0429dc1cc 100644 --- a/include/partition/files.hpp +++ b/include/partition/files.hpp @@ -35,8 +35,9 @@ inline void writeGraph(const boost::filesystem::path &path, } // read .osrm.partition file -template -inline void readPartition(const boost::filesystem::path &path, detail::MultiLevelPartitionImpl &mlp) +template +inline void readPartition(const boost::filesystem::path &path, + detail::MultiLevelPartitionImpl &mlp) { const auto fingerprint = storage::io::FileReader::VerifyFingerprint; storage::io::FileReader reader{path, fingerprint}; @@ -45,8 +46,9 @@ inline void readPartition(const boost::filesystem::path &path, detail::MultiLeve } // writes .osrm.partition file -template -inline void writePartition(const boost::filesystem::path &path, const detail::MultiLevelPartitionImpl &mlp) +template +inline void writePartition(const boost::filesystem::path &path, + const detail::MultiLevelPartitionImpl &mlp) { const auto fingerprint = storage::io::FileWriter::GenerateFingerprint; storage::io::FileWriter writer{path, fingerprint}; @@ -55,8 +57,9 @@ inline void writePartition(const boost::filesystem::path &path, const detail::Mu } // reads .osrm.cells file -template -inline void readCells(const boost::filesystem::path &path, detail::CellStorageImpl &storage) +template +inline void readCells(const boost::filesystem::path &path, + detail::CellStorageImpl &storage) { const auto fingerprint = storage::io::FileReader::VerifyFingerprint; storage::io::FileReader reader{path, fingerprint}; @@ -65,8 +68,9 @@ inline void readCells(const boost::filesystem::path &path, detail::CellStorageIm } // writes .osrm.cells file -template -inline void writeCells(const boost::filesystem::path &path, const detail::CellStorageImpl &storage) +template +inline void writeCells(const boost::filesystem::path &path, + const detail::CellStorageImpl &storage) { const auto fingerprint = storage::io::FileWriter::GenerateFingerprint; storage::io::FileWriter writer{path, fingerprint}; diff --git a/include/partition/multi_level_partition.hpp b/include/partition/multi_level_partition.hpp index 87e67b354..414fa312e 100644 --- a/include/partition/multi_level_partition.hpp +++ b/include/partition/multi_level_partition.hpp @@ -4,8 +4,8 @@ #include "util/exception.hpp" #include "util/for_each_pair.hpp" #include "util/msb.hpp" -#include "util/vector_view.hpp" #include "util/typedefs.hpp" +#include "util/vector_view.hpp" #include "storage/io.hpp" #include "storage/shared_memory_ownership.hpp" @@ -336,7 +336,8 @@ inline MultiLevelPartitionImpl::MultiLevelPartiti } template <> -inline MultiLevelPartitionImpl::MultiLevelPartitionImpl() : level_data(nullptr) +inline MultiLevelPartitionImpl::MultiLevelPartitionImpl() + : level_data(nullptr) { } } diff --git a/include/storage/serialization.hpp b/include/storage/serialization.hpp index 0a99cf084..fc06c7024 100644 --- a/include/storage/serialization.hpp +++ b/include/storage/serialization.hpp @@ -29,7 +29,7 @@ template void write(io::FileWriter &writer, const std::vector &d template void read(io::FileReader &reader, util::vector_view &data) { const auto count = reader.ReadElementCount64(); - data.resize(count); + BOOST_ASSERT(data.size() == count); reader.ReadInto(data.data(), count); } @@ -39,7 +39,6 @@ template void write(io::FileWriter &writer, const util::vector_view writer.WriteElementCount64(count); return writer.WriteFrom(data.data(), count); } - } } } diff --git a/include/util/deallocating_vector.hpp b/include/util/deallocating_vector.hpp index c3b24e125..17b805826 100644 --- a/include/util/deallocating_vector.hpp +++ b/include/util/deallocating_vector.hpp @@ -239,13 +239,17 @@ class DeallocatingVector bucket_list.emplace_back(new ElementT[ELEMENTS_PER_BLOCK]); } + // copying is not safe since this would only do a shallow copy + DeallocatingVector(DeallocatingVector &other) = delete; + DeallocatingVector &operator=(DeallocatingVector &other) = delete; + DeallocatingVector(DeallocatingVector &&other) { bucket_list = std::move(other.bucket_list); current_size = std::move(other.current_size); } - DeallocatingVector& operator=(DeallocatingVector &&other) + DeallocatingVector &operator=(DeallocatingVector &&other) { bucket_list = std::move(other.bucket_list); current_size = std::move(other.current_size); diff --git a/include/util/dynamic_graph.hpp b/include/util/dynamic_graph.hpp index c62bc1753..793bd25f0 100644 --- a/include/util/dynamic_graph.hpp +++ b/include/util/dynamic_graph.hpp @@ -36,8 +36,7 @@ template void read(storage::io::FileReader &reader, DynamicGraph &graph); template -void write(storage::io::FileWriter &writer, - const DynamicGraph &graph); +void write(storage::io::FileWriter &writer, const DynamicGraph &graph); } template class DynamicGraph diff --git a/include/util/graph_loader.hpp b/include/util/graph_loader.hpp index ac7d4e874..e413aadf8 100644 --- a/include/util/graph_loader.hpp +++ b/include/util/graph_loader.hpp @@ -9,8 +9,8 @@ #include "util/exception.hpp" #include "util/fingerprint.hpp" #include "util/log.hpp" -#include "util/typedefs.hpp" #include "util/packed_vector.hpp" +#include "util/typedefs.hpp" #include #include diff --git a/include/util/packed_vector.hpp b/include/util/packed_vector.hpp index 97ac685f8..c484bec92 100644 --- a/include/util/packed_vector.hpp +++ b/include/util/packed_vector.hpp @@ -1,8 +1,8 @@ #ifndef PACKED_VECTOR_HPP #define PACKED_VECTOR_HPP -#include "util/vector_view.hpp" #include "util/typedefs.hpp" +#include "util/vector_view.hpp" #include "storage/io.hpp" #include "storage/shared_memory_ownership.hpp" diff --git a/include/util/serialization.hpp b/include/util/serialization.hpp index bff5291fa..f0c084a2b 100644 --- a/include/util/serialization.hpp +++ b/include/util/serialization.hpp @@ -1,9 +1,9 @@ #ifndef OSMR_UTIL_SERIALIZATION_HPP #define OSMR_UTIL_SERIALIZATION_HPP +#include "util/dynamic_graph.hpp" #include "util/packed_vector.hpp" #include "util/static_graph.hpp" -#include "util/dynamic_graph.hpp" #include "storage/io.hpp" #include "storage/serialization.hpp" @@ -15,40 +15,35 @@ namespace util namespace serialization { template -inline void read(storage::io::FileReader &reader, - detail::PackedVector &vec) +inline void read(storage::io::FileReader &reader, detail::PackedVector &vec) { - vec.num_elements =reader.ReadOne(); + vec.num_elements = reader.ReadOne(); storage::serialization::read(reader, vec.vec); } template -inline void write(storage::io::FileWriter &writer, - const detail::PackedVector &vec) +inline void write(storage::io::FileWriter &writer, const detail::PackedVector &vec) { writer.WriteOne(vec.num_elements); storage::serialization::write(writer, vec.vec); } template -inline void read(storage::io::FileReader &reader, - StaticGraph &graph) +inline void read(storage::io::FileReader &reader, StaticGraph &graph) { storage::serialization::read(reader, graph.node_array); storage::serialization::read(reader, graph.edge_array); } template -inline void write(storage::io::FileWriter &writer, - const StaticGraph &graph) +inline void write(storage::io::FileWriter &writer, const StaticGraph &graph) { storage::serialization::write(writer, graph.node_array); storage::serialization::write(writer, graph.edge_array); } template -inline void read(storage::io::FileReader &reader, - DynamicGraph &graph) +inline void read(storage::io::FileReader &reader, DynamicGraph &graph) { storage::serialization::read(reader, graph.node_array); auto num_edges = reader.ReadElementCount64(); @@ -62,8 +57,7 @@ inline void read(storage::io::FileReader &reader, } template -inline void write(storage::io::FileWriter &writer, - const DynamicGraph &graph) +inline void write(storage::io::FileWriter &writer, const DynamicGraph &graph) { storage::serialization::write(writer, graph.node_array); writer.WriteElementCount64(graph.number_of_edges); @@ -72,7 +66,6 @@ inline void write(storage::io::FileWriter &writer, writer.WriteOne(graph.edge_list[index]); } } - } } } diff --git a/include/util/static_graph.hpp b/include/util/static_graph.hpp index 4ce3907bc..02dd649e2 100644 --- a/include/util/static_graph.hpp +++ b/include/util/static_graph.hpp @@ -4,8 +4,8 @@ #include "util/graph_traits.hpp" #include "util/integer_range.hpp" #include "util/percent.hpp" -#include "util/vector_view.hpp" #include "util/typedefs.hpp" +#include "util/vector_view.hpp" #include "storage/shared_memory_ownership.hpp" @@ -272,7 +272,9 @@ class StaticGraph unsigned offset = std::distance(begin, iter); node_array.push_back(NodeArrayEntry{offset}); } - BOOST_ASSERT_MSG(iter == end, ("Still " + std::to_string(std::distance(iter, end)) + " edges left.").c_str()); + BOOST_ASSERT_MSG( + iter == end, + ("Still " + std::to_string(std::distance(iter, end)) + " edges left.").c_str()); BOOST_ASSERT(node_array.size() == number_of_nodes + 1); edge_array.resize(number_of_edges); diff --git a/include/util/static_rtree.hpp b/include/util/static_rtree.hpp index 555f38024..5d69a7ed3 100644 --- a/include/util/static_rtree.hpp +++ b/include/util/static_rtree.hpp @@ -9,8 +9,8 @@ #include "util/hilbert_value.hpp" #include "util/integer_range.hpp" #include "util/rectangle.hpp" -#include "util/vector_view.hpp" #include "util/typedefs.hpp" +#include "util/vector_view.hpp" #include "util/web_mercator.hpp" #include "osrm/coordinate.hpp" diff --git a/include/util/vector_view.hpp b/include/util/vector_view.hpp index 452471fef..2480e9761 100644 --- a/include/util/vector_view.hpp +++ b/include/util/vector_view.hpp @@ -29,9 +29,10 @@ class VectorViewIterator : public boost::iterator_facade { - typedef boost:: - iterator_facade, DataT, boost::random_access_traversal_tag> - base_t; + typedef boost::iterator_facade, + DataT, + boost::random_access_traversal_tag> + base_t; public: typedef typename base_t::value_type value_type; @@ -85,17 +86,6 @@ template class vector_view m_size = size; } - // for a vector-like interface - void resize(std::size_t size) const - { - if (m_size != size) - { - throw util::exception("Invalid resize " + std::to_string(size) + - " on immutable vector view of size " + std::to_string(m_size) + - "."); - } - } - DataT &at(const std::size_t index) { return m_ptr[index]; } const DataT &at(const std::size_t index) const { return m_ptr[index]; } @@ -168,15 +158,6 @@ template <> class vector_view void reset(unsigned *, std::size_t size) { m_size = size; } - // for ensuring a vector compatible interface - void resize(std::size_t size) const - { - if (m_size != size) - { - throw util::exception("Invalid resize on immutable shared memory vector."); - } - } - std::size_t size() const { return m_size; } bool empty() const { return 0 == size(); } diff --git a/src/contractor/contractor.cpp b/src/contractor/contractor.cpp index d4069f938..3d9f41a86 100644 --- a/src/contractor/contractor.cpp +++ b/src/contractor/contractor.cpp @@ -48,7 +48,7 @@ int Contractor::Run() std::vector node_weights; { storage::io::FileReader reader(config.node_file_path, - storage::io::FileReader::VerifyFingerprint); + storage::io::FileReader::VerifyFingerprint); storage::serialization::read(reader, node_weights); } util::Log() << "Done reading node weights."; diff --git a/src/extractor/guidance/coordinate_extractor.cpp b/src/extractor/guidance/coordinate_extractor.cpp index 0a8a2069c..36c357b14 100644 --- a/src/extractor/guidance/coordinate_extractor.cpp +++ b/src/extractor/guidance/coordinate_extractor.cpp @@ -95,9 +95,7 @@ util::Coordinate CoordinateExtractor::ExtractRepresentativeCoordinate( { // check if the coordinate is equal to the interseciton coordinate const auto not_same_as_start = [&](const util::Coordinate coordinate) { - return node_coordinates[traversed_in_reverse - ? to_node - : intersection_node] != coordinate; + return node_coordinates[traversed_in_reverse ? to_node : intersection_node] != coordinate; }; // this is only used for debug purposes in assertions. We don't want warnings about it (void)not_same_as_start; diff --git a/src/extractor/guidance/intersection_normalizer.cpp b/src/extractor/guidance/intersection_normalizer.cpp index a54af3ebe..fffa32645 100644 --- a/src/extractor/guidance/intersection_normalizer.cpp +++ b/src/extractor/guidance/intersection_normalizer.cpp @@ -14,12 +14,11 @@ namespace extractor namespace guidance { -IntersectionNormalizer::IntersectionNormalizer( - const util::NodeBasedDynamicGraph &node_based_graph, - const std::vector &coordinates, - const util::NameTable &name_table, - const SuffixTable &street_name_suffix_table, - const IntersectionGenerator &intersection_generator) +IntersectionNormalizer::IntersectionNormalizer(const util::NodeBasedDynamicGraph &node_based_graph, + const std::vector &coordinates, + const util::NameTable &name_table, + const SuffixTable &street_name_suffix_table, + const IntersectionGenerator &intersection_generator) : node_based_graph(node_based_graph), intersection_generator(intersection_generator), mergable_road_detector(node_based_graph, coordinates, diff --git a/src/extractor/guidance/turn_analysis.cpp b/src/extractor/guidance/turn_analysis.cpp index 4857bd903..5c1ab843f 100644 --- a/src/extractor/guidance/turn_analysis.cpp +++ b/src/extractor/guidance/turn_analysis.cpp @@ -34,11 +34,9 @@ TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph, const util::NameTable &name_table, const SuffixTable &street_name_suffix_table, const ProfileProperties &profile_properties) - : node_based_graph(node_based_graph), intersection_generator(node_based_graph, - restriction_map, - barrier_nodes, - coordinates, - compressed_edge_container), + : node_based_graph(node_based_graph), + intersection_generator( + node_based_graph, restriction_map, barrier_nodes, coordinates, compressed_edge_container), intersection_normalizer(node_based_graph, coordinates, name_table, diff --git a/src/tools/components.cpp b/src/tools/components.cpp index 445c23e84..d6cc239aa 100644 --- a/src/tools/components.cpp +++ b/src/tools/components.cpp @@ -42,7 +42,8 @@ std::size_t loadGraph(const std::string &path, auto nop = boost::make_function_output_iterator([](auto) {}); - const auto number_of_nodes = util::loadNodesFromFile(file_reader, nop, nop, coordinate_list, osm_node_ids); + const auto number_of_nodes = + util::loadNodesFromFile(file_reader, nop, nop, coordinate_list, osm_node_ids); util::loadEdgesFromFile(file_reader, edge_list); @@ -75,10 +76,11 @@ struct FeatureWriter out << "{\"type\":\"FeatureCollection\",\"features\":["; } - void - AddLine(const util::Coordinate from, const util::Coordinate to, - const OSMNodeID from_id, const OSMNodeID to_id, - const std::string &type) + void AddLine(const util::Coordinate from, + const util::Coordinate to, + const OSMNodeID from_id, + const OSMNodeID to_id, + const std::string &type) { const auto from_lon = static_cast(util::toFloating(from.lon)); const auto from_lat = static_cast(util::toFloating(from.lat)); @@ -189,7 +191,11 @@ int main(int argc, char *argv[]) auto same_component = source_component_id == target_component_id; std::string type = same_component ? "inner" : "border"; - writer.AddLine(coordinate_list[source], coordinate_list[target], osm_node_ids[source], osm_node_ids[target], type); + writer.AddLine(coordinate_list[source], + coordinate_list[target], + osm_node_ids[source], + osm_node_ids[target], + type); } } }