osrm-backend/include/storage/block.hpp

38 lines
721 B
C++
Raw Normal View History

#ifndef OSRM_STORAGE_BLOCK_HPP
#define OSRM_STORAGE_BLOCK_HPP
#include "storage/io.hpp"
#include <cstdint>
#include <string>
#include <tuple>
namespace osrm
{
namespace storage
{
struct Block
{
2018-03-26 16:08:39 -04:00
std::uint64_t num_entries;
std::uint64_t byte_size;
Block() : num_entries(0), byte_size(0) {}
Block(std::uint64_t num_entries, std::uint64_t byte_size)
: num_entries(num_entries), byte_size(byte_size)
{
}
};
using NamedBlock = std::tuple<std::string, Block>;
template <typename T> Block make_block(uint64_t num_entries)
{
static_assert(sizeof(T) % alignof(T) == 0, "aligned T* can't be used as an array pointer");
2018-03-15 07:13:13 -04:00
return Block{num_entries, sizeof(T) * num_entries};
}
}
}
#endif