BmnRoot 26.10.0-233-gb9bbe585
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnIArchiveLibRead.h
Go to the documentation of this file.
1#pragma once
2#ifndef BmnIArchiveLibRead_h
3#define BmnIArchiveLibRead_h
4
5// headers from this target
7// std:: headers
8#include <cstddef>
9#include <string>
10
11/*
12 * An interface class for all archive libraries that should read (uncompress) data from binary files
13 */
15{
16 BmnIArchiveLibRead() = default;
17 virtual ~BmnIArchiveLibRead() = default;
18
19 /*
20 * A method that is called to uncompress compressed data
21 * @param source A pointer to a buffer with the subsequent compressed data that should be uncompressed
22 * @param sourceTotalSize A number of bytes available in the source buffer
23 * @param numberOfReadBytes A number of bytes that were consumed while compressing. This value will be set.
24 * @param output A pointer to a buffer that will be filled with uncompressed data
25 * @param outputTotalSize A number of bytes that may be filled in the output buffer
26 * @param numberOfSetOutputBytes A number of bytes that were set while decompressing. This value will be set.
27 * @return A result status based on the success of this function
28 */
29 virtual BmnFileStreamResults Uncompress(const void* source,
30 const size_t sourceTotalSize,
31 size_t& numberOfReadBytes,
32 void* output,
33 const size_t outputTotalSize,
34 size_t& numberOfSetOutputBytes) = 0;
35
36 /*
37 * If an error previously occurred, this method may be called to obtain its description
38 * @return A string describing the last error, or an empty string if no error has occurred
39 * @throw std::bad_alloc if an allocation error occurs
40 */
41 [[nodiscard]] virtual std::string GetLastUncompressErrorDescription() const = 0;
42
43 /*
44 * Get the number of currently decompressed bytes. This only includes bytes that are not part of
45 * various headers (actual number of output bytes)
46 * @return The number of currently decompressed bytes
47 */
48 [[nodiscard]] virtual size_t GetNumberOfDecompressedBytes() const noexcept = 0;
49
50 /*
51 * Some libraries if not all will be able to tell if the end of the stream is reached.
52 * This is important because the used library might cache some data internally, which could result
53 * in data loss. Thus, calling this method to check if we have processed all the data is
54 * advisable.
55 * @return 'true' if the underlying stream has a bad state or empty internal cache, or 'false' otherwise
56 */
57 [[nodiscard]] virtual bool HasReachedTheEndOfStream() const noexcept = 0;
58
59 /*
60 * This method can help us determine if an error was detected in the past while trying to decompress data
61 * @return 'true' if an underlying decompression stream is in a good state, or 'false' if not
62 */
63 [[nodiscard]] virtual bool IsStreamInGoodState() const noexcept = 0;
64};
65
66#endif // BmnIArchiveLibRead_h
virtual std::string GetLastUncompressErrorDescription() const =0
BmnIArchiveLibRead()=default
virtual BmnFileStreamResults Uncompress(const void *source, const size_t sourceTotalSize, size_t &numberOfReadBytes, void *output, const size_t outputTotalSize, size_t &numberOfSetOutputBytes)=0
virtual ~BmnIArchiveLibRead()=default
virtual bool HasReachedTheEndOfStream() const noexcept=0
virtual size_t GetNumberOfDecompressedBytes() const noexcept=0
virtual bool IsStreamInGoodState() const noexcept=0