Don't leak ownership in partition/files
This commit is contained in:
committed by
Patrick Niklaus
parent
446c865415
commit
2da5da3f16
+38
-18
@@ -1,6 +1,8 @@
|
||||
#ifndef OSRM_PARTITION_SERILIZATION_HPP
|
||||
#define OSRM_PARTITION_SERILIZATION_HPP
|
||||
|
||||
#include "customizer/edge_based_graph.hpp"
|
||||
|
||||
#include "partition/serialization.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
@@ -13,10 +15,13 @@ namespace files
|
||||
{
|
||||
|
||||
// reads .osrm.mldgr file
|
||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
||||
inline void readGraph(const boost::filesystem::path &path,
|
||||
MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
||||
template <typename MultiLevelGraphT>
|
||||
inline void readGraph(const boost::filesystem::path &path, MultiLevelGraphT &graph)
|
||||
{
|
||||
static_assert(std::is_same<customizer::MultiLevelEdgeBasedGraphView, MultiLevelGraphT>::value ||
|
||||
std::is_same<customizer::MultiLevelEdgeBasedGraph, MultiLevelGraphT>::value,
|
||||
"");
|
||||
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
@@ -24,10 +29,13 @@ inline void readGraph(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// writes .osrm.mldgr file
|
||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
||||
inline void writeGraph(const boost::filesystem::path &path,
|
||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
||||
template <typename MultiLevelGraphT>
|
||||
inline void writeGraph(const boost::filesystem::path &path, const MultiLevelGraphT &graph)
|
||||
{
|
||||
static_assert(std::is_same<customizer::MultiLevelEdgeBasedGraphView, MultiLevelGraphT>::value ||
|
||||
std::is_same<customizer::MultiLevelEdgeBasedGraph, MultiLevelGraphT>::value,
|
||||
"");
|
||||
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
@@ -35,10 +43,13 @@ inline void writeGraph(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// read .osrm.partition file
|
||||
template <storage::Ownership Ownership>
|
||||
inline void readPartition(const boost::filesystem::path &path,
|
||||
detail::MultiLevelPartitionImpl<Ownership> &mlp)
|
||||
template <typename MultiLevelPartitionT>
|
||||
inline void readPartition(const boost::filesystem::path &path, MultiLevelPartitionT &mlp)
|
||||
{
|
||||
static_assert(std::is_same<MultiLevelPartitionView, MultiLevelPartitionT>::value ||
|
||||
std::is_same<MultiLevelPartition, MultiLevelPartitionT>::value,
|
||||
"");
|
||||
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
@@ -46,10 +57,13 @@ inline void readPartition(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// writes .osrm.partition file
|
||||
template <storage::Ownership Ownership>
|
||||
inline void writePartition(const boost::filesystem::path &path,
|
||||
const detail::MultiLevelPartitionImpl<Ownership> &mlp)
|
||||
template <typename MultiLevelPartitionT>
|
||||
inline void writePartition(const boost::filesystem::path &path, const MultiLevelPartitionT &mlp)
|
||||
{
|
||||
static_assert(std::is_same<MultiLevelPartitionView, MultiLevelPartitionT>::value ||
|
||||
std::is_same<MultiLevelPartition, MultiLevelPartitionT>::value,
|
||||
"");
|
||||
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
@@ -57,10 +71,13 @@ inline void writePartition(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// reads .osrm.cells file
|
||||
template <storage::Ownership Ownership>
|
||||
inline void readCells(const boost::filesystem::path &path,
|
||||
detail::CellStorageImpl<Ownership> &storage)
|
||||
template <typename CellStorageT>
|
||||
inline void readCells(const boost::filesystem::path &path, CellStorageT &storage)
|
||||
{
|
||||
static_assert(std::is_same<CellStorageView, CellStorageT>::value ||
|
||||
std::is_same<CellStorage, CellStorageT>::value,
|
||||
"");
|
||||
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
@@ -68,10 +85,13 @@ inline void readCells(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// writes .osrm.cells file
|
||||
template <storage::Ownership Ownership>
|
||||
inline void writeCells(const boost::filesystem::path &path,
|
||||
const detail::CellStorageImpl<Ownership> &storage)
|
||||
template <typename CellStorageT>
|
||||
inline void writeCells(const boost::filesystem::path &path, CellStorageT &storage)
|
||||
{
|
||||
static_assert(std::is_same<CellStorageView, CellStorageT>::value ||
|
||||
std::is_same<CellStorage, CellStorageT>::value,
|
||||
"");
|
||||
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user