BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
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 */
15enum class BmnFileType : uint8_t
16{
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 */
32template<typename T>
33inline 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) {
39 return initialString += "Raw";
41 return initialString += "ZStd";
43 return initialString += "ZLib";
45 return initialString += "ZLib_ng";
47 return initialString += "XZ_LZMA";
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 */
61template<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
69enum class BmnFileStreamResults : uint8_t
70{
71 // Read was successful
73 // The file read has just reached EOF
75 // Arguments (parameters) passed to a stream function are invalid
77 // Trying to use a file that's in bad state already
79 // Trying to use a file while it's not open
81 // Some unexpected error
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 */
94enum 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
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
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!
118 // Uses increased compression strength for writing if the underlying library supports different compression levels.
119 // Compressing will most likely be slow!
121 // Uses increased, but not significantly, compression strength for writing if the underlying library supports
122 // different compression levels.
124 // Uses default compression strength for writing if the underlying library supports different compression levels.
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.
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.
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.
140 // Compression will consume default amount of memory, according to the library specifications. Usable if the
141 // underlying library supports this feature.
143
144 // NOTE: additional flags might be added in the future
145};
147
152
157
162
163#endif // BmnFileProcessingFlags_h
#define MAKE_ENUM_BITMASK(EnumType)
Definition BmnEnums.h:20
T operator+(const T &initialString, const BmnFileType fileType)
constexpr BmnBinaryFileProcessingOptions cg_writeFileFlags
constexpr BmnBinaryFileProcessingOptions cg_compressionIntensityFlags
T & operator+=(T &initialString, const BmnFileType fileType)
BmnBinaryFileProcessingOptions
constexpr BmnBinaryFileProcessingOptions cg_compressionMemoryFlags