31#ifndef ALICEO2_BASE_DATA_HEADER_
32#define ALICEO2_BASE_DATA_HEADER_
94void hexDump(
const char* desc,
const void* voidaddr,
size_t len,
size_t max = 0);
108template <
typename T,
typename... Targs>
111 return (T)
c | String2__<T>(Fargs...) << 8;
115template <
unsigned int N>
125template <
typename T,
int N>
128 return N /
sizeof(T) + ((N %
sizeof(T)) ? 1 : 0);
161template <
typename T,
typename... Targs>
169 static_assert(
sizeof...(Targs) ==
sizeof(T) + 1 ||
170 sizeof...(Targs) ==
sizeof(T),
171 "number of arguments does not match the uint type width");
172 return internal::String2__<T>(
c, Fargs...);
179template <
typename T, std::
size_t N, std::
size_t pos = 0,
bool suppressAssert = false>
182 static_assert(std::is_integral<T>::value,
"Non integral types not compatible with String2<type>");
183 static_assert(N >=
pos,
"Position is larger than the length of string");
184 static_assert(suppressAssert || N -
pos <=
sizeof(T) + 1,
185 "String parameter is longer than the size of the data type");
188 (
sizeof(T) >= 2 &&
str[0 +
pos] ? ((T)
str[1 +
pos] << (
sizeof(T) >= 2 ? 8 : 0) |
189 (
sizeof(T) >= 4 &&
str[1 +
pos] ? ((T)
str[2 +
pos] << (
sizeof(T) >= 4 ? 16 : 0) |
190 (
sizeof(T) >= 4 &&
str[2 +
pos] ? ((T)
str[3 +
pos] << (
sizeof(T) >= 4 ? 24 : 0) |
191 (
sizeof(T) >= 8 &&
str[3 +
pos] ? ((T)
str[4 +
pos] << (
sizeof(T) >= 8 ? 32 : 0) |
192 (
sizeof(T) >= 8 &&
str[4 +
pos] ? ((T)
str[5 +
pos] << (
sizeof(T) >= 8 ? 40 : 0) |
193 (
sizeof(T) >= 8 &&
str[5 +
pos] ? ((T)
str[6 +
pos] << (
sizeof(T) >= 8 ? 48 : 0) |
194 (
sizeof(T) >= 8 &&
str[6 +
pos] ? ((T)
str[7 +
pos] << (
sizeof(T) >= 8 ? 56 : 0))
195 : 0)) : 0)) : 0)) : 0)) : 0)) : 0)) : 0));
206template <std::
size_t N>
209 "Descriptor size is required to be a power of 2");
213 static constexpr int arraySize = internal::ArraySize<uint64_t, size>();
233 if constexpr (std::is_same_v<ImplicitConversion, ItgType>) {
240 return std::string_view(
str,
len);
245 template <std::
size_t L>
248 static_assert(L <= N + 1,
"initializer string must not exceed descriptor size");
250 for (;
i < (N < L ? N : L) && in[
i]; ++
i) {
281 throw std::invalid_argument(
"argument must not be longer than descriptor size");
294 template <
typename T>
296 template <
typename T>
300 template <
typename T>
301 std::enable_if_t<std::is_same<T, std::string>::value ==
true, T>
as()
const
310 std::string ret(
str,
len);
407 return (
b !=
nullptr && *(
reinterpret_cast<const uint32_t*
>(
b)) ==
sMagicString)
422 inline const std::byte*
data() const noexcept {
return reinterpret_cast<const std::byte*
>(
this); }
453template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value,
int> = 0>
456 using HeaderConstPtrType =
const typename std::remove_pointer<HeaderType>::type*;
457 using HeaderValueType =
typename std::remove_pointer<HeaderType>::type;
461 return HeaderConstPtrType{
nullptr};
463 if (current->
description == HeaderValueType::sHeaderType) {
470 if (current->
sanityCheck(HeaderValueType::sVersion)) {
471 return reinterpret_cast<HeaderConstPtrType
>(current);
474 auto* prev = current;
475 while ((current = current->
next())) {
477 if (current->
description == HeaderValueType::sHeaderType) {
478 if (current->
sanityCheck(HeaderValueType::sVersion)) {
479 return reinterpret_cast<HeaderConstPtrType
>(current);
486 if (prev->flagsNextHeader) {
489 return HeaderConstPtrType{
nullptr};
492template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value,
int> = 0>
495 return get<HeaderType>(
reinterpret_cast<const std::byte*
>(
buffer),
len);
505 static_assert(std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed,
506 "Target must be an unsigned integer type");
508 if constexpr (
sizeof(T) <=
sizeof(uint32_t)) {
509 unsigned long res = strtoul(
str, str_end, base);
510 if (
res > std::numeric_limits<T>::max()) {
512 return std::numeric_limits<T>::max();
514 return static_cast<T
>(
res);
517 unsigned long long res = strtoull(
str, str_end, base);
518 if (
res > std::numeric_limits<T>::max()) {
520 return std::numeric_limits<T>::max();
522 return static_cast<T
>(
res);
528T
stoui(
const std::string&
str,
size_t*
pos =
nullptr,
int base = 10)
530 static_assert(std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed,
531 "Target must be an unsigned integer type");
533 if constexpr (
sizeof(T) <=
sizeof(uint32_t)) {
534 unsigned long res = std::stoul(
str,
pos, base);
535 if (
res > std::numeric_limits<T>::max()) {
536 throw std::out_of_range(
"result does not fit in target type");
538 return static_cast<T
>(
res);
541 unsigned long long res = std::stoull(
str,
pos, base);
542 if (
res > std::numeric_limits<T>::max()) {
543 throw std::out_of_range(
"result does not fit in target type");
545 return static_cast<T
>(
res);
763 template <std::
size_t N, std::
size_t M>
776 "HeaderType struct must be of size 8");
778 "SerializationMethod struct must be of size 8");
780 "BaseHeader struct must be of size 32");
782 "DataOrigin struct must be of size 4");
784 "DataHeader struct must be of size 96");
786 "Size mismatch in magic string union");
788 "Inconsitent size of global magic identifier");
794template <std::
size_t S>
GLsizei const GLchar *const * string
GLboolean GLboolean GLboolean b
GLsizei GLsizei GLchar * source
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::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 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