From 6339395cba08c17321d9d4fd98be8923f68324af Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Mon, 14 Aug 2017 21:24:33 +0000 Subject: [PATCH] Fix clang format --- include/customizer/cell_metric.hpp | 3 +- include/customizer/customizer_config.hpp | 6 +++- include/customizer/files.hpp | 8 ++--- include/engine/api/route_parameters.hpp | 14 +++++--- include/engine/data_watchdog.hpp | 28 ++++++++++------ include/engine/datafacade.hpp | 1 - .../contiguous_internalmem_datafacade.hpp | 14 +++++--- include/engine/datafacade_provider.hpp | 26 +++++++++++---- include/engine/engine.hpp | 3 +- include/engine/plugins/plugin_base.hpp | 7 ++-- include/engine/routing_algorithms.hpp | 5 +-- include/extractor/profile_properties.hpp | 2 +- include/partition/cell_storage.hpp | 13 ++++---- include/partition/multi_level_graph.hpp | 8 ++--- include/partition/serialization.hpp | 1 - src/extractor/extractor.cpp | 3 +- src/extractor/scripting_environment_lua.cpp | 3 +- unit_tests/customizer/cell_customization.cpp | 33 ++++--------------- unit_tests/engine/offline_facade.cpp | 1 - unit_tests/mocks/mock_datafacade.hpp | 2 +- unit_tests/partition/cell_storage.cpp | 2 +- 21 files changed, 98 insertions(+), 85 deletions(-) diff --git a/include/customizer/cell_metric.hpp b/include/customizer/cell_metric.hpp index 6afdefa6a..530a18559 100644 --- a/include/customizer/cell_metric.hpp +++ b/include/customizer/cell_metric.hpp @@ -4,8 +4,8 @@ #include "storage/io_fwd.hpp" #include "storage/shared_memory_ownership.hpp" -#include "util/vector_view.hpp" #include "util/typedefs.hpp" +#include "util/vector_view.hpp" namespace osrm { @@ -25,7 +25,6 @@ template struct CellMetricImpl using CellMetric = detail::CellMetricImpl; using CellMetricView = detail::CellMetricImpl; - } } diff --git a/include/customizer/customizer_config.hpp b/include/customizer/customizer_config.hpp index 447ea76e9..f889dc2e6 100644 --- a/include/customizer/customizer_config.hpp +++ b/include/customizer/customizer_config.hpp @@ -17,7 +17,11 @@ namespace customizer struct CustomizationConfig final : storage::IOConfig { CustomizationConfig() - : IOConfig({".osrm.ebg", ".osrm.partition", ".osrm.cells", ".osrm.ebg_nodes", ".osrm.properties"}, + : IOConfig({".osrm.ebg", + ".osrm.partition", + ".osrm.cells", + ".osrm.ebg_nodes", + ".osrm.properties"}, {}, {".osrm.cell_metrics", ".osrm.mldgr"}), requested_num_threads(0) diff --git a/include/customizer/files.hpp b/include/customizer/files.hpp index 91dd3552b..c5cc28c25 100644 --- a/include/customizer/files.hpp +++ b/include/customizer/files.hpp @@ -28,7 +28,7 @@ inline void readCellMetrics(const boost::filesystem::path &path, std::vector -inline void writeCellMetrics(const boost::filesystem::path &path, const std::vector &metrics) +inline void writeCellMetrics(const boost::filesystem::path &path, + const std::vector &metrics) { static_assert(std::is_same::value || std::is_same::value, @@ -46,12 +47,11 @@ inline void writeCellMetrics(const boost::filesystem::path &path, const std::vec storage::io::FileWriter writer{path, fingerprint}; writer.WriteElementCount64(metrics.size()); - for (const auto& metric : metrics) + for (const auto &metric : metrics) { serialization::write(writer, metric); } } - } } } diff --git a/include/engine/api/route_parameters.hpp b/include/engine/api/route_parameters.hpp index ae07a2280..115a557af 100644 --- a/include/engine/api/route_parameters.hpp +++ b/include/engine/api/route_parameters.hpp @@ -88,10 +88,16 @@ struct RouteParameters : public BaseParameters const OverviewType overview_, const boost::optional continue_straight_, Args... args_) - // Once we perfectly-forward `args` (see #2990) this constructor can delegate to the one below. - : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, - number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{false}, - annotations_type{AnnotationsType::None}, geometries{geometries_}, overview{overview_}, + // Once we perfectly-forward `args` (see #2990) this constructor can delegate to the one + // below. + : BaseParameters{std::forward(args_)...}, + steps{steps_}, + alternatives{alternatives_}, + number_of_alternatives{alternatives_ ? 1u : 0u}, + annotations{false}, + annotations_type{AnnotationsType::None}, + geometries{geometries_}, + overview{overview_}, continue_straight{continue_straight_} { } diff --git a/include/engine/data_watchdog.hpp b/include/engine/data_watchdog.hpp index d37910ae2..91349eb2a 100644 --- a/include/engine/data_watchdog.hpp +++ b/include/engine/data_watchdog.hpp @@ -22,7 +22,6 @@ namespace osrm namespace engine { - namespace detail { // We need this wrapper type since template-template specilization of FacadeT is broken on clang @@ -30,7 +29,8 @@ namespace detail // See https://godbolt.org/g/ZS6Xmt for an example. template class DataWatchdogImpl; -template class DataWatchdogImpl> final +template +class DataWatchdogImpl> final { using mutex_type = typename storage::SharedMonitor::mutex_type; using Facade = datafacade::ContiguousInternalMemoryDataFacade; @@ -42,8 +42,9 @@ template class DataWatchdogImpl current_region_lock(barrier.get_mutex()); - facade_factory = DataFacadeFactory( - std::make_shared(barrier.data().region)); + facade_factory = + DataFacadeFactory( + std::make_shared(barrier.data().region)); timestamp = barrier.data().timestamp; } @@ -57,8 +58,14 @@ template class DataWatchdogImpl Get(const api::BaseParameters ¶ms) const { return facade_factory.Get(params); } - std::shared_ptr Get(const api::TileParameters ¶ms) const { return facade_factory.Get(params); } + std::shared_ptr Get(const api::BaseParameters ¶ms) const + { + return facade_factory.Get(params); + } + std::shared_ptr Get(const api::TileParameters ¶ms) const + { + return facade_factory.Get(params); + } private: void Run() @@ -75,8 +82,9 @@ template class DataWatchdogImpl( - std::make_shared(region)); + facade_factory = + DataFacadeFactory( + std::make_shared(region)); timestamp = barrier.data().timestamp; util::Log() << "updated facade to region " << region << " with timestamp " << timestamp; @@ -97,8 +105,8 @@ template class DataWatchdogImpl class FacadeT> using DataWatchdog = detail::DataWatchdogImpl>; - +template class FacadeT> +using DataWatchdog = detail::DataWatchdogImpl>; } } diff --git a/include/engine/datafacade.hpp b/include/engine/datafacade.hpp index 0d2baeea5..76068a472 100644 --- a/include/engine/datafacade.hpp +++ b/include/engine/datafacade.hpp @@ -11,7 +11,6 @@ namespace engine using DataFacadeBase = datafacade::ContiguousInternalMemoryDataFacadeBase; template using DataFacade = datafacade::ContiguousInternalMemoryDataFacade; - } } diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index adc72ff33..e4fb05ed7 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -247,7 +247,9 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade // allocator that keeps the allocation data std::shared_ptr allocator; - void InitializeProfilePropertiesPointer(storage::DataLayout &data_layout, char *memory_block, const std::size_t avoid_index) + void InitializeProfilePropertiesPointer(storage::DataLayout &data_layout, + char *memory_block, + const std::size_t avoid_index) { m_profile_properties = data_layout.GetBlockPtr( memory_block, storage::DataLayout::PROPERTIES); @@ -542,7 +544,9 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade m_entry_class_table = std::move(entry_class_table); } - void InitializeInternalPointers(storage::DataLayout &data_layout, char *memory_block, const std::size_t avoid_index) + void InitializeInternalPointers(storage::DataLayout &data_layout, + char *memory_block, + const std::size_t avoid_index) { InitializeChecksumPointer(data_layout, memory_block); InitializeNodeInformationPointers(data_layout, memory_block); @@ -561,7 +565,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade public: // allows switching between process_memory/shared_memory datafacade, based on the type of // allocator - ContiguousInternalMemoryDataFacadeBase(std::shared_ptr allocator_, const std::size_t avoid_index) + ContiguousInternalMemoryDataFacadeBase(std::shared_ptr allocator_, + const std::size_t avoid_index) : allocator(std::move(allocator_)) { InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), avoid_index); @@ -924,7 +929,6 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade { return m_profile_properties->left_hand_driving; } - }; template class ContiguousInternalMemoryDataFacade; @@ -1028,7 +1032,7 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade : public Algo util::vector_view durations(mld_cell_durations_ptr, duration_entries_count); - mld_cell_metric = customizer::CellMetricView {std::move(weights), std::move(durations)}; + mld_cell_metric = customizer::CellMetricView{std::move(weights), std::move(durations)}; } if (data_layout.GetBlockSize(storage::DataLayout::MLD_CELLS) > 0) diff --git a/include/engine/datafacade_provider.hpp b/include/engine/datafacade_provider.hpp index 4a0257d41..99e5fad58 100644 --- a/include/engine/datafacade_provider.hpp +++ b/include/engine/datafacade_provider.hpp @@ -1,11 +1,11 @@ #ifndef OSRM_ENGINE_DATAFACADE_PROVIDER_HPP #define OSRM_ENGINE_DATAFACADE_PROVIDER_HPP -#include "engine/datafacade_factory.hpp" #include "engine/data_watchdog.hpp" #include "engine/datafacade.hpp" #include "engine/datafacade/contiguous_internalmem_datafacade.hpp" #include "engine/datafacade/process_memory_allocator.hpp" +#include "engine/datafacade_factory.hpp" namespace osrm { @@ -21,8 +21,8 @@ template class FacadeT> class DataFa virtual ~DataFacadeProvider() = default; - virtual std::shared_ptr Get(const api::BaseParameters&) const = 0; - virtual std::shared_ptr Get(const api::TileParameters&) const = 0; + virtual std::shared_ptr Get(const api::BaseParameters &) const = 0; + virtual std::shared_ptr Get(const api::TileParameters &) const = 0; }; template class FacadeT> @@ -36,8 +36,14 @@ class ImmutableProvider final : public DataFacadeProvider { } - std::shared_ptr Get(const api::TileParameters ¶ms) const override final { return facade_factory.Get(params); } - std::shared_ptr Get(const api::BaseParameters ¶ms) const override final { return facade_factory.Get(params); } + std::shared_ptr Get(const api::TileParameters ¶ms) const override final + { + return facade_factory.Get(params); + } + std::shared_ptr Get(const api::BaseParameters ¶ms) const override final + { + return facade_factory.Get(params); + } private: DataFacadeFactory facade_factory; @@ -51,8 +57,14 @@ class WatchingProvider : public DataFacadeProvider public: using Facade = typename DataFacadeProvider::Facade; - std::shared_ptr Get(const api::TileParameters ¶ms) const override final { return watchdog.Get(params); } - std::shared_ptr Get(const api::BaseParameters ¶ms) const override final { return watchdog.Get(params); } + std::shared_ptr Get(const api::TileParameters ¶ms) const override final + { + return watchdog.Get(params); + } + std::shared_ptr Get(const api::BaseParameters ¶ms) const override final + { + return watchdog.Get(params); + } }; } diff --git a/include/engine/engine.hpp b/include/engine/engine.hpp index e9a130769..2031e4e89 100644 --- a/include/engine/engine.hpp +++ b/include/engine/engine.hpp @@ -119,8 +119,7 @@ template class Engine final : public EngineInterface static bool CheckCompability(const EngineConfig &config); private: - template - auto GetAlgorithms(const ParametersT ¶ms) const + template auto GetAlgorithms(const ParametersT ¶ms) const { return RoutingAlgorithms{heaps, facade_provider->Get(params)}; } diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index a90a2e08c..e9d754794 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -37,7 +37,9 @@ class BasePlugin }); } - bool CheckAlgorithms(const api::BaseParameters ¶ms, const RoutingAlgorithmsInterface& algorithms, util::json::Object &result) const + bool CheckAlgorithms(const api::BaseParameters ¶ms, + const RoutingAlgorithmsInterface &algorithms, + util::json::Object &result) const { if (algorithms.IsValid()) { @@ -55,7 +57,8 @@ class BasePlugin return false; } - BOOST_ASSERT_MSG(false, "There are only two reasons why the algorithm interface can be invalid."); + BOOST_ASSERT_MSG(false, + "There are only two reasons why the algorithm interface can be invalid."); return false; } diff --git a/include/engine/routing_algorithms.hpp b/include/engine/routing_algorithms.hpp index b09b5d298..923ab3205 100644 --- a/include/engine/routing_algorithms.hpp +++ b/include/engine/routing_algorithms.hpp @@ -134,10 +134,7 @@ template class RoutingAlgorithms final : public RoutingAlgo return routing_algorithms::HasAvoidFlags::value; } - bool IsValid() const final override - { - return static_cast(facade); - } + bool IsValid() const final override { return static_cast(facade); } private: SearchEngineData &heaps; diff --git a/include/extractor/profile_properties.hpp b/include/extractor/profile_properties.hpp index c7a3d12c8..393cda8fb 100644 --- a/include/extractor/profile_properties.hpp +++ b/include/extractor/profile_properties.hpp @@ -6,8 +6,8 @@ #include "util/typedefs.hpp" #include -#include #include +#include #include #include diff --git a/include/partition/cell_storage.hpp b/include/partition/cell_storage.hpp index fe3516cd0..529a0353b 100644 --- a/include/partition/cell_storage.hpp +++ b/include/partition/cell_storage.hpp @@ -91,9 +91,10 @@ template class CellStorageImpl WeightValueT, boost::random_access_traversal_tag> { - typedef boost:: - iterator_facade - base_t; + typedef boost::iterator_facade + base_t; public: typedef typename base_t::value_type value_type; @@ -178,8 +179,8 @@ template class CellStorageImpl const NodeID *const all_destinations) : num_source_nodes{data.num_source_nodes}, num_destination_nodes{data.num_destination_nodes}, - weights{all_weights + data.value_offset}, durations{all_durations + - data.value_offset}, + weights{all_weights + data.value_offset}, + durations{all_durations + data.value_offset}, source_boundary{all_sources + data.source_boundary_offset}, destination_boundary{all_destinations + data.destination_boundary_offset} { @@ -338,7 +339,7 @@ template class CellStorageImpl const auto &last_cell = cells.back(); ValueOffset total_size = cells.back().value_offset + - last_cell.num_source_nodes * last_cell.num_destination_nodes; + last_cell.num_source_nodes * last_cell.num_destination_nodes; metric.weights.resize(total_size + 1, INVALID_EDGE_WEIGHT); metric.durations.resize(total_size + 1, MAXIMAL_EDGE_DURATION); diff --git a/include/partition/multi_level_graph.hpp b/include/partition/multi_level_graph.hpp index 135d6c9e5..c0aa2393b 100644 --- a/include/partition/multi_level_graph.hpp +++ b/include/partition/multi_level_graph.hpp @@ -43,10 +43,10 @@ class MultiLevelGraph : public util::StaticGraph using EdgeOffset = std::uint8_t; MultiLevelGraph() = default; - MultiLevelGraph(MultiLevelGraph&&) = default; - MultiLevelGraph(const MultiLevelGraph&) = default; - MultiLevelGraph& operator=(MultiLevelGraph&&) = default; - MultiLevelGraph& operator=(const MultiLevelGraph&) = default; + MultiLevelGraph(MultiLevelGraph &&) = default; + MultiLevelGraph(const MultiLevelGraph &) = default; + MultiLevelGraph &operator=(MultiLevelGraph &&) = default; + MultiLevelGraph &operator=(const MultiLevelGraph &) = default; MultiLevelGraph(Vector node_array_, Vector edge_array_, diff --git a/include/partition/serialization.hpp b/include/partition/serialization.hpp index 3b29c274d..1c84557d9 100644 --- a/include/partition/serialization.hpp +++ b/include/partition/serialization.hpp @@ -69,7 +69,6 @@ inline void write(storage::io::FileWriter &writer, storage::serialization::write(writer, storage.cells); storage::serialization::write(writer, storage.level_to_cell_offset); } - } } } diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index e6c29af17..952b56649 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -86,7 +86,8 @@ void SetAvoidableClasses(const ExtractorCallbacks::ClassesMap &classes_map, { if (avoidable_classes.size() > MAX_AVOIDABLE_CLASSES) { - throw util::exception("Only " + std::to_string(MAX_AVOIDABLE_CLASSES) + " avoidable combinations allowed."); + throw util::exception("Only " + std::to_string(MAX_AVOIDABLE_CLASSES) + + " avoidable combinations allowed."); } // The avoid index 0 is reserve for not avoiding anything diff --git a/src/extractor/scripting_environment_lua.cpp b/src/extractor/scripting_environment_lua.cpp index 8b71af05c..cdcc3bf58 100644 --- a/src/extractor/scripting_environment_lua.cpp +++ b/src/extractor/scripting_environment_lua.cpp @@ -712,7 +712,8 @@ Sol2ScriptingEnvironment::GetStringListsFromTable(const std::string &table_name) sol::table inner_table = pair.second; if (!inner_table.valid()) { - throw util::exception("Expected a sub-table at " + table_name + "[" + pair.first.as() + "]"); + throw util::exception("Expected a sub-table at " + table_name + "[" + + pair.first.as() + "]"); } std::vector inner_vector; diff --git a/unit_tests/customizer/cell_customization.cpp b/unit_tests/customizer/cell_customization.cpp index 2cc8fbdde..f9be3453c 100644 --- a/unit_tests/customizer/cell_customization.cpp +++ b/unit_tests/customizer/cell_customization.cpp @@ -291,30 +291,9 @@ BOOST_AUTO_TEST_CASE(avoid_test) // 2 ----3 --- 4 --- 7 // \__________/ std::vector edges = { - {0, 1, 1}, - {0, 2, 1}, - {1, 0, 1}, - {1, 2, 10}, - {1, 3, 1}, - {1, 5, 1}, - {2, 0, 1}, - {2, 1, 10}, - {2, 3, 1}, - {2, 4, 1}, - {3, 1, 1}, - {3, 2, 1}, - {3, 4, 1}, - {4, 2, 1}, - {4, 3, 1}, - {4, 5, 1}, - {4, 7, 1}, - {5, 1, 1}, - {5, 4, 1}, - {5, 6, 1}, - {6, 5, 1}, - {6, 7, 1}, - {7, 4, 1}, - {7, 6, 1}, + {0, 1, 1}, {0, 2, 1}, {1, 0, 1}, {1, 2, 10}, {1, 3, 1}, {1, 5, 1}, {2, 0, 1}, {2, 1, 10}, + {2, 3, 1}, {2, 4, 1}, {3, 1, 1}, {3, 2, 1}, {3, 4, 1}, {4, 2, 1}, {4, 3, 1}, {4, 5, 1}, + {4, 7, 1}, {5, 1, 1}, {5, 4, 1}, {5, 6, 1}, {6, 5, 1}, {6, 7, 1}, {7, 4, 1}, {7, 6, 1}, }; // node: 0 1 2 3 4 5 6 7 @@ -417,10 +396,12 @@ BOOST_AUTO_TEST_CASE(avoid_test) CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(1), 0, 10, INVALID_EDGE_WEIGHT); CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(2), 10, 0, INVALID_EDGE_WEIGHT); - CHECK_EQUAL_RANGE(cell_2_0.GetOutWeight(3), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT); + CHECK_EQUAL_RANGE( + cell_2_0.GetOutWeight(3), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT); CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(1), 0, 10, INVALID_EDGE_WEIGHT); CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(2), 10, 0, INVALID_EDGE_WEIGHT); - CHECK_EQUAL_RANGE(cell_2_0.GetInWeight(3), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT); + CHECK_EQUAL_RANGE( + cell_2_0.GetInWeight(3), INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT, INVALID_EDGE_WEIGHT); CHECK_EQUAL_RANGE(cell_2_1.GetOutWeight(4), 0, 1); CHECK_EQUAL_RANGE(cell_2_1.GetOutWeight(5), 1, 0); diff --git a/unit_tests/engine/offline_facade.cpp b/unit_tests/engine/offline_facade.cpp index eaf149188..dfadab0da 100644 --- a/unit_tests/engine/offline_facade.cpp +++ b/unit_tests/engine/offline_facade.cpp @@ -104,7 +104,6 @@ struct ExternalCellStorage ConstCell GetCell(ExternalCellMetric, LevelID /*level*/, CellID /*id*/) const { return Cell{}; } }; - // Define external data facade template <> class ContiguousInternalMemoryDataFacade final diff --git a/unit_tests/mocks/mock_datafacade.hpp b/unit_tests/mocks/mock_datafacade.hpp index 59a11105c..ee9b8ea6f 100644 --- a/unit_tests/mocks/mock_datafacade.hpp +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -28,7 +28,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade using StringView = util::StringView; public: - bool AvoidNode(const NodeID ) const override { return false; }; + bool AvoidNode(const NodeID) const override { return false; }; util::Coordinate GetCoordinateOfNode(const NodeID /* id */) const override { diff --git a/unit_tests/partition/cell_storage.cpp b/unit_tests/partition/cell_storage.cpp index 53efadf85..b4a1074e5 100644 --- a/unit_tests/partition/cell_storage.cpp +++ b/unit_tests/partition/cell_storage.cpp @@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(immutable_cell_storage) // test const storage const CellStorage const_storage(mlp, graph); - const auto metric =const_storage.MakeMetric(); + const auto metric = const_storage.MakeMetric(); auto const_cell_1_0 = const_storage.GetCell(metric, 1, 0); auto const_cell_1_1 = const_storage.GetCell(metric, 1, 1);