OGLplus  (0.59.0) a C++ wrapper for rendering APIs

packed_block_source.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_SERIALIZE_PACKED_BLOCK_SOURCE_HPP
10 #define EAGINE_SERIALIZE_PACKED_BLOCK_SOURCE_HPP
11 
12 #include "../compression.hpp"
13 #include "block_source.hpp"
14 
15 namespace eagine {
16 //------------------------------------------------------------------------------
22 public:
24  packed_block_data_source() noexcept = default;
25 
28  data_compressor compressor,
29  memory::const_block src) noexcept
30  : _compressor{std::move(compressor)} {
31  reset(src);
32  }
33 
35  : packed_block_data_source{{}, src} {}
36 
37  packed_block_data_source(data_compressor compressor) noexcept
38  : packed_block_data_source{std::move(compressor), {}} {}
39 
40  void reset(memory::const_block src) {
41  block_data_source::reset(_compressor.decompress(src));
42  }
43 
44 private:
45  data_compressor _compressor{};
46 };
47 //------------------------------------------------------------------------------
48 } // namespace eagine
49 
50 #endif // EAGINE_SERIALIZE_PACKED_BLOCK_SOURCE_HPP
Common code is placed in this namespace.
Definition: eagine.hpp:21
basic_block< true > const_block
Alias for const byte memory span.
Definition: block.hpp:32
Unpacking deserialization data source backed by a pre-allocated memory block.
Definition: packed_block_source.hpp:21
Deserialization data source backed by a pre-allocated memory block.
Definition: block_source.hpp:23
Non-owning view of a contiguous range of memory with ValueType elements.
Definition: flatten_fwd.hpp:16
packed_block_data_source() noexcept=default
Default constructor.
Class implementing data compression and decompresson.
Definition: compression.hpp:37
packed_block_data_source(data_compressor compressor, memory::const_block src) noexcept
Constructor setting the backing block and data compressor.
Definition: packed_block_source.hpp:27
auto decompress(memory::const_block input, const data_handler &handler) -> bool
Decompress the input block, passing the unpacked data to handler.
void reset(memory::const_block src)
Resets the backing block.
Definition: block_source.hpp:34

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).