BmnRoot
26.10.0-19-g6979a6c6
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnFileProcessingFlags.h
Go to the documentation of this file.
1
#pragma once
2
#ifndef BmnFileProcessingFlags_h
3
#define BmnFileProcessingFlags_h
4
5
// Other BMN targets' header
6
#include "
BmnEnums.h
"
7
// std:: headers
8
#include <cstdint>
9
10
/*
11
* An enum type that tells us which exactly file-reader type is used.
12
* If one adds additional compression libraries into BM@N, add them to the list.
13
* @note Check "ReadMe.md" for more info about the available types
14
*/
15
enum class
BmnFileType
: uint8_t
16
{
17
Unknown
,
18
Raw
,
19
ZStd
,
20
ZLib
,
21
ZLib_ng
,
22
XZ_LZMA
,
23
};
24
25
/*
26
* A method that appends an enum into a string
27
* @tparam T A string-type parameter that supports operator+= with strings
28
* @param initialString A string onto which a file type will be appended
29
* @param fileType A type of file that should be appended onto the string
30
* @return initialString with a file-type string appended
31
*/
32
template
<
typename
T>
33
inline
T&
operator+=
(T& initialString,
const
BmnFileType
fileType)
34
{
35
// I don't think we need a type trait here - various string classes are written differently and might
36
// even be represented as a standard array underneath or non-template classes without internal using declaration
37
switch
(fileType) {
38
case
BmnFileType::Raw
:
39
return
initialString +=
"Raw"
;
40
case
BmnFileType::ZStd
:
41
return
initialString +=
"ZStd"
;
42
case
BmnFileType::ZLib
:
43
return
initialString +=
"ZLib"
;
44
case
BmnFileType::ZLib_ng
:
45
return
initialString +=
"ZLib_ng"
;
46
case
BmnFileType::XZ_LZMA
:
47
return
initialString +=
"XZ_LZMA"
;
48
case
BmnFileType::Unknown
:
49
default
:
50
return
initialString +=
"Unknown"
;
51
}
52
}
53
54
/*
55
* A method that concatenates a string and an enum
56
* @tparam T A string-type parameter that supports operator+= with strings
57
* @param initialString An initial string that should be concatenated with an enum
58
* @param fileType A type of file that should be concatenated with the string
59
* @return A new concatenated string built from initialString and fileType
60
*/
61
template
<
typename
T>
62
[[nodiscard]]
inline
T
operator+
(
const
T& initialString,
const
BmnFileType
fileType)
63
{
64
T aReturnString{initialString};
65
aReturnString += fileType;
66
return
aReturnString;
67
}
68
69
enum class
BmnFileStreamResults
: uint8_t
70
{
71
// Read was successful
72
Success
,
73
// The file read has just reached EOF
74
ReachedEOF
,
75
// Arguments (parameters) passed to a stream function are invalid
76
InvalidParameters
,
77
// Trying to use a file that's in bad state already
78
TryingToReadBadStream
,
79
// Trying to use a file while it's not open
80
FileNotOpen
,
81
// Some unexpected error
82
UnexpectedFail
83
};
84
85
/*
86
* An enum type that tells us how to write/read files. These values always must be set
87
* before an input/output file is open! Otherwise, flags will be just omitted.
88
* @note Different file-processing libraries/systems may require various flags. Flags
89
* that are supported will be consumed, while others will be neglected. For instance,
90
* if a compression library doesn't support various compression levels, setting
91
* `MaximalCompression` will behave as if `DefaultCompression` is set
92
* @warning All files are managed as binaries!
93
*/
94
enum class
BmnBinaryFileProcessingOptions
: uint32_t
95
{
96
// If None, all default parameters will be used
97
None
= 0,
98
// o o o o o o OPEN-MODE FLAGS o o o o o o
99
100
// For writing files
101
WriteBinary
= 1 << 0,
102
// For reading files
103
ReadBinary
= 1 << 1,
104
// Not to remove data before writing a file (if not used, all old data will be lost)
105
LeaveOldData
= 1 << 2,
106
// Useful if LeaveOldData is on and writing into a file. Then, the starting position will be 0
107
StartFromNull
= 1 << 3,
108
// Useful if LeaveOldData is on and writing into a file. Then, the starting position will be at the end of the file
109
StartFromEnd
= 1 << 4,
110
// Forces to always write at the end of the file. Seek position will not work
111
AlwaysWriteAtTheEnd
= 1 << 5,
112
113
// o o o o o o COMPRESSION FLAGS o o o o o o
114
115
// Uses maximal compression strength for writing if the underlying library supports different compression levels.
116
// Compressing might be VERY SLOW!
117
MaximalCompression
= 1 << 6,
118
// Uses increased compression strength for writing if the underlying library supports different compression levels.
119
// Compressing will most likely be slow!
120
HighCompression
= 1 << 7,
121
// Uses increased, but not significantly, compression strength for writing if the underlying library supports
122
// different compression levels.
123
NormalCompression
= 1 << 7,
124
// Uses default compression strength for writing if the underlying library supports different compression levels.
125
DefaultCompression
= 1 << 9,
126
// Uses some lower-level compression strength to improve compression speed, if the underlying library supports
127
// different compression levels.
128
LowCompression
= 1 << 10,
129
// The compression speed will be maximal, but the resulting compression ratio will most likely no be that high.
130
// Usable if the underlying library supports different compression levels.
131
MinimalCompression
= 1 << 11,
132
// Compression will consume a lot of memory - it will be able to look for similar patterns over the bigger portion
133
// of the file. Most likely, this will increase the compression time, while the resulting compression ratio will be
134
// improved. Usable if the underlying library supports this feature.
135
HighCompressionMemory
= 1 << 12,
136
// Compression will consume more memory - it will be able to look for similar patterns over the bigger portion of
137
// the file. Most likely, this will increase the compression time, while the resulting compression ratio will be
138
// improved. Usable if the underlying library supports this feature.
139
IntermediateCompressionMemory
= 1 << 13,
140
// Compression will consume default amount of memory, according to the library specifications. Usable if the
141
// underlying library supports this feature.
142
DefaultCompressionMemory
= 1 << 14,
143
144
// NOTE: additional flags might be added in the future
145
};
146
MAKE_ENUM_BITMASK
(
BmnBinaryFileProcessingOptions
);
147
148
constexpr
BmnBinaryFileProcessingOptions
cg_writeFileFlags
=
149
BmnBinaryFileProcessingOptions::WriteBinary
|
BmnBinaryFileProcessingOptions::LeaveOldData
150
|
BmnBinaryFileProcessingOptions::StartFromNull
|
BmnBinaryFileProcessingOptions::StartFromEnd
151
|
BmnBinaryFileProcessingOptions::AlwaysWriteAtTheEnd
;
152
153
constexpr
BmnBinaryFileProcessingOptions
cg_compressionIntensityFlags
=
154
BmnBinaryFileProcessingOptions::MaximalCompression
|
BmnBinaryFileProcessingOptions::HighCompression
155
|
BmnBinaryFileProcessingOptions::NormalCompression
|
BmnBinaryFileProcessingOptions::DefaultCompression
156
|
BmnBinaryFileProcessingOptions::LowCompression
|
BmnBinaryFileProcessingOptions::MinimalCompression
;
157
158
constexpr
BmnBinaryFileProcessingOptions
cg_compressionMemoryFlags
=
159
BmnBinaryFileProcessingOptions::HighCompressionMemory
160
|
BmnBinaryFileProcessingOptions::IntermediateCompressionMemory
161
|
BmnBinaryFileProcessingOptions::DefaultCompressionMemory
;
162
163
#endif
// BmnFileProcessingFlags_h
BmnEnums.h
Define enumerations used in tracking.
MAKE_ENUM_BITMASK
#define MAKE_ENUM_BITMASK(EnumType)
Definition
BmnEnums.h:20
BmnFileStreamResults
BmnFileStreamResults
Definition
BmnFileProcessingFlags.h:70
BmnFileStreamResults::InvalidParameters
@ InvalidParameters
Definition
BmnFileProcessingFlags.h:76
BmnFileStreamResults::Success
@ Success
Definition
BmnFileProcessingFlags.h:72
BmnFileStreamResults::ReachedEOF
@ ReachedEOF
Definition
BmnFileProcessingFlags.h:74
BmnFileStreamResults::FileNotOpen
@ FileNotOpen
Definition
BmnFileProcessingFlags.h:80
BmnFileStreamResults::UnexpectedFail
@ UnexpectedFail
Definition
BmnFileProcessingFlags.h:82
BmnFileStreamResults::TryingToReadBadStream
@ TryingToReadBadStream
Definition
BmnFileProcessingFlags.h:78
operator+
T operator+(const T &initialString, const BmnFileType fileType)
Definition
BmnFileProcessingFlags.h:62
BmnFileType
BmnFileType
Definition
BmnFileProcessingFlags.h:16
BmnFileType::ZLib
@ ZLib
Definition
BmnFileProcessingFlags.h:20
BmnFileType::Raw
@ Raw
Definition
BmnFileProcessingFlags.h:18
BmnFileType::Unknown
@ Unknown
Definition
BmnFileProcessingFlags.h:17
BmnFileType::XZ_LZMA
@ XZ_LZMA
Definition
BmnFileProcessingFlags.h:22
BmnFileType::ZStd
@ ZStd
Definition
BmnFileProcessingFlags.h:19
BmnFileType::ZLib_ng
@ ZLib_ng
Definition
BmnFileProcessingFlags.h:21
cg_writeFileFlags
constexpr BmnBinaryFileProcessingOptions cg_writeFileFlags
Definition
BmnFileProcessingFlags.h:148
cg_compressionIntensityFlags
constexpr BmnBinaryFileProcessingOptions cg_compressionIntensityFlags
Definition
BmnFileProcessingFlags.h:153
operator+=
T & operator+=(T &initialString, const BmnFileType fileType)
Definition
BmnFileProcessingFlags.h:33
BmnBinaryFileProcessingOptions
BmnBinaryFileProcessingOptions
Definition
BmnFileProcessingFlags.h:95
BmnBinaryFileProcessingOptions::ReadBinary
@ ReadBinary
Definition
BmnFileProcessingFlags.h:103
BmnBinaryFileProcessingOptions::HighCompressionMemory
@ HighCompressionMemory
Definition
BmnFileProcessingFlags.h:135
BmnBinaryFileProcessingOptions::MaximalCompression
@ MaximalCompression
Definition
BmnFileProcessingFlags.h:117
BmnBinaryFileProcessingOptions::AlwaysWriteAtTheEnd
@ AlwaysWriteAtTheEnd
Definition
BmnFileProcessingFlags.h:111
BmnBinaryFileProcessingOptions::IntermediateCompressionMemory
@ IntermediateCompressionMemory
Definition
BmnFileProcessingFlags.h:139
BmnBinaryFileProcessingOptions::StartFromNull
@ StartFromNull
Definition
BmnFileProcessingFlags.h:107
BmnBinaryFileProcessingOptions::LowCompression
@ LowCompression
Definition
BmnFileProcessingFlags.h:128
BmnBinaryFileProcessingOptions::DefaultCompression
@ DefaultCompression
Definition
BmnFileProcessingFlags.h:125
BmnBinaryFileProcessingOptions::HighCompression
@ HighCompression
Definition
BmnFileProcessingFlags.h:120
BmnBinaryFileProcessingOptions::LeaveOldData
@ LeaveOldData
Definition
BmnFileProcessingFlags.h:105
BmnBinaryFileProcessingOptions::None
@ None
Definition
BmnFileProcessingFlags.h:97
BmnBinaryFileProcessingOptions::StartFromEnd
@ StartFromEnd
Definition
BmnFileProcessingFlags.h:109
BmnBinaryFileProcessingOptions::MinimalCompression
@ MinimalCompression
Definition
BmnFileProcessingFlags.h:131
BmnBinaryFileProcessingOptions::NormalCompression
@ NormalCompression
Definition
BmnFileProcessingFlags.h:123
BmnBinaryFileProcessingOptions::DefaultCompressionMemory
@ DefaultCompressionMemory
Definition
BmnFileProcessingFlags.h:142
BmnBinaryFileProcessingOptions::WriteBinary
@ WriteBinary
Definition
BmnFileProcessingFlags.h:101
cg_compressionMemoryFlags
constexpr BmnBinaryFileProcessingOptions cg_compressionMemoryFlags
Definition
BmnFileProcessingFlags.h:158
compression
include
BmnFileProcessingFlags.h
Generated on
for BmnRoot by
1.17.0