clang-format

This commit is contained in:
Pepijn Schoen 2017-04-03 10:28:46 +02:00 committed by Patrick Niklaus
parent 16665aeb00
commit 091a495632
15 changed files with 55 additions and 90 deletions

View File

@ -19,20 +19,17 @@ namespace customizer
using EdgeBasedGraphEdgeData = partition::EdgeBasedGraphEdgeData; using EdgeBasedGraphEdgeData = partition::EdgeBasedGraphEdgeData;
struct MultiLevelEdgeBasedGraph struct MultiLevelEdgeBasedGraph
: public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, : public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::Container>
osrm::storage::Ownership::Container>
{ {
using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, using Base =
osrm::storage::Ownership::Container>; partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::Container>;
using Base::Base; using Base::Base;
}; };
struct MultiLevelEdgeBasedGraphView struct MultiLevelEdgeBasedGraphView
: public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, : public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::View>
osrm::storage::Ownership::View>
{ {
using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::View>;
osrm::storage::Ownership::View>;
using Base::Base; using Base::Base;
}; };

View File

@ -251,8 +251,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
util::vector_view<util::guidance::EntryClass> m_entry_class_table; util::vector_view<util::guidance::EntryClass> m_entry_class_table;
// the look-up table for distinct bearing classes. A bearing class lists the available bearings // the look-up table for distinct bearing classes. A bearing class lists the available bearings
// at an intersection // at an intersection
std::shared_ptr<util::RangeTable<16, osrm::storage::Ownership::View>> std::shared_ptr<util::RangeTable<16, osrm::storage::Ownership::View>> m_bearing_ranges_table;
m_bearing_ranges_table;
util::vector_view<DiscreteBearing> m_bearing_values_table; util::vector_view<DiscreteBearing> m_bearing_values_table;
// allocator that keeps the allocation data // allocator that keeps the allocation data

View File

@ -190,8 +190,7 @@ template <osrm::storage::Ownership Ownership> class SegmentDataContainerImpl
auto GetNumberOfGeometries() const { return index.size() - 1; } auto GetNumberOfGeometries() const { return index.size() - 1; }
auto GetNumberOfSegments() const { return fwd_weights.size(); } auto GetNumberOfSegments() const { return fwd_weights.size(); }
friend void friend void io::read<Ownership>(const boost::filesystem::path &path,
io::read<Ownership>(const boost::filesystem::path &path,
detail::SegmentDataContainerImpl<Ownership> &segment_data); detail::SegmentDataContainerImpl<Ownership> &segment_data);
friend void friend void
io::write<Ownership>(const boost::filesystem::path &path, io::write<Ownership>(const boost::filesystem::path &path,
@ -208,10 +207,8 @@ template <osrm::storage::Ownership Ownership> class SegmentDataContainerImpl
}; };
} }
using SegmentDataView = using SegmentDataView = detail::SegmentDataContainerImpl<osrm::storage::Ownership::View>;
detail::SegmentDataContainerImpl<osrm::storage::Ownership::View>; using SegmentDataContainer = detail::SegmentDataContainerImpl<osrm::storage::Ownership::Container>;
using SegmentDataContainer =
detail::SegmentDataContainerImpl<osrm::storage::Ownership::Container>;
} }
} }

View File

@ -35,8 +35,7 @@ using CellStorageView = detail::CellStorageImpl<osrm::storage::Ownership::View>;
namespace io namespace io
{ {
template <osrm::storage::Ownership Ownership> template <osrm::storage::Ownership Ownership>
inline void read(const boost::filesystem::path &path, inline void read(const boost::filesystem::path &path, detail::CellStorageImpl<Ownership> &storage);
detail::CellStorageImpl<Ownership> &storage);
template <osrm::storage::Ownership Ownership> template <osrm::storage::Ownership Ownership>
inline void write(const boost::filesystem::path &path, inline void write(const boost::filesystem::path &path,
const detail::CellStorageImpl<Ownership> &storage); const detail::CellStorageImpl<Ownership> &storage);
@ -186,8 +185,7 @@ template <osrm::storage::Ownership Ownership> class CellStorageImpl
CellStorageImpl() {} CellStorageImpl() {}
template < template <typename GraphT,
typename GraphT,
typename = std::enable_if<Ownership == osrm::storage::Ownership::Container>> typename = std::enable_if<Ownership == osrm::storage::Ownership::Container>>
CellStorageImpl(const partition::MultiLevelPartition &partition, const GraphT &base_graph) CellStorageImpl(const partition::MultiLevelPartition &partition, const GraphT &base_graph)
{ {
@ -317,8 +315,7 @@ template <osrm::storage::Ownership Ownership> class CellStorageImpl
weights.resize(weight_offset + 1, INVALID_EDGE_WEIGHT); weights.resize(weight_offset + 1, INVALID_EDGE_WEIGHT);
} }
template < template <typename = std::enable_if<Ownership == osrm::storage::Ownership::View>>
typename = std::enable_if<Ownership == osrm::storage::Ownership::View>>
CellStorageImpl(Vector<EdgeWeight> weights_, CellStorageImpl(Vector<EdgeWeight> weights_,
Vector<NodeID> source_boundary_, Vector<NodeID> source_boundary_,
Vector<NodeID> destination_boundary_, Vector<NodeID> destination_boundary_,
@ -343,8 +340,7 @@ template <osrm::storage::Ownership Ownership> class CellStorageImpl
destination_boundary.empty() ? nullptr : destination_boundary.data()}; destination_boundary.empty() ? nullptr : destination_boundary.data()};
} }
template < template <typename = std::enable_if<Ownership == osrm::storage::Ownership::Container>>
typename = std::enable_if<Ownership == osrm::storage::Ownership::Container>>
Cell GetCell(LevelID level, CellID id) Cell GetCell(LevelID level, CellID id)
{ {
const auto level_index = LevelIDToIndex(level); const auto level_index = LevelIDToIndex(level);

View File

@ -17,8 +17,7 @@ namespace io
{ {
template <typename EdgeDataT, osrm::storage::Ownership Ownership> template <typename EdgeDataT, osrm::storage::Ownership Ownership>
inline void read(const boost::filesystem::path &path, inline void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, Ownership> &graph)
MultiLevelGraph<EdgeDataT, Ownership> &graph)
{ {
const auto fingerprint = storage::io::FileReader::VerifyFingerprint; const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
storage::io::FileReader reader{path, fingerprint}; storage::io::FileReader reader{path, fingerprint};

View File

@ -24,8 +24,7 @@ template <typename EdgeDataT, osrm::storage::Ownership Ownership>
void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, Ownership> &graph); void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, Ownership> &graph);
template <typename EdgeDataT, osrm::storage::Ownership Ownership> template <typename EdgeDataT, osrm::storage::Ownership Ownership>
void write(const boost::filesystem::path &path, void write(const boost::filesystem::path &path, const MultiLevelGraph<EdgeDataT, Ownership> &graph);
const MultiLevelGraph<EdgeDataT, Ownership> &graph);
} }
template <typename EdgeDataT, osrm::storage::Ownership Ownership> template <typename EdgeDataT, osrm::storage::Ownership Ownership>
@ -191,11 +190,9 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
node_to_edge_offset.push_back(mlp.GetNumberOfLevels()); node_to_edge_offset.push_back(mlp.GetNumberOfLevels());
} }
friend void friend void io::read<EdgeDataT, Ownership>(const boost::filesystem::path &path,
io::read<EdgeDataT, Ownership>(const boost::filesystem::path &path,
MultiLevelGraph<EdgeDataT, Ownership> &graph); MultiLevelGraph<EdgeDataT, Ownership> &graph);
friend void friend void io::write<EdgeDataT, Ownership>(const boost::filesystem::path &path,
io::write<EdgeDataT, Ownership>(const boost::filesystem::path &path,
const MultiLevelGraph<EdgeDataT, Ownership> &graph); const MultiLevelGraph<EdgeDataT, Ownership> &graph);
Vector<EdgeOffset> node_to_edge_offset; Vector<EdgeOffset> node_to_edge_offset;

View File

@ -28,10 +28,8 @@ namespace detail
{ {
template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl; template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl;
} }
using MultiLevelPartition = using MultiLevelPartition = detail::MultiLevelPartitionImpl<osrm::storage::Ownership::Container>;
detail::MultiLevelPartitionImpl<osrm::storage::Ownership::Container>; using MultiLevelPartitionView = detail::MultiLevelPartitionImpl<osrm::storage::Ownership::View>;
using MultiLevelPartitionView =
detail::MultiLevelPartitionImpl<osrm::storage::Ownership::View>;
namespace io namespace io
{ {
@ -70,8 +68,7 @@ template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl fina
// cell_sizes is index by level (starting at 0, the base graph). // cell_sizes is index by level (starting at 0, the base graph).
// However level 0 always needs to have cell size 1, since it is the // However level 0 always needs to have cell size 1, since it is the
// basegraph. // basegraph.
template <typename = typename std::enable_if<Ownership == template <typename = typename std::enable_if<Ownership == osrm::storage::Ownership::Container>>
osrm::storage::Ownership::Container>>
MultiLevelPartitionImpl(const std::vector<std::vector<CellID>> &partitions, MultiLevelPartitionImpl(const std::vector<std::vector<CellID>> &partitions,
const std::vector<std::uint32_t> &lidx_to_num_cells) const std::vector<std::uint32_t> &lidx_to_num_cells)
: level_data(MakeLevelData(lidx_to_num_cells)) : level_data(MakeLevelData(lidx_to_num_cells))
@ -79,8 +76,7 @@ template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl fina
InitializePartitionIDs(partitions); InitializePartitionIDs(partitions);
} }
template <typename = typename std::enable_if<Ownership == template <typename = typename std::enable_if<Ownership == osrm::storage::Ownership::View>>
osrm::storage::Ownership::View>>
MultiLevelPartitionImpl(LevelData level_data, MultiLevelPartitionImpl(LevelData level_data,
Vector<PartitionID> partition_, Vector<PartitionID> partition_,
Vector<CellID> cell_to_children_) Vector<CellID> cell_to_children_)

View File

@ -22,8 +22,7 @@ namespace util
* NOTE: this type is templated for future use, but will require a slight refactor to * NOTE: this type is templated for future use, but will require a slight refactor to
* configure BITSIZE and ELEMSIZE * configure BITSIZE and ELEMSIZE
*/ */
template <typename T, template <typename T, osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container>
osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container>
class PackedVector class PackedVector
{ {
static const constexpr std::size_t BITSIZE = 33; static const constexpr std::size_t BITSIZE = 33;

View File

@ -216,8 +216,7 @@ template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> class RangeTa
}; };
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership>
unsigned RangeTable<BLOCK_SIZE, Ownership>::PrefixSumAtIndex(int index, unsigned RangeTable<BLOCK_SIZE, Ownership>::PrefixSumAtIndex(int index, const BlockT &block) const
const BlockT &block) const
{ {
// this loop looks inefficent, but a modern compiler // this loop looks inefficent, but a modern compiler
// will emit nice SIMD here, at least for sensible block sizes. (I checked.) // will emit nice SIMD here, at least for sensible block sizes. (I checked.)

View File

@ -128,8 +128,7 @@ template <typename DataT> class vector_view
auto data() const { return m_ptr; } auto data() const { return m_ptr; }
template <typename T> template <typename T> friend void swap(vector_view<T> &, vector_view<T> &) noexcept;
friend void swap(vector_view<T> &, vector_view<T> &) noexcept;
}; };
template <> class vector_view<bool> template <> class vector_view<bool>
@ -163,13 +162,11 @@ template <> class vector_view<bool>
bool operator[](const unsigned index) const { return at(index); } bool operator[](const unsigned index) const { return at(index); }
template <typename T> template <typename T> friend void swap(vector_view<T> &, vector_view<T> &) noexcept;
friend void swap(vector_view<T> &, vector_view<T> &) noexcept;
}; };
// Both vector_view<T> and the vector_view<bool> specializations share this impl. // Both vector_view<T> and the vector_view<bool> specializations share this impl.
template <typename DataT> template <typename DataT> void swap(vector_view<DataT> &lhs, vector_view<DataT> &rhs) noexcept
void swap(vector_view<DataT> &lhs, vector_view<DataT> &rhs) noexcept
{ {
std::swap(lhs.m_ptr, rhs.m_ptr); std::swap(lhs.m_ptr, rhs.m_ptr);
std::swap(lhs.m_size, rhs.m_size); std::swap(lhs.m_size, rhs.m_size);
@ -177,8 +174,7 @@ void swap(vector_view<DataT> &lhs, vector_view<DataT> &rhs) noexcept
template <typename DataT, osrm::storage::Ownership Ownership> struct ShM template <typename DataT, osrm::storage::Ownership Ownership> struct ShM
{ {
using vector = using vector = typename std::conditional<Ownership == osrm::storage::Ownership::View,
typename std::conditional<Ownership == osrm::storage::Ownership::View,
vector_view<DataT>, vector_view<DataT>,
std::vector<DataT>>::type; std::vector<DataT>>::type;
}; };

View File

@ -27,8 +27,8 @@ constexpr int32_t WORLD_MIN_LON = -180 * COORDINATE_PRECISION;
constexpr int32_t WORLD_MAX_LON = 180 * COORDINATE_PRECISION; constexpr int32_t WORLD_MAX_LON = 180 * COORDINATE_PRECISION;
using RTreeLeaf = extractor::EdgeBasedNode; using RTreeLeaf = extractor::EdgeBasedNode;
using BenchStaticRTree = util::StaticRTree< using BenchStaticRTree =
RTreeLeaf, util::StaticRTree<RTreeLeaf,
util::ShM<util::Coordinate, osrm::storage::Ownership::Container>::vector, util::ShM<util::Coordinate, osrm::storage::Ownership::Container>::vector,
osrm::storage::Ownership::Container>; osrm::storage::Ownership::Container>;

View File

@ -84,9 +84,8 @@ auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
auto directed = partition::splitBidirectionalEdges(edge_based_edge_list); auto directed = partition::splitBidirectionalEdges(edge_based_edge_list);
auto tidied = auto tidied =
partition::prepareEdgesForUsageInGraph<StaticEdgeBasedGraphEdge>(std::move(directed)); partition::prepareEdgesForUsageInGraph<StaticEdgeBasedGraphEdge>(std::move(directed));
auto edge_based_graph = auto edge_based_graph = std::make_unique<
std::make_unique<partition::MultiLevelGraph<EdgeBasedGraphEdgeData, partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::Container>>(
osrm::storage::Ownership::Container>>(
mlp, num_nodes, std::move(tidied)); mlp, num_nodes, std::move(tidied));
util::Log() << "Loaded edge based graph for mapping partition ids: " util::Log() << "Loaded edge based graph for mapping partition ids: "

View File

@ -365,14 +365,13 @@ void Storage::PopulateLayout(DataLayout &layout)
intersection_file.Skip<std::uint32_t>(1); // sum_lengths intersection_file.Skip<std::uint32_t>(1); // sum_lengths
layout.SetBlockSize<unsigned>(DataLayout::BEARING_OFFSETS, bearing_blocks); layout.SetBlockSize<unsigned>(DataLayout::BEARING_OFFSETS, bearing_blocks);
layout.SetBlockSize< layout.SetBlockSize<typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT>(
typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT>(
DataLayout::BEARING_BLOCKS, bearing_blocks); DataLayout::BEARING_BLOCKS, bearing_blocks);
// No need to read the data // No need to read the data
intersection_file.Skip<unsigned>(bearing_blocks); intersection_file.Skip<unsigned>(bearing_blocks);
intersection_file.Skip< intersection_file
typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT>( .Skip<typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT>(
bearing_blocks); bearing_blocks);
const auto num_bearings = intersection_file.ReadElementCount64(); const auto num_bearings = intersection_file.ReadElementCount64();
@ -807,8 +806,7 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
intersection_file.Skip<std::uint32_t>(1); // sum_lengths intersection_file.Skip<std::uint32_t>(1); // sum_lengths
std::vector<unsigned> bearing_offsets_data(bearing_blocks); std::vector<unsigned> bearing_offsets_data(bearing_blocks);
std::vector< std::vector<typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT>
typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT>
bearing_blocks_data(bearing_blocks); bearing_blocks_data(bearing_blocks);
intersection_file.ReadInto(bearing_offsets_data.data(), bearing_blocks); intersection_file.ReadInto(bearing_offsets_data.data(), bearing_blocks);

View File

@ -38,8 +38,7 @@ auto makeGraph(const MultiLevelPartition &mlp, const std::vector<MockEdge> &mock
edges.push_back(Edge{m.target, m.source, false, true}); edges.push_back(Edge{m.target, m.source, false, true});
} }
std::sort(edges.begin(), edges.end()); std::sort(edges.begin(), edges.end());
return MultiLevelGraph<EdgeData, osrm::storage::Ownership::Container>( return MultiLevelGraph<EdgeData, osrm::storage::Ownership::Container>(mlp, max_id + 1, edges);
mlp, max_id + 1, edges);
} }
} }

View File

@ -45,11 +45,8 @@ using TestStaticRTree = StaticRTree<TestData,
osrm::storage::Ownership::Container, osrm::storage::Ownership::Container,
TEST_BRANCHING_FACTOR, TEST_BRANCHING_FACTOR,
TEST_LEAF_NODE_SIZE>; TEST_LEAF_NODE_SIZE>;
using MiniStaticRTree = StaticRTree<TestData, using MiniStaticRTree =
std::vector<Coordinate>, StaticRTree<TestData, std::vector<Coordinate>, osrm::storage::Ownership::Container, 2, 128>;
osrm::storage::Ownership::Container,
2,
128>;
// Choosen by a fair W20 dice roll (this value is completely arbitrary) // Choosen by a fair W20 dice roll (this value is completely arbitrary)
constexpr unsigned RANDOM_SEED = 42; constexpr unsigned RANDOM_SEED = 42;
@ -277,11 +274,8 @@ void construction_test(const std::string &prefix, FixtureT *fixture)
BOOST_FIXTURE_TEST_CASE(construct_tiny, TestRandomGraphFixture_10_30) BOOST_FIXTURE_TEST_CASE(construct_tiny, TestRandomGraphFixture_10_30)
{ {
using TinyTestTree = StaticRTree<TestData, using TinyTestTree =
std::vector<Coordinate>, StaticRTree<TestData, std::vector<Coordinate>, osrm::storage::Ownership::Container, 2, 64>;
osrm::storage::Ownership::Container,
2,
64>;
construction_test<TinyTestTree>("test_tiny", this); construction_test<TinyTestTree>("test_tiny", this);
} }