osrm-backend/include/contractor/serialization.hpp
Daniel Patterson 50d9632ed7
Upgrade formatting to clang-format 10 (#5895)
* Update formatting tools to clang-format-10

* Reformat using clang-format-10.0.09
2020-11-26 07:21:39 -08:00

54 lines
1.6 KiB
C++

#ifndef OSRM_CONTRACTOR_SERIALIZATION_HPP
#define OSRM_CONTRACTOR_SERIALIZATION_HPP
#include "contractor/contracted_metric.hpp"
#include "util/serialization.hpp"
#include "storage/serialization.hpp"
#include "storage/tar.hpp"
namespace osrm
{
namespace contractor
{
namespace serialization
{
template <storage::Ownership Ownership>
void write(storage::tar::FileWriter &writer,
const std::string &name,
const detail::ContractedMetric<Ownership> &metric)
{
util::serialization::write(writer, name + "/contracted_graph", metric.graph);
writer.WriteElementCount64(name + "/exclude", metric.edge_filter.size());
for (const auto index : util::irange<std::size_t>(0, metric.edge_filter.size()))
{
storage::serialization::write(writer,
name + "/exclude/" + std::to_string(index) + "/edge_filter",
metric.edge_filter[index]);
}
}
template <storage::Ownership Ownership>
void read(storage::tar::FileReader &reader,
const std::string &name,
detail::ContractedMetric<Ownership> &metric)
{
util::serialization::read(reader, name + "/contracted_graph", metric.graph);
metric.edge_filter.resize(reader.ReadElementCount64(name + "/exclude"));
for (const auto index : util::irange<std::size_t>(0, metric.edge_filter.size()))
{
storage::serialization::read(reader,
name + "/exclude/" + std::to_string(index) + "/edge_filter",
metric.edge_filter[index]);
}
}
} // namespace serialization
} // namespace contractor
} // namespace osrm
#endif