2018-03-13 09:25:22 -04:00
|
|
|
#ifndef OSRM_STORAGE_BLOCK_HPP
|
|
|
|
#define OSRM_STORAGE_BLOCK_HPP
|
|
|
|
|
|
|
|
#include "storage/io.hpp"
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
#include <tuple>
|
|
|
|
|
2022-12-11 04:10:26 -05:00
|
|
|
namespace osrm::storage
|
2018-03-13 09:25:22 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
struct Block
|
|
|
|
{
|
2018-03-26 16:08:39 -04:00
|
|
|
std::uint64_t num_entries;
|
|
|
|
std::uint64_t byte_size;
|
2018-10-27 02:48:51 -04:00
|
|
|
std::uint64_t offset;
|
2018-03-26 16:08:39 -04:00
|
|
|
|
2018-10-27 02:48:51 -04:00
|
|
|
Block() : num_entries(0), byte_size(0), offset(0) {}
|
|
|
|
Block(std::uint64_t num_entries, std::uint64_t byte_size, std::uint64_t offset)
|
|
|
|
: num_entries(num_entries), byte_size(byte_size), offset(offset)
|
|
|
|
{
|
|
|
|
}
|
2018-03-26 16:08:39 -04:00
|
|
|
Block(std::uint64_t num_entries, std::uint64_t byte_size)
|
2018-10-27 02:48:51 -04:00
|
|
|
: num_entries(num_entries), byte_size(byte_size), offset(0)
|
2018-03-26 16:08:39 -04:00
|
|
|
{
|
|
|
|
}
|
2018-03-13 09:25:22 -04:00
|
|
|
};
|
|
|
|
|
2018-03-15 09:55:06 -04:00
|
|
|
using NamedBlock = std::tuple<std::string, Block>;
|
|
|
|
|
2018-03-13 09:25:22 -04:00
|
|
|
template <typename T> Block make_block(uint64_t num_entries)
|
|
|
|
{
|
2022-07-04 16:46:59 -04:00
|
|
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
2018-03-13 09:25:22 -04:00
|
|
|
static_assert(sizeof(T) % alignof(T) == 0, "aligned T* can't be used as an array pointer");
|
2018-10-27 02:48:51 -04:00
|
|
|
return Block{num_entries, sizeof(T) * num_entries, 0};
|
2018-03-13 09:25:22 -04:00
|
|
|
}
|
2022-12-20 12:00:11 -05:00
|
|
|
} // namespace osrm::storage
|
2018-03-13 09:25:22 -04:00
|
|
|
|
|
|
|
#endif
|