Fix clang format

This commit is contained in:
Patrick Niklaus 2017-08-14 21:24:33 +00:00 committed by Patrick Niklaus
parent bd6492bb38
commit 6339395cba
21 changed files with 98 additions and 85 deletions

View File

@ -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 <storage::Ownership Ownership> struct CellMetricImpl
using CellMetric = detail::CellMetricImpl<storage::Ownership::Container>;
using CellMetricView = detail::CellMetricImpl<storage::Ownership::View>;
}
}

View File

@ -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)

View File

@ -28,7 +28,7 @@ inline void readCellMetrics(const boost::filesystem::path &path, std::vector<Cel
auto num_metrics = reader.ReadElementCount64();
metrics.resize(num_metrics);
for (auto& metric : metrics)
for (auto &metric : metrics)
{
serialization::read(reader, metric);
}
@ -36,7 +36,8 @@ inline void readCellMetrics(const boost::filesystem::path &path, std::vector<Cel
// writes .osrm.cell_metrics file
template <typename CellMetricT>
inline void writeCellMetrics(const boost::filesystem::path &path, const std::vector<CellMetricT> &metrics)
inline void writeCellMetrics(const boost::filesystem::path &path,
const std::vector<CellMetricT> &metrics)
{
static_assert(std::is_same<CellMetricView, CellMetricT>::value ||
std::is_same<CellMetric, CellMetricT>::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);
}
}
}
}
}

View File

@ -88,10 +88,16 @@ struct RouteParameters : public BaseParameters
const OverviewType overview_,
const boost::optional<bool> continue_straight_,
Args... args_)
// Once we perfectly-forward `args` (see #2990) this constructor can delegate to the one below.
: BaseParameters{std::forward<Args>(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>(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_}
{
}

View File

@ -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 <typename AlgorithmT, typename FacadeT> class DataWatchdogImpl;
template <typename AlgorithmT> class DataWatchdogImpl<AlgorithmT, datafacade::ContiguousInternalMemoryDataFacade<AlgorithmT>> final
template <typename AlgorithmT>
class DataWatchdogImpl<AlgorithmT, datafacade::ContiguousInternalMemoryDataFacade<AlgorithmT>> final
{
using mutex_type = typename storage::SharedMonitor<storage::SharedDataTimestamp>::mutex_type;
using Facade = datafacade::ContiguousInternalMemoryDataFacade<AlgorithmT>;
@ -42,7 +42,8 @@ template <typename AlgorithmT> class DataWatchdogImpl<AlgorithmT, datafacade::Co
{
boost::interprocess::scoped_lock<mutex_type> current_region_lock(barrier.get_mutex());
facade_factory = DataFacadeFactory<datafacade::ContiguousInternalMemoryDataFacade, AlgorithmT>(
facade_factory =
DataFacadeFactory<datafacade::ContiguousInternalMemoryDataFacade, AlgorithmT>(
std::make_shared<datafacade::SharedMemoryAllocator>(barrier.data().region));
timestamp = barrier.data().timestamp;
}
@ -57,8 +58,14 @@ template <typename AlgorithmT> class DataWatchdogImpl<AlgorithmT, datafacade::Co
watcher.join();
}
std::shared_ptr<const Facade> Get(const api::BaseParameters &params) const { return facade_factory.Get(params); }
std::shared_ptr<const Facade> Get(const api::TileParameters &params) const { return facade_factory.Get(params); }
std::shared_ptr<const Facade> Get(const api::BaseParameters &params) const
{
return facade_factory.Get(params);
}
std::shared_ptr<const Facade> Get(const api::TileParameters &params) const
{
return facade_factory.Get(params);
}
private:
void Run()
@ -75,7 +82,8 @@ template <typename AlgorithmT> class DataWatchdogImpl<AlgorithmT, datafacade::Co
if (timestamp != barrier.data().timestamp)
{
auto region = barrier.data().region;
facade_factory = DataFacadeFactory<datafacade::ContiguousInternalMemoryDataFacade, AlgorithmT>(
facade_factory =
DataFacadeFactory<datafacade::ContiguousInternalMemoryDataFacade, AlgorithmT>(
std::make_shared<datafacade::SharedMemoryAllocator>(region));
timestamp = barrier.data().timestamp;
util::Log() << "updated facade to region " << region << " with timestamp "
@ -97,8 +105,8 @@ template <typename AlgorithmT> class DataWatchdogImpl<AlgorithmT, datafacade::Co
// This class monitors the shared memory region that contains the pointers to
// the data and layout regions that should be used. This region is updated
// once a new dataset arrives.
template <typename AlgorithmT, template<typename A> class FacadeT> using DataWatchdog = detail::DataWatchdogImpl<AlgorithmT, FacadeT<AlgorithmT>>;
template <typename AlgorithmT, template <typename A> class FacadeT>
using DataWatchdog = detail::DataWatchdogImpl<AlgorithmT, FacadeT<AlgorithmT>>;
}
}

View File

@ -11,7 +11,6 @@ namespace engine
using DataFacadeBase = datafacade::ContiguousInternalMemoryDataFacadeBase;
template <typename AlgorithmT>
using DataFacade = datafacade::ContiguousInternalMemoryDataFacade<AlgorithmT>;
}
}

View File

@ -247,7 +247,9 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
// allocator that keeps the allocation data
std::shared_ptr<ContiguousBlockAllocator> 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<extractor::ProfileProperties>(
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<ContiguousBlockAllocator> allocator_, const std::size_t avoid_index)
ContiguousInternalMemoryDataFacadeBase(std::shared_ptr<ContiguousBlockAllocator> 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 <typename AlgorithmT> class ContiguousInternalMemoryDataFacade;
@ -1028,7 +1032,7 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
util::vector_view<EdgeDuration> 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)

View File

@ -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 <typename AlgorithmT, template <typename A> class FacadeT> class DataFa
virtual ~DataFacadeProvider() = default;
virtual std::shared_ptr<const Facade> Get(const api::BaseParameters&) const = 0;
virtual std::shared_ptr<const Facade> Get(const api::TileParameters&) const = 0;
virtual std::shared_ptr<const Facade> Get(const api::BaseParameters &) const = 0;
virtual std::shared_ptr<const Facade> Get(const api::TileParameters &) const = 0;
};
template <typename AlgorithmT, template <typename A> class FacadeT>
@ -36,8 +36,14 @@ class ImmutableProvider final : public DataFacadeProvider<AlgorithmT, FacadeT>
{
}
std::shared_ptr<const Facade> Get(const api::TileParameters &params) const override final { return facade_factory.Get(params); }
std::shared_ptr<const Facade> Get(const api::BaseParameters &params) const override final { return facade_factory.Get(params); }
std::shared_ptr<const Facade> Get(const api::TileParameters &params) const override final
{
return facade_factory.Get(params);
}
std::shared_ptr<const Facade> Get(const api::BaseParameters &params) const override final
{
return facade_factory.Get(params);
}
private:
DataFacadeFactory<FacadeT, AlgorithmT> facade_factory;
@ -51,8 +57,14 @@ class WatchingProvider : public DataFacadeProvider<AlgorithmT, FacadeT>
public:
using Facade = typename DataFacadeProvider<AlgorithmT, FacadeT>::Facade;
std::shared_ptr<const Facade> Get(const api::TileParameters &params) const override final { return watchdog.Get(params); }
std::shared_ptr<const Facade> Get(const api::BaseParameters &params) const override final { return watchdog.Get(params); }
std::shared_ptr<const Facade> Get(const api::TileParameters &params) const override final
{
return watchdog.Get(params);
}
std::shared_ptr<const Facade> Get(const api::BaseParameters &params) const override final
{
return watchdog.Get(params);
}
};
}

View File

@ -119,8 +119,7 @@ template <typename Algorithm> class Engine final : public EngineInterface
static bool CheckCompability(const EngineConfig &config);
private:
template<typename ParametersT>
auto GetAlgorithms(const ParametersT &params) const
template <typename ParametersT> auto GetAlgorithms(const ParametersT &params) const
{
return RoutingAlgorithms<Algorithm>{heaps, facade_provider->Get(params)};
}

View File

@ -37,7 +37,9 @@ class BasePlugin
});
}
bool CheckAlgorithms(const api::BaseParameters &params, const RoutingAlgorithmsInterface& algorithms, util::json::Object &result) const
bool CheckAlgorithms(const api::BaseParameters &params,
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;
}

View File

@ -134,10 +134,7 @@ template <typename Algorithm> class RoutingAlgorithms final : public RoutingAlgo
return routing_algorithms::HasAvoidFlags<Algorithm>::value;
}
bool IsValid() const final override
{
return static_cast<bool>(facade);
}
bool IsValid() const final override { return static_cast<bool>(facade); }
private:
SearchEngineData<Algorithm> &heaps;

View File

@ -6,8 +6,8 @@
#include "util/typedefs.hpp"
#include <boost/assert.hpp>
#include <boost/optional.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/optional.hpp>
#include <algorithm>
#include <cstdint>

View File

@ -91,8 +91,9 @@ template <storage::Ownership Ownership> class CellStorageImpl
WeightValueT,
boost::random_access_traversal_tag>
{
typedef boost::
iterator_facade<ColumnIterator, WeightValueT, boost::random_access_traversal_tag>
typedef boost::iterator_facade<ColumnIterator,
WeightValueT,
boost::random_access_traversal_tag>
base_t;
public:
@ -178,8 +179,8 @@ template <storage::Ownership Ownership> 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}
{

View File

@ -43,10 +43,10 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
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<typename SuperT::NodeArrayEntry> node_array_,
Vector<typename SuperT::EdgeArrayEntry> edge_array_,

View File

@ -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);
}
}
}
}

View File

@ -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

View File

@ -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<std::string>() + "]");
throw util::exception("Expected a sub-table at " + table_name + "[" +
pair.first.as<std::string>() + "]");
}
std::vector<std::string> inner_vector;

View File

@ -291,30 +291,9 @@ BOOST_AUTO_TEST_CASE(avoid_test)
// 2 ----3 --- 4 --- 7
// \__________/
std::vector<MockEdge> 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);

View File

@ -104,7 +104,6 @@ struct ExternalCellStorage
ConstCell GetCell(ExternalCellMetric, LevelID /*level*/, CellID /*id*/) const { return Cell{}; }
};
// Define external data facade
template <>
class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm> final

View File

@ -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
{

View File

@ -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);