2017-04-02 19:02:57 -04:00
|
|
|
#ifndef OSRM_CONTRACTOR_FILES_HPP
|
|
|
|
#define OSRM_CONTRACTOR_FILES_HPP
|
|
|
|
|
|
|
|
#include "contractor/query_graph.hpp"
|
|
|
|
|
|
|
|
#include "util/serialization.hpp"
|
|
|
|
|
|
|
|
#include "storage/io.hpp"
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace contractor
|
|
|
|
{
|
|
|
|
namespace files
|
|
|
|
{
|
|
|
|
|
|
|
|
// reads .osrm.hsgr file
|
2017-04-03 10:21:13 -04:00
|
|
|
template <typename QueryGraphT>
|
|
|
|
inline void readGraph(const boost::filesystem::path &path, unsigned &checksum, QueryGraphT &graph)
|
2017-04-02 19:02:57 -04:00
|
|
|
{
|
2017-04-03 10:21:13 -04:00
|
|
|
static_assert(std::is_same<QueryGraphView, QueryGraphT>::value ||
|
|
|
|
std::is_same<QueryGraph, QueryGraphT>::value,
|
|
|
|
"graph must be of type QueryGraph<>");
|
|
|
|
|
2017-04-02 19:02:57 -04:00
|
|
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
|
|
|
storage::io::FileReader reader{path, fingerprint};
|
|
|
|
|
|
|
|
reader.ReadInto(checksum);
|
|
|
|
util::serialization::read(reader, graph);
|
|
|
|
}
|
|
|
|
|
|
|
|
// writes .osrm.hsgr file
|
2017-04-03 10:21:13 -04:00
|
|
|
template <typename QueryGraphT>
|
|
|
|
inline void
|
|
|
|
writeGraph(const boost::filesystem::path &path, unsigned checksum, const QueryGraphT &graph)
|
2017-04-02 19:02:57 -04:00
|
|
|
{
|
2017-04-03 10:21:13 -04:00
|
|
|
static_assert(std::is_same<QueryGraphView, QueryGraphT>::value ||
|
|
|
|
std::is_same<QueryGraph, QueryGraphT>::value,
|
|
|
|
"graph must be of type QueryGraph<>");
|
2017-04-02 19:02:57 -04:00
|
|
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
|
|
|
storage::io::FileWriter writer{path, fingerprint};
|
|
|
|
|
|
|
|
writer.WriteOne(checksum);
|
|
|
|
util::serialization::write(writer, graph);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|