BmnRoot 26.10.0-233-gb9bbe585
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 */
25
26/*
27 * A method that appends an enum into a string
28 * @tparam T A string-type parameter that supports operator+= with strings
29 * @param initialString A string onto which a file type will be appended
30 * @param fileType A type of file that should be appended onto the string
31 * @return initialString with a file-type string appended
32 */
33template<typename T>
34inline T& operator+=(T& initialString, const BmnFileType fileType)
35{
36 // I don't think we need a type trait here - various string classes are written differently and might
37 // even be represented as a standard array underneath or non-template classes without internal using declaration
38 switch (fileType) {
40 return initialString += "Raw";
42 return initialString += "ZStd";
44 return initialString += "ZLib";
46 return initialString += "ZLib_ng";
48 return initialString += "XZ_LZMA";
50 return initialString += "BZip3";
52 [[fallthrough]];
53 default:
54 return initialString += "Unknown";
55 }
56}
57
58/*
59 * A method that concatenates a string and an enum
60 * @tparam T A string-type parameter that supports operator+= with strings
61 * @param initialString An initial string that should be concatenated with an enum
62 * @param fileType A type of file that should be concatenated with the string
63 * @return A new concatenated string built from initialString and fileType
64 */
65template<typename T>
66[[nodiscard]] inline T operator+(const T& initialString, const BmnFileType fileType)
67{
68 T aReturnString{initialString};
69 aReturnString += fileType;
70 return aReturnString;
71}
72
73enum class BmnFileStreamResults : uint8_t
74{
75 // Read was successful
77 // The file read has just reached EOF
79 // Arguments (parameters) passed to a stream function are invalid
81 // Trying to use a file that's in bad state already
83 // Trying to use a file while it's not open
85 // Some unexpected error
87};
88
89/*
90 * An enum type that tells us how to write/read files. These values always must be set
91 * before an input/output file is open! Otherwise, flags will be just omitted.
92 * @note Different file-processing libraries/systems may require various flags. Flags
93 * that are supported will be consumed, while others will be neglected. For instance,
94 * if a compression library doesn't support various compression levels, setting
95 * `MaximalCompression` will behave as if `DefaultCompression` is set
96 * @warning All files are managed as binaries!
97 */
98enum class BmnCompressionWritingFlags : uint32_t
99{
100 // If None, all default parameters will be used
101 None = 0,
102 // o o o o o o OPEN-MODE FLAGS o o o o o o
103
104 // Not to remove data before writing a file (if not used, all old data will be lost)
105 LeaveOldData = 1 << 0,
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 << 2,
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.
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
156
157#endif // BmnFileProcessingFlags_h
Define enumerations used in tracking.
#define MAKE_ENUM_BITMASK(EnumType)
Definition BmnEnums.h:20
T operator+(const T &initialString, const BmnFileType fileType)
constexpr BmnCompressionWritingFlags cg_compressionMemoryFlags
BmnCompressionWritingFlags
T & operator+=(T &initialString, const BmnFileType fileType)
constexpr BmnCompressionWritingFlags cg_compressionIntensityFlags