Remove osrm namespace indication where possible, wrap out shared_memory_ownership
This commit is contained in:
committed by
Patrick Niklaus
parent
091a495632
commit
789311abd6
@@ -4,7 +4,7 @@
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "storage/shared_memory_ownership.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
@@ -22,7 +22,7 @@ namespace util
|
||||
* NOTE: this type is templated for future use, but will require a slight refactor to
|
||||
* configure BITSIZE and ELEMSIZE
|
||||
*/
|
||||
template <typename T, osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container>
|
||||
template <typename T, storage::Ownership Ownership = storage::Ownership::Container>
|
||||
class PackedVector
|
||||
{
|
||||
static const constexpr std::size_t BITSIZE = 33;
|
||||
@@ -123,20 +123,20 @@ class PackedVector
|
||||
|
||||
std::size_t size() const { return num_elements; }
|
||||
|
||||
template <bool enabled = (Ownership == osrm::storage::Ownership::View)>
|
||||
template <bool enabled = (Ownership == storage::Ownership::View)>
|
||||
void reserve(typename std::enable_if<!enabled, std::size_t>::type capacity)
|
||||
{
|
||||
vec.reserve(elements_to_blocks(capacity));
|
||||
}
|
||||
|
||||
template <bool enabled = (Ownership == osrm::storage::Ownership::View)>
|
||||
template <bool enabled = (Ownership == storage::Ownership::View)>
|
||||
void reset(typename std::enable_if<enabled, std::uint64_t>::type *ptr,
|
||||
typename std::enable_if<enabled, std::size_t>::type size)
|
||||
{
|
||||
vec.reset(ptr, size);
|
||||
}
|
||||
|
||||
template <bool enabled = (Ownership == osrm::storage::Ownership::View)>
|
||||
template <bool enabled = (Ownership == storage::Ownership::View)>
|
||||
void set_number_of_entries(typename std::enable_if<enabled, std::size_t>::type count)
|
||||
{
|
||||
num_elements = count;
|
||||
@@ -154,38 +154,38 @@ class PackedVector
|
||||
|
||||
signed cursor = -1;
|
||||
|
||||
template <bool enabled = (Ownership == osrm::storage::Ownership::View)>
|
||||
template <bool enabled = (Ownership == storage::Ownership::View)>
|
||||
void replace_last_elem(typename std::enable_if<enabled, std::uint64_t>::type last_elem)
|
||||
{
|
||||
vec[cursor] = last_elem;
|
||||
}
|
||||
|
||||
template <bool enabled = (Ownership == osrm::storage::Ownership::View)>
|
||||
template <bool enabled = (Ownership == storage::Ownership::View)>
|
||||
void replace_last_elem(typename std::enable_if<!enabled, std::uint64_t>::type last_elem)
|
||||
{
|
||||
vec.back() = last_elem;
|
||||
}
|
||||
|
||||
template <bool enabled = (Ownership == osrm::storage::Ownership::View)>
|
||||
template <bool enabled = (Ownership == storage::Ownership::View)>
|
||||
void add_last_elem(typename std::enable_if<enabled, std::uint64_t>::type last_elem)
|
||||
{
|
||||
vec[cursor + 1] = last_elem;
|
||||
cursor++;
|
||||
}
|
||||
|
||||
template <bool enabled = (Ownership == osrm::storage::Ownership::View)>
|
||||
template <bool enabled = (Ownership == storage::Ownership::View)>
|
||||
void add_last_elem(typename std::enable_if<!enabled, std::uint64_t>::type last_elem)
|
||||
{
|
||||
vec.push_back(last_elem);
|
||||
}
|
||||
|
||||
template <bool enabled = (Ownership == osrm::storage::Ownership::View)>
|
||||
template <bool enabled = (Ownership == storage::Ownership::View)>
|
||||
std::uint64_t vec_back(typename std::enable_if<enabled>::type * = nullptr)
|
||||
{
|
||||
return vec[cursor];
|
||||
}
|
||||
|
||||
template <bool enabled = (Ownership == osrm::storage::Ownership::View)>
|
||||
template <bool enabled = (Ownership == storage::Ownership::View)>
|
||||
std::uint64_t vec_back(typename std::enable_if<!enabled>::type * = nullptr)
|
||||
{
|
||||
return vec.back();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define RANGE_TABLE_HPP
|
||||
|
||||
#include "storage/io.hpp"
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "storage/shared_memory_ownership.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
|
||||
@@ -19,14 +19,13 @@ namespace util
|
||||
* and otherwise the compiler gets confused.
|
||||
*/
|
||||
|
||||
template <unsigned BLOCK_SIZE = 16,
|
||||
osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container>
|
||||
template <unsigned BLOCK_SIZE = 16, storage::Ownership Ownership = storage::Ownership::Container>
|
||||
class RangeTable;
|
||||
|
||||
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership>
|
||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
|
||||
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownership> &table);
|
||||
|
||||
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership>
|
||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
|
||||
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &table);
|
||||
|
||||
/**
|
||||
@@ -38,7 +37,7 @@ std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &ta
|
||||
* But each block consists of an absolute value and BLOCK_SIZE differential values.
|
||||
* So the effective block size is sizeof(unsigned) + BLOCK_SIZE.
|
||||
*/
|
||||
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> class RangeTable
|
||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership> class RangeTable
|
||||
{
|
||||
public:
|
||||
using BlockT = std::array<unsigned char, BLOCK_SIZE>;
|
||||
@@ -142,7 +141,7 @@ template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> class RangeTa
|
||||
sum_lengths = lengths_prefix_sum;
|
||||
}
|
||||
|
||||
void Write(osrm::storage::io::FileWriter &filewriter)
|
||||
void Write(storage::io::FileWriter &filewriter)
|
||||
{
|
||||
unsigned number_of_blocks = diff_blocks.size();
|
||||
|
||||
@@ -154,7 +153,7 @@ template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> class RangeTa
|
||||
filewriter.WriteFrom(diff_blocks.data(), number_of_blocks);
|
||||
}
|
||||
|
||||
void Read(osrm::storage::io::FileReader &filereader)
|
||||
void Read(storage::io::FileReader &filereader)
|
||||
{
|
||||
unsigned number_of_blocks = filereader.ReadElementCount32();
|
||||
// read total length
|
||||
@@ -215,7 +214,7 @@ template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> class RangeTa
|
||||
unsigned sum_lengths;
|
||||
};
|
||||
|
||||
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership>
|
||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
|
||||
unsigned RangeTable<BLOCK_SIZE, Ownership>::PrefixSumAtIndex(int index, const BlockT &block) const
|
||||
{
|
||||
// this loop looks inefficent, but a modern compiler
|
||||
@@ -229,7 +228,7 @@ unsigned RangeTable<BLOCK_SIZE, Ownership>::PrefixSumAtIndex(int index, const Bl
|
||||
return sum;
|
||||
}
|
||||
|
||||
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership>
|
||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
|
||||
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownership> &table)
|
||||
{
|
||||
// write number of block
|
||||
@@ -245,7 +244,7 @@ std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownersh
|
||||
return out;
|
||||
}
|
||||
|
||||
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership>
|
||||
template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
|
||||
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &table)
|
||||
{
|
||||
// read number of block
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "storage/shared_memory_ownership.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
@@ -172,9 +172,9 @@ template <typename DataT> void swap(vector_view<DataT> &lhs, vector_view<DataT>
|
||||
std::swap(lhs.m_size, rhs.m_size);
|
||||
}
|
||||
|
||||
template <typename DataT, osrm::storage::Ownership Ownership> struct ShM
|
||||
template <typename DataT, storage::Ownership Ownership> struct ShM
|
||||
{
|
||||
using vector = typename std::conditional<Ownership == osrm::storage::Ownership::View,
|
||||
using vector = typename std::conditional<Ownership == storage::Ownership::View,
|
||||
vector_view<DataT>,
|
||||
std::vector<DataT>>::type;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "storage/shared_memory_ownership.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
@@ -99,8 +99,7 @@ EntryT edgeToEntry(const OtherEdge &from, std::false_type)
|
||||
|
||||
} // namespace static_graph_details
|
||||
|
||||
template <typename EdgeDataT,
|
||||
osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container>
|
||||
template <typename EdgeDataT, storage::Ownership Ownership = storage::Ownership::Container>
|
||||
class StaticGraph
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "storage/shared_memory_ownership.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
@@ -54,7 +54,7 @@ namespace util
|
||||
// are computed, this means the internal distance metric doesn not represent meters!
|
||||
template <class EdgeDataT,
|
||||
class CoordinateListT = std::vector<Coordinate>,
|
||||
osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container,
|
||||
storage::Ownership Ownership = storage::Ownership::Container,
|
||||
std::uint32_t BRANCHING_FACTOR = 128,
|
||||
std::uint32_t LEAF_PAGE_SIZE = 4096>
|
||||
class StaticRTree
|
||||
@@ -159,7 +159,7 @@ class StaticRTree
|
||||
|
||||
boost::iostreams::mapped_file_source m_leaves_region;
|
||||
// read-only view of leaves
|
||||
typename ShM<const LeafNode, osrm::storage::Ownership::View>::vector m_leaves;
|
||||
typename ShM<const LeafNode, storage::Ownership::View>::vector m_leaves;
|
||||
|
||||
public:
|
||||
StaticRTree(const StaticRTree &) = delete;
|
||||
|
||||
Reference in New Issue
Block a user