BmnRoot
26.10.0-233-gb9bbe585
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnIFileReader.h
Go to the documentation of this file.
1
#pragma once
2
#ifndef BmnIFileReader_h
3
#define BmnIFileReader_h
4
5
// headers from this target
6
#include "
BmnFileProcessingFlags.h
"
7
// std:: headers
8
#include <filesystem>
9
// FairLogger headers
10
#include <fairlogger/Logger.h>
11
12
// o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
13
// ================== BmnIFileReader class ==================
14
// o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
15
16
/*
17
* An abstract interface class for reading files. The primary goal of this class is to provide some
18
* basic-reading functionality while children classes will implement various ways of extracting data
19
* from files (mostly from compressed files as this is the goal).
20
*/
21
class
BmnIFileReader
22
{
23
public
:
24
BmnIFileReader
() =
default
;
25
26
virtual
~BmnIFileReader
() =
default
;
27
BmnIFileReader
(
const
BmnIFileReader
&) =
delete
;
28
BmnIFileReader
&
operator=
(
const
BmnIFileReader
&) =
delete
;
29
BmnIFileReader
(
BmnIFileReader
&&) noexcept = delete;
30
BmnIFileReader
& operator=(
BmnIFileReader
&&) noexcept = delete;
31
32
/*
33
* A method that opens a binary file for reading from one of the daughter classes
34
* @param aFilePath A path to the file that should be opened
35
* @warning Be very carful with "the currently-working directory" as it may not be the same as the executable path!
36
*/
37
virtual
void
Open
(const std::filesystem::path& aFilePath) = 0;
38
39
/*
40
* A method that closes an open file stream and clears/removes all buffers.
41
* This method should be used before reopening a file.
42
*/
43
virtual
void
Close
() noexcept = 0;
44
45
/*
46
* A method that extracts a requested number of bytes and puts them into the provided array
47
* @param dataPointer A buffer for inserting new data
48
* @param numberOfBytesToRead A number of bytes that should be copied into the provided buffer
49
* @return The number of bytes that have actually been copied. If less than `numberOfBytesToRead`, it means we've
50
* hit EOF or an error
51
*/
52
virtual int64_t
Read
(
void
* dataPointer, int64_t numberOfBytesToRead) = 0;
53
54
/*
55
* @return A next byte ID that's to be read
56
*/
57
[[nodiscard]] virtual int64_t
Tell
() const noexcept = 0;
58
59
/*
60
* Move the file reading ID to another position
61
* @param aNewReadingPosition A next position to read
62
* @warning If compressed files are used, this might still read and uncomress the data. The method might not have
63
* high performance
64
*/
65
virtual
void
Seek
(int64_t aNewReadingPosition) = 0;
66
67
/*
68
* @return 'true' if no error has been detected while processing an input stream, otherwise 'false'
69
*/
70
[[nodiscard]] virtual
bool
IsGood
() const noexcept = 0;
71
72
/*
73
* @return 'true' if we have reached EOF, otherwise 'false'
74
*/
75
[[nodiscard]] virtual
bool
IsEOF
() const noexcept = 0;
76
77
/*
78
* A method that clears bad flags after an error has occurred. Just calling this error will most likely
79
* not solve the problem, and you will get an error again in the next read. That is, before calling `Read`,
80
* remove the previous error source
81
*/
82
virtual
void
ClearStateFlags
() = 0;
83
84
/*
85
* @return 'true' if the input file is open, otherwise 'false'
86
*/
87
[[nodiscard]] virtual
bool
IsOpen
() const noexcept = 0;
88
89
/*
90
* @return A type of the current reader
91
*/
92
[[nodiscard]] virtual
BmnFileType
GetFileType
() const noexcept = 0;
93
94
protected:
95
/*
96
* A method that ensures the input file actually exists and is good to use.
97
* @param aFilePath A path to a file that's being opened
98
* @return 'true' if the file is good for processing, 'false' otherwise
99
*/
100
[[nodiscard]]
bool
PerformStandardChecksBeforeOpening
(const std::filesystem::path& aFilePath) const noexcept;
101
};
102
103
#endif
// BmnIFileReader_h
BmnFileProcessingFlags.h
BmnFileType
BmnFileType
Definition
BmnFileProcessingFlags.h:16
BmnIFileReader::~BmnIFileReader
virtual ~BmnIFileReader()=default
BmnIFileReader::Close
virtual void Close() noexcept=0
BmnIFileReader::BmnIFileReader
BmnIFileReader(BmnIFileReader &&) noexcept=delete
BmnIFileReader::BmnIFileReader
BmnIFileReader()=default
BmnIFileReader::operator=
BmnIFileReader & operator=(const BmnIFileReader &)=delete
BmnIFileReader::IsOpen
virtual bool IsOpen() const noexcept=0
BmnIFileReader::Open
virtual void Open(const std::filesystem::path &aFilePath)=0
BmnIFileReader::Seek
virtual void Seek(int64_t aNewReadingPosition)=0
BmnIFileReader::Tell
virtual int64_t Tell() const noexcept=0
BmnIFileReader::IsEOF
virtual bool IsEOF() const noexcept=0
BmnIFileReader::GetFileType
virtual BmnFileType GetFileType() const noexcept=0
BmnIFileReader::PerformStandardChecksBeforeOpening
bool PerformStandardChecksBeforeOpening(const std::filesystem::path &aFilePath) const noexcept
Definition
BmnIFileReader.cxx:8
BmnIFileReader::BmnIFileReader
BmnIFileReader(const BmnIFileReader &)=delete
BmnIFileReader::Read
virtual int64_t Read(void *dataPointer, int64_t numberOfBytesToRead)=0
BmnIFileReader::IsGood
virtual bool IsGood() const noexcept=0
BmnIFileReader::ClearStateFlags
virtual void ClearStateFlags()=0
compression
include
BmnIFileReader.h
Generated on
for BmnRoot by
1.17.0