/* * buffer.h * * Created on: Jun 7, 2021 * Author: mad */ #ifndef INCLUDE_CHIA_BUFFER_H_ #define INCLUDE_CHIA_BUFFER_H_ #include template struct byte_buffer_t { size_t count = 0; const size_t capacity; uint8_t* data = nullptr; static constexpr size_t entry_size = T::disk_size; byte_buffer_t(const size_t capacity) : capacity(capacity) { data = new uint8_t[capacity * entry_size]; } ~byte_buffer_t() { delete [] data; } uint8_t* entry_at(const size_t i) { return data + i * entry_size; } byte_buffer_t(byte_buffer_t&) = delete; byte_buffer_t& operator=(byte_buffer_t&) = delete; }; template struct read_buffer_t : byte_buffer_t { read_buffer_t() : byte_buffer_t(g_read_chunk_size) {} }; template struct write_buffer_t : byte_buffer_t { write_buffer_t() : byte_buffer_t(g_write_chunk_size) {} }; #endif /* INCLUDE_CHIA_BUFFER_H_ */