|
Centipede 0.0.1
Centipede program
|
Class for writing binary files. More...
#include <binary.hpp>
Classes | |
| class | Config |
| Class for configuring the binary writer class (Binary). More... | |
Public Types | |
| using | BufferType = std::pair<std::vector<uint32_t>, std::vector<float>> |
| Type of the data_buffer_. | |
| using | BufferPoint = std::pair<uint32_t, float> |
| Type of the buffer point stored in the data_buffer_. | |
Public Member Functions | |
| Binary ()=default | |
| Default constructor. | |
| constexpr | Binary (Config config) |
| Constructor takes an argument for the configuration. | |
| auto | init () -> EnumError<> |
| Initialization. | |
| template<std::size_t NLocals, std::size_t NGlobals> | |
| auto | add_entrypoint (const EntryPoint< NLocals, NGlobals > &entry_point) -> EnumError<> |
| Add an entrypoint to the internal data buffer. | |
| auto | write_current_entry () -> EnumError< std::size_t > |
| Streaming an entry data to the output file. | |
| void | close () |
| Manually close the output file handler. | |
| constexpr auto | get_config () const -> const Config & |
| Getter of the configuration. | |
| constexpr auto | get_buffer () const -> const BufferType & |
| Getter of the buffer. | |
Private Attributes | |
| Config | config_ |
| Member variable for the configuration. | |
| BufferType | data_buffer_ |
| Data buffer to store entry_point. | |
| std::ofstream | output_file_ |
| Output file handler. | |
Data is written to the binary file via each entry, which contains different entrypoints (of the type centipede::EntryPoint). Before any operation, the Binary::init() function must be called, where the file handler is opened and internal buffer resetted, ready for the next data input. When adding each entrypoint, the writer doesn't write the corresponding data to the binary file, but rather pushes the data to its internal buffer (see Binary::data_buffer_). Data is only written to the binary file after calling Binary::write_current_entry(). All entrypoints added before this call are grouped into the same entry.
Configuration of the class is done via the Binary::Config struct.
For a complete example, please check out test_writer.cpp.
Definition at line 62 of file binary.hpp.
|
inlineexplicitconstexpr |
The config argument will be moved (std::move) to its member variable config_
| config | Configuration struct. |
Definition at line 100 of file binary.hpp.
|
nodiscard |
The adding of an entrypoint to the data buffer follows the sequence:
| entry_point | Input data structure which stores the local/global derivatives, measurement and error. |
Definition at line 183 of file binary.hpp.
|
inline |
This function will be called automatically when the destructor is called.
Definition at line 151 of file binary.hpp.
|
inlineconstexpr |
Definition at line 167 of file binary.hpp.
|
inlineconstexpr |
Definition at line 159 of file binary.hpp.
|
nodiscard |
The initialization function must be called before calling the add_entrypoint() method. When calling this function, data_buffer_ is resetted and a file is opened with the specified name in Config.
Definition at line 50 of file binary.cpp.
| auto centipede::writer::Binary::write_current_entry | ( | ) | -> EnumError< std::size_t > |
Streaming the entry data to the output file and call the reset() function to clear the internal buffer. After the function is called, the writer is waiting for a new entry to be added.
Definition at line 63 of file binary.cpp.