31#ifndef ALICEO2_BASE_DATA_HEADER_
32#define ALICEO2_BASE_DATA_HEADER_
93void hexDump(
const char* desc,
const void* voidaddr,
size_t len,
size_t max = 0);
107template <
typename T,
typename... Targs>
110 return (T)
c | String2__<T>(Fargs...) << 8;
114template <
unsigned int N>
124template <
typename T,
int N>
127 return N /
sizeof(T) + ((N %
sizeof(T)) ? 1 : 0);
160template <
typename T,
typename... Targs>
168 static_assert(
sizeof...(Targs) ==
sizeof(T) + 1 ||
169 sizeof...(Targs) ==
sizeof(T),
170 "number of arguments does not match the uint type width");
171 return internal::String2__<T>(
c, Fargs...);
178template <
typename T, std::
size_t N, std::
size_t pos = 0,
bool suppressAssert = false>
181 static_assert(std::is_integral<T>::value,
"Non integral types not compatible with String2<type>");
182 static_assert(N >=
pos,
"Position is larger than the length of string");
183 static_assert(suppressAssert || N -
pos <=
sizeof(T) + 1,
184 "String parameter is longer than the size of the data type");
187 (
sizeof(T) >= 2 &&
str[0 +
pos] ? ((T)
str[1 +
pos] << (
sizeof(T) >= 2 ? 8 : 0) |
188 (
sizeof(T) >= 4 &&
str[1 +
pos] ? ((T)
str[2 +
pos] << (
sizeof(T) >= 4 ? 16 : 0) |
189 (
sizeof(T) >= 4 &&
str[2 +
pos] ? ((T)
str[3 +
pos] << (
sizeof(T) >= 4 ? 24 : 0) |
190 (
sizeof(T) >= 8 &&
str[3 +
pos] ? ((T)
str[4 +
pos] << (
sizeof(T) >= 8 ? 32 : 0) |
191 (
sizeof(T) >= 8 &&
str[4 +
pos] ? ((T)
str[5 +
pos] << (
sizeof(T) >= 8 ? 40 : 0) |
192 (
sizeof(T) >= 8 &&
str[5 +
pos] ? ((T)
str[6 +
pos] << (
sizeof(T) >= 8 ? 48 : 0) |
193 (
sizeof(T) >= 8 &&
str[6 +
pos] ? ((T)
str[7 +
pos] << (
sizeof(T) >= 8 ? 56 : 0))
194 : 0)) : 0)) : 0)) : 0)) : 0)) : 0)) : 0));
205template <std::
size_t N>
208 "Descriptor size is required to be a power of 2");
212 static constexpr int arraySize = internal::ArraySize<uint64_t, size>();
232 if constexpr (std::is_same_v<ImplicitConversion, ItgType>) {
239 return std::string_view(
str,
len);
244 template <std::
size_t L>
247 static_assert(L <= N + 1,
"initializer string must not exceed descriptor size");
249 for (;
i < (N < L ? N : L) && in[
i]; ++
i) {
263 if (!
string.
empty() && (
string.
size() > (
int)N)) {
264 throw std::invalid_argument(
"argument must not be longer than the descriptor size");
269 auto*
ptr =
str +
string.size();
296 template <
typename T>
298 template <
typename T>
302 template <
typename T>
303 requires(std::same_as<T, std::string>)
313 std::string ret(
str,
len);
410 return (
b !=
nullptr && *(
reinterpret_cast<const uint32_t*
>(
b)) ==
sMagicString)
425 inline const std::byte*
data() const noexcept {
return reinterpret_cast<const std::byte*
>(
this); }
456template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value,
int> = 0>
459 using HeaderConstPtrType =
const typename std::remove_pointer<HeaderType>::type*;
460 using HeaderValueType =
typename std::remove_pointer<HeaderType>::type;
464 return HeaderConstPtrType{
nullptr};
466 if (current->
description == HeaderValueType::sHeaderType) {
473 if (current->
sanityCheck(HeaderValueType::sVersion)) {
474 return reinterpret_cast<HeaderConstPtrType
>(current);
477 auto* prev = current;
478 while ((current = current->
next())) {
480 if (current->
description == HeaderValueType::sHeaderType) {
481 if (current->
sanityCheck(HeaderValueType::sVersion)) {
482 return reinterpret_cast<HeaderConstPtrType
>(current);
489 if (prev->flagsNextHeader) {
492 return HeaderConstPtrType{
nullptr};
495template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value,
int> = 0>
498 return get<HeaderType>(
reinterpret_cast<const std::byte*
>(
buffer),
len);
508 static_assert(std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed,
509 "Target must be an unsigned integer type");
511 if constexpr (
sizeof(T) <=
sizeof(uint32_t)) {
512 unsigned long res = strtoul(
str, str_end, base);
513 if (
res > std::numeric_limits<T>::max()) {
515 return std::numeric_limits<T>::max();
517 return static_cast<T
>(
res);
520 unsigned long long res = strtoull(
str, str_end, base);
521 if (
res > std::numeric_limits<T>::max()) {
523 return std::numeric_limits<T>::max();
525 return static_cast<T
>(
res);
531T
stoui(
const std::string&
str,
size_t*
pos =
nullptr,
int base = 10)
533 static_assert(std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed,
534 "Target must be an unsigned integer type");
536 if constexpr (
sizeof(T) <=
sizeof(uint32_t)) {
537 unsigned long res = std::stoul(
str,
pos, base);
538 if (
res > std::numeric_limits<T>::max()) {
539 throw std::out_of_range(
"result does not fit in target type");
541 return static_cast<T
>(
res);
544 unsigned long long res = std::stoull(
str,
pos, base);
545 if (
res > std::numeric_limits<T>::max()) {
546 throw std::out_of_range(
"result does not fit in target type");
548 return static_cast<T
>(
res);
768 template <std::
size_t N, std::
size_t M>
781 "HeaderType struct must be of size 8");
783 "SerializationMethod struct must be of size 8");
785 "BaseHeader struct must be of size 32");
787 "DataOrigin struct must be of size 4");
789 "DataHeader struct must be of size 96");
791 "Size mismatch in magic string union");
793 "Inconsitent size of global magic identifier");
799template <std::
size_t S>
header::DataOrigin origin
GLsizei const GLchar *const * string
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLuint GLsizei GLsizei * length
GLenum GLenum GLsizei len
constexpr o2::header::DataOrigin gDataOriginPHS
constexpr o2::header::DataOrigin gDataOriginMFT
constexpr o2::header::DataOrigin gDataOriginMCH
constexpr o2::header::DataDescription gDataDescriptionInvalid
constexpr o2::header::DataOrigin gDataOriginCTP
constexpr o2::header::DataOrigin gDataOriginFLP
constexpr o2::header::DataOrigin gDataOriginIT3
constexpr o2::header::DataOrigin gDataOriginTST
constexpr o2::header::DataDescription gDataDescriptionInfo
constexpr o2::header::DataOrigin gDataOriginMI3
constexpr o2::header::DataOrigin gDataOriginTRK
constexpr o2::header::DataOrigin gDataOriginHMP
constexpr o2::header::DataOrigin gDataOriginTPC
constexpr o2::header::DataOrigin gDataOriginACO
constexpr o2::header::DataDescription gDataDescriptionROOTStreamers
constexpr o2::header::DataOrigin gDataOriginFOC
constexpr o2::header::DataOrigin gDataOriginFCT
constexpr o2::header::DataOrigin gDataOriginFT3
constexpr o2::header::DataOrigin gDataOriginZDC
constexpr o2::header::DataDescription gDataDescriptionTracks
constexpr o2::header::DataOrigin gDataOriginInvalid
constexpr o2::header::DataDescription gDataDescriptionEos
constexpr o2::header::DataOrigin gDataOriginRCH
constexpr o2::header::DataDescription gDataDescriptionConfig
constexpr o2::header::DataOrigin gDataOriginMID
constexpr o2::header::DataOrigin gDataOriginECL
constexpr o2::header::DataOrigin gDataOriginFDD
constexpr o2::header::DataDescription gDataDescriptionRawData
constexpr o2::header::DataOrigin gDataOriginFT0
constexpr o2::header::DataOrigin gDataOriginTRD
constexpr o2::header::DataOrigin gDataOriginEMC
constexpr o2::header::DataOrigin gDataOriginTF3
constexpr o2::header::DataOrigin gDataOriginTOF
constexpr o2::header::DataOrigin gDataOriginITS
constexpr o2::header::DataOrigin gDataOriginCPV
constexpr o2::header::DataOrigin gDataOriginAny
constexpr o2::header::DataDescription gDataDescriptionClusters
constexpr o2::header::DataOrigin gDataOriginFD3
constexpr o2::header::DataOrigin gDataOriginFV0
constexpr o2::header::DataDescription gDataDescriptionAny
constexpr o2::header::DataOrigin gDataOriginGPU
constexpr o2::header::DataDescription gDataDescriptionDISTSTF
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other