Project
Loading...
Searching...
No Matches
DataHeader.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
23
30
31#ifndef ALICEO2_BASE_DATA_HEADER_
32#define ALICEO2_BASE_DATA_HEADER_
33
34#include <cstddef>
35#include <cstdint>
36#include <memory>
37#include <cassert>
38#include <cstring> //needed for memcmp
39#include <string>
40#include <stdexcept>
41#include <limits>
42#include <cerrno>
43
44namespace o2::header
45{
46
47//__________________________________________________________________________________________________
52
53//__________________________________________________________________________________________________
63
64//__________________________________________________________________________________________________
73
75constexpr uint32_t gSizeMagicString = 4;
77constexpr uint32_t gSizeDataOriginString = 4;
79constexpr uint32_t gSizeSerializationMethodString = 8;
81constexpr uint32_t gSizeDataDescriptionString = 16;
83constexpr uint32_t gSizeHeaderDescriptionString = 8;
84
86
87//__________________________________________________________________________________________________
88struct DataHeader;
89struct DataIdentifier;
90
91//__________________________________________________________________________________________________
93void hexDump(const char* desc, const void* voidaddr, size_t len, size_t max = 0);
94
95//__________________________________________________________________________________________________
96// internal implementations
98namespace internal
99{
100// terminating initializer implementation
101template <typename T>
102constexpr T String2__()
103{
104 return 0;
105}
106// recursive initializer implementation
107template <typename T, typename... Targs>
108constexpr T String2__(char c, Targs... Fargs)
109{
110 return (T)c | String2__<T>(Fargs...) << 8;
111}
112
114template <unsigned int N>
116 static int const value = NumberOfActiveBits<(N >> 1)>::value + (N & 0x1);
117};
118template <>
120 static int const value = 0;
121};
122
124template <typename T, int N>
125constexpr int ArraySize()
126{
127 return N / sizeof(T) + ((N % sizeof(T)) ? 1 : 0);
128}
129
131template <int N>
133 using Type = uint64_t;
134};
135template <>
136struct TraitsIntType<1> {
137 using Type = uint8_t;
138};
139template <>
140struct TraitsIntType<2> {
141 using Type = uint16_t;
142};
143template <>
144struct TraitsIntType<4> {
145 using Type = uint32_t;
146};
147
150template <int N>
151constexpr std::size_t strLength(const char (&str)[N], std::size_t pos = 0)
152{
153 return ((pos >= N || str[pos] == 0) ? 0 : 1 + strLength(str, pos + 1));
154}
155}; // namespace internal
156
157//__________________________________________________________________________________________________
160template <typename T, typename... Targs>
161constexpr T String2(char c, Targs... Fargs)
162{
163 // number of arguments has either to match the size of the type, or the last element is treated
164 // as '0' if missing
165 // TODO: this is a bit of a question, do we allow the number of characters to
166 // be smaller than the size of the type and just pad with 0 like in the case
167 // of a char array argument?
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...);
172}
173
178template <typename T, std::size_t N, std::size_t pos = 0, bool suppressAssert = false>
179constexpr T String2(const char (&str)[N])
180{
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");
185 // clang-format off
186 return ((T)str[0 + pos] |
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));
195 // clang-format on
196}
197
198//__________________________________________________________________________________________________
205template <std::size_t N>
208 "Descriptor size is required to be a power of 2");
210 static int constexpr size = N;
211 static int constexpr bitcount = size * 8;
212 static constexpr int arraySize = internal::ArraySize<uint64_t, size>();
214
215 union {
216 char str[N];
218 };
219 constexpr Descriptor() : itg{0} {};
220 constexpr Descriptor(ItgType initializer) : itg{initializer} {};
221 constexpr Descriptor(const Descriptor& other) = default;
223
224 // Note: don't need to define operator=(ItgType v) because the compiler
225 // can use Descriptor(ItgType initializer) for conversion
226 using ImplicitConversion = std::conditional_t<(size <= 8), ItgType, std::string_view>;
227
228 // type cast operator for simplified usage of the descriptor's integer member
229 // in case it does not fit into the descriptor, the string representation is returned
230 operator ImplicitConversion() const
231 {
232 if constexpr (std::is_same_v<ImplicitConversion, ItgType>) {
233 return itg[0];
234 } else {
235 size_t len = size;
236 while (len > 1 && str[len - 1] == 0) {
237 --len;
238 }
239 return std::string_view(str, len);
240 }
241 }
242
244 template <std::size_t L>
245 constexpr Descriptor(const char (&in)[L]) : str{0}
246 {
247 static_assert(L <= N + 1, "initializer string must not exceed descriptor size");
248 unsigned i = 0;
249 for (; i < (N < L ? N : L) && in[i]; ++i) {
250 str[i] = in[i];
251 }
252 }
253
260 void runtimeInit(std::string_view string)
261 {
262 // empty strings and string longet than the descriptor size are not allowed
263 if (!string.empty() && (string.size() > (int)N)) {
264 throw std::invalid_argument("argument must not be longer than the descriptor size");
265 }
266 // copy the content directly
267 std::memcpy(str, string.data(), string.size());
268 // nullify the remainder
269 auto* ptr = str + string.size();
270 for (; ptr < str + N; ++ptr) {
271 *ptr = 0;
272 }
273 }
274
276 void runtimeInit(const char* string)
277 {
278 runtimeInit(std::string_view{string, std::strlen(string)});
279 }
280
282 void runtimeInit(const char* buffer, size_t length)
283 {
284 runtimeInit(std::string_view{buffer, length});
285 }
286
287 bool operator==(const Descriptor& other) const { return std::memcmp(this->str, other.str, N) == 0; }
288 bool operator<(const Descriptor& other) const { return std::memcmp(this->str, other.str, N) < 0; }
289 bool operator!=(const Descriptor& other) const { return not this->operator==(other); }
290
291 // Convesion operators for comparison with their implicitly convertible types
292 friend bool operator==(const Descriptor& lhs, ImplicitConversion rhs) { return static_cast<ImplicitConversion>(lhs) == rhs; }
293 // explicitly forbid comparison with e.g. const char* strings
294 // use: value == Descriptor<N>("DESC") for the appropriate
295 // template instantiation instead
296 template <typename T>
297 bool operator==(const T*) const = delete;
298 template <typename T>
299 bool operator!=(const T*) const = delete;
300
302 template <typename T>
303 requires(std::same_as<T, std::string>)
304 T as() const
305 {
306 // backward search to find first non-zero char
307 // FIXME: can optimize this by using the int value to start at e.g. size/2
308 // if the upper part of the string is just zeros.
309 size_t len = size;
310 while (len > 1 && str[len - 1] == 0) {
311 --len;
312 }
313 std::string ret(str, len);
314 return ret;
315 }
316};
317
318//__________________________________________________________________________________________________
320const uint32_t gInvalidToken32 = 0xFFFFFFFF;
322const uint64_t gInvalidToken64 = 0xFFFFFFFFFFFFFFFF;
323
326
327// possible serialization types
335
336//__________________________________________________________________________________________________
355 // static definitions
356 static constexpr uint32_t sMagicString{String2<uint32_t>("O2O2")};
357
358 static const uint32_t sVersion;
361
362 //__the data layout:
363
365 union {
368 };
369
372 uint32_t headerSize;
373
375 union {
376 uint32_t flags;
377 struct {
378 uint32_t flagsNextHeader : 1, // do we have a next header after this one?
379 flagsReserved : 15, // reserved for future use
380 flagsDerivedHeader : 16; // reserved for usage by the derived header
381 };
382 };
383
386
389
392
393 //___the functions:
394
396 BaseHeader() = delete;
397 BaseHeader(const BaseHeader&) = default;
399 constexpr BaseHeader(uint32_t mySize, HeaderType desc,
400 SerializationMethod ser, uint32_t version)
402 {
403 }
404
408 inline static const BaseHeader* get(const std::byte* b, size_t /*len*/ = 0)
409 {
410 return (b != nullptr && *(reinterpret_cast<const uint32_t*>(b)) == sMagicString)
411 ? reinterpret_cast<const BaseHeader*>(b)
412 : nullptr;
413 }
414
418 inline static BaseHeader* get(std::byte* b, size_t /*len*/ = 0)
419 {
420 return (b != nullptr && *(reinterpret_cast<uint32_t*>(b)) == sMagicString) ? reinterpret_cast<BaseHeader*>(b)
421 : nullptr;
422 }
423
424 constexpr uint32_t size() const noexcept { return headerSize; }
425 inline const std::byte* data() const noexcept { return reinterpret_cast<const std::byte*>(this); }
426
428 inline const BaseHeader* next() const noexcept
429 {
430 // BaseHeader::get checks that next header starts with the BaseHeader information at the
431 // offset given by the size of the current header.
432 return (flagsNextHeader) ? BaseHeader::get(reinterpret_cast<const std::byte*>(this) + headerSize) : nullptr;
433 }
434
436 inline BaseHeader* next() noexcept
437 {
438 return (flagsNextHeader) ? BaseHeader::get(reinterpret_cast<std::byte*>(this) + headerSize) : nullptr;
439 }
440
446 bool sanityCheck(uint32_t expectedVersion) const;
447
450 void throwInconsistentStackError() const;
451};
452
456template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value, int> = 0>
457auto get(const std::byte* buffer, size_t /*len*/ = 0)
458{
459 using HeaderConstPtrType = const typename std::remove_pointer<HeaderType>::type*;
460 using HeaderValueType = typename std::remove_pointer<HeaderType>::type;
461
462 const BaseHeader* current = BaseHeader::get(buffer);
463 if (!current) {
464 return HeaderConstPtrType{nullptr};
465 }
466 if (current->description == HeaderValueType::sHeaderType) {
467 // FIXME: We need to think how to handle multiple versions.
468 // For the moment we require the version to exactly match the expected version, which
469 // is part of the header definition. The check function 'sanityCheck' will throw
470 // otherwise, we keep the code related to the exception outside the header file.
471 // Note: Can not check on size because the O2 data model requires variable size headers
472 // to be supported.
473 if (current->sanityCheck(HeaderValueType::sVersion)) {
474 return reinterpret_cast<HeaderConstPtrType>(current);
475 }
476 }
477 auto* prev = current;
478 while ((current = current->next())) {
479 prev = current;
480 if (current->description == HeaderValueType::sHeaderType) {
481 if (current->sanityCheck(HeaderValueType::sVersion)) {
482 return reinterpret_cast<HeaderConstPtrType>(current);
483 }
484 }
485 }
486 // if a next header was expected but not found, the header stack is inconsistent
487 // either the flag is wrongly set, or the size of the current header is wrong so
488 // that the BaseHeader information is not found at the expected offset.
489 if (prev->flagsNextHeader) {
491 }
492 return HeaderConstPtrType{nullptr};
493}
494
495template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value, int> = 0>
496auto get(const void* buffer, size_t len = 0)
497{
498 return get<HeaderType>(reinterpret_cast<const std::byte*>(buffer), len);
499}
500
501//__________________________________________________________________________________________________
502// utilities for converting strings to ints - tries to mimick the stadard API, but the result is
503// strongly typed - can be used for fixed width and short unsigned integer types unlike the standard
504// utilities.
505template <typename T>
506T strtoui(const char* str, char** str_end, int base) noexcept
507{
508 static_assert(std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed,
509 "Target must be an unsigned integer type");
510 // standard lib gives us 2 specializations of strtouX, so let's use them both where appropriate
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()) {
514 errno = ERANGE;
515 return std::numeric_limits<T>::max();
516 } else {
517 return static_cast<T>(res);
518 };
519 } else {
520 unsigned long long res = strtoull(str, str_end, base);
521 if (res > std::numeric_limits<T>::max()) {
522 errno = ERANGE;
523 return std::numeric_limits<T>::max();
524 } else {
525 return static_cast<T>(res);
526 };
527 }
528};
529
530template <typename T>
531T stoui(const std::string& str, size_t* pos = nullptr, int base = 10)
532{
533 static_assert(std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed,
534 "Target must be an unsigned integer type");
535 // standard lib gives us 2 specializations of stouX, so let's use them both where appropriate
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");
540 } else {
541 return static_cast<T>(res);
542 };
543 } else {
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");
547 } else {
548 return static_cast<T>(res);
549 };
550 }
551};
552
555
556//__________________________________________________________________________________________________
560
561//__________________________________________________________________________________________________
562// possible data origins
583constexpr o2::header::DataOrigin gDataOriginACO{"ACO"}; // for bwd compatibility with DD
584
593constexpr o2::header::DataOrigin gDataOriginECL{"ECL"}; // upgrades
594constexpr o2::header::DataOrigin gDataOriginFD3{"FD3"}; // upgrades
595
597
598// possible data types
610
611//__________________________________________________________________________________________________
623struct DataHeader : public BaseHeader {
624 // allows DataHeader::SubSpecificationType to be used as generic type in the code
625 using SubSpecificationType = uint32_t;
626 using SplitPayloadIndexType = uint32_t;
627 using SplitPayloadPartsType = uint32_t;
628 using PayloadSizeType = uint64_t;
629 using TForbitType = uint32_t;
630 using TFCounterType = uint32_t;
631 using RunNumberType = uint32_t;
632
633 // static data for this header type/version
634 static constexpr uint32_t sVersion{3};
635 static constexpr o2::header::HeaderType sHeaderType{String2<uint64_t>("DataHead")};
637
642
647
652
657
662
667
672
673 //___NEVER MODIFY THE ABOVE
674 //___NEW STUFF GOES BELOW
675
680
685
690
691 //___the functions:
692 //__________________________________________________________________________________________________
707
708 //__________________________________________________________________________________________________
723
724 //__________________________________________________________________________________________________
739
740 DataHeader(const DataHeader&) = default;
741 DataHeader& operator=(const DataHeader&) = default; // assignment
742
743 bool operator==(const DataHeader&) const; // comparison
744 bool operator==(const DataOrigin&) const; // comparison
745 bool operator==(const DataDescription&) const; // comparison
746 bool operator==(const SerializationMethod&) const; // comparison
747
748 static const DataHeader* Get(const BaseHeader* baseHeader)
749 {
750 return (baseHeader->description == DataHeader::sHeaderType) ? static_cast<const DataHeader*>(baseHeader) : nullptr;
751 }
752};
753
754//__________________________________________________________________________________________________
763 // a full data identifier combining origin and description
768 template <std::size_t N, std::size_t M>
769 DataIdentifier(const char (&desc)[N], const char (&origin)[M])
771 {
772 }
773
774 bool operator==(const DataIdentifier&) const;
775};
776
777//__________________________________________________________________________________________________
780static_assert(sizeof(HeaderType) == 8,
781 "HeaderType struct must be of size 8");
782static_assert(sizeof(SerializationMethod) == 8,
783 "SerializationMethod struct must be of size 8");
784static_assert(sizeof(BaseHeader) == 32,
785 "BaseHeader struct must be of size 32");
786static_assert(sizeof(DataOrigin) == 4,
787 "DataOrigin struct must be of size 4");
788static_assert(sizeof(DataHeader) == 96,
789 "DataHeader struct must be of size 96");
790static_assert(gSizeMagicString == sizeof(BaseHeader::magicStringInt),
791 "Size mismatch in magic string union");
792static_assert(sizeof(BaseHeader::sMagicString) == sizeof(BaseHeader::magicStringInt),
793 "Inconsitent size of global magic identifier");
794
795template <typename T>
796struct is_descriptor : std::false_type {
797};
798
799template <std::size_t S>
800struct is_descriptor<o2::header::Descriptor<S>> : std::true_type {
801};
802
803} // namespace o2::header
804
805#endif
header::DataOrigin origin
int32_t i
uint16_t pos
Definition RawData.h:3
uint32_t res
Definition RawData.h:0
uint32_t c
Definition RawData.h:2
uint32_t version
Definition RawData.h:8
TBranch * ptr
GLsizei const GLchar *const * string
Definition glcorearb.h:809
GLuint buffer
Definition glcorearb.h:655
GLsizeiptr size
Definition glcorearb.h:659
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLboolean * data
Definition glcorearb.h:298
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
GLbitfield flags
Definition glcorearb.h:1570
GLenum GLenum GLsizei len
Definition glcorearb.h:4232
constexpr o2::header::DataOrigin gDataOriginPHS
Definition DataHeader.h:577
constexpr o2::header::DataOrigin gDataOriginMFT
Definition DataHeader.h:575
constexpr o2::header::DataOrigin gDataOriginMCH
Definition DataHeader.h:574
constexpr o2::header::DataDescription gDataDescriptionInvalid
Definition DataHeader.h:600
constexpr o2::header::DataOrigin gDataOriginCTP
Definition DataHeader.h:567
constexpr o2::header::DataOrigin gDataOriginFLP
Definition DataHeader.h:565
constexpr o2::header::DataOrigin gDataOriginIT3
Definition DataHeader.h:585
constexpr o2::header::DataOrigin gDataOriginTST
Definition DataHeader.h:582
constexpr o2::header::DataDescription gDataDescriptionInfo
Definition DataHeader.h:605
constexpr o2::header::DataOrigin gDataOriginMI3
Definition DataHeader.h:592
constexpr o2::header::DataOrigin gDataOriginTRK
Definition DataHeader.h:587
constexpr o2::header::DataOrigin gDataOriginHMP
Definition DataHeader.h:572
constexpr o2::header::DataOrigin gDataOriginTPC
Definition DataHeader.h:579
constexpr o2::header::DataOrigin gDataOriginACO
Definition DataHeader.h:583
constexpr o2::header::DataDescription gDataDescriptionROOTStreamers
Definition DataHeader.h:607
constexpr o2::header::DataOrigin gDataOriginFOC
Definition DataHeader.h:586
constexpr o2::header::DataOrigin gDataOriginFCT
Definition DataHeader.h:589
constexpr o2::header::DataOrigin gDataOriginFT3
Definition DataHeader.h:588
constexpr o2::header::DataOrigin gDataOriginZDC
Definition DataHeader.h:581
constexpr o2::header::DataDescription gDataDescriptionTracks
Definition DataHeader.h:603
constexpr o2::header::DataOrigin gDataOriginInvalid
Definition DataHeader.h:564
constexpr o2::header::DataDescription gDataDescriptionEos
Definition DataHeader.h:606
constexpr o2::header::DataOrigin gDataOriginRCH
Definition DataHeader.h:591
constexpr o2::header::DataDescription gDataDescriptionConfig
Definition DataHeader.h:604
constexpr o2::header::DataOrigin gDataOriginMID
Definition DataHeader.h:576
constexpr o2::header::DataOrigin gDataOriginECL
Definition DataHeader.h:593
constexpr o2::header::DataOrigin gDataOriginFDD
Definition DataHeader.h:571
constexpr o2::header::DataDescription gDataDescriptionRawData
Definition DataHeader.h:601
constexpr o2::header::DataOrigin gDataOriginFT0
Definition DataHeader.h:569
constexpr o2::header::DataOrigin gDataOriginTRD
Definition DataHeader.h:580
constexpr o2::header::DataOrigin gDataOriginEMC
Definition DataHeader.h:568
constexpr o2::header::DataOrigin gDataOriginTF3
Definition DataHeader.h:590
constexpr o2::header::DataOrigin gDataOriginTOF
Definition DataHeader.h:578
constexpr o2::header::DataOrigin gDataOriginITS
Definition DataHeader.h:573
constexpr o2::header::DataOrigin gDataOriginCPV
Definition DataHeader.h:566
constexpr o2::header::DataOrigin gDataOriginAny
Definition DataHeader.h:563
constexpr o2::header::DataDescription gDataDescriptionClusters
Definition DataHeader.h:602
constexpr o2::header::DataOrigin gDataOriginFD3
Definition DataHeader.h:594
constexpr o2::header::DataOrigin gDataOriginFV0
Definition DataHeader.h:570
constexpr o2::header::DataDescription gDataDescriptionAny
Definition DataHeader.h:599
constexpr o2::header::DataOrigin gDataOriginGPU
Definition DataHeader.h:596
constexpr o2::header::DataDescription gDataDescriptionDISTSTF
Definition DataHeader.h:608
constexpr uint32_t gSizeDataOriginString
size of the data origin field
Definition DataHeader.h:77
constexpr uint32_t gSizeHeaderDescriptionString
size of the header description field
Definition DataHeader.h:83
constexpr uint32_t gSizeMagicString
size of the magic string field
Definition DataHeader.h:75
constexpr uint32_t gSizeDataDescriptionString
size of the data description field
Definition DataHeader.h:81
constexpr uint32_t gSizeSerializationMethodString
size of the payload serialization field
Definition DataHeader.h:79
constexpr T String2__()
Definition DataHeader.h:102
constexpr std::size_t strLength(const char(&str)[N], std::size_t pos=0)
Definition DataHeader.h:151
constexpr int ArraySize()
evaluate the array size necessary to hold a N-byte number with type T
Definition DataHeader.h:125
O2 data header classes and API, v0.1.
Definition DetID.h:51
const uint64_t gInvalidToken64
default int representation of 'invalid' token for 8-byte char field
Definition DataHeader.h:322
constexpr o2::header::SerializationMethod gSerializationMethodAny
Definition DataHeader.h:328
void hexDump(const char *desc, const void *voidaddr, size_t len, size_t max=0)
helper function to print a hex/ASCII dump of some memory
constexpr T String2(char c, Targs... Fargs)
Definition DataHeader.h:161
Descriptor< gSizeHeaderDescriptionString > HeaderType
Definition DataHeader.h:324
auto get(const std::byte *buffer, size_t=0)
Definition DataHeader.h:457
constexpr o2::header::SerializationMethod gSerializationMethodArrow
Definition DataHeader.h:334
constexpr o2::header::SerializationMethod gSerializationMethodInvalid
Definition DataHeader.h:329
constexpr o2::header::SerializationMethod gSerializationMethodROOT
Definition DataHeader.h:331
T strtoui(const char *str, char **str_end, int base) noexcept
Definition DataHeader.h:506
const uint32_t gInvalidToken32
default int representation of 'invalid' token for 4-byte char field
Definition DataHeader.h:320
constexpr o2::header::SerializationMethod gSerializationMethodFlatBuf
Definition DataHeader.h:333
constexpr o2::header::SerializationMethod gSerializationMethodNone
Definition DataHeader.h:330
Descriptor< gSizeDataOriginString > DataOrigin
Definition DataHeader.h:553
Descriptor< gSizeSerializationMethodString > SerializationMethod
Definition DataHeader.h:325
constexpr o2::header::SerializationMethod gSerializationMethodCCDB
Definition DataHeader.h:332
T stoui(const std::string &str, size_t *pos=nullptr, int base=10)
Definition DataHeader.h:531
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void empty(int)
the base header struct Every header type must begin (i.e. derive) with this. Don't use this struct di...
Definition DataHeader.h:354
static BaseHeader * get(std::byte *b, size_t=0)
access header in buffer
Definition DataHeader.h:418
const std::byte * data() const noexcept
Definition DataHeader.h:425
o2::header::HeaderType description
header type description, set by derived header
Definition DataHeader.h:388
bool sanityCheck(uint32_t expectedVersion) const
static const BaseHeader * get(const std::byte *b, size_t=0)
access header in buffer
Definition DataHeader.h:408
const BaseHeader * next() const noexcept
get the next header if any (const version)
Definition DataHeader.h:428
static const o2::header::HeaderType sHeaderType
Definition DataHeader.h:359
constexpr BaseHeader(uint32_t mySize, HeaderType desc, SerializationMethod ser, uint32_t version)
Special ctor for initialization in derived types.
Definition DataHeader.h:399
void throwInconsistentStackError() const
BaseHeader * next() noexcept
get the next header if any (non-const version)
Definition DataHeader.h:436
uint32_t headerVersion
version of the entire header, set by the derived header
Definition DataHeader.h:385
static const o2::header::SerializationMethod sSerializationMethod
Definition DataHeader.h:360
BaseHeader()=delete
dont construct directly
char magicString[gSizeMagicString]
Definition DataHeader.h:366
static constexpr uint32_t sMagicString
Definition DataHeader.h:356
constexpr uint32_t size() const noexcept
Definition DataHeader.h:424
static const uint32_t sVersion
Definition DataHeader.h:358
o2::header::SerializationMethod serialization
header serialization method, set by derived header
Definition DataHeader.h:391
BaseHeader(const BaseHeader &)=default
the main header struct
Definition DataHeader.h:623
SplitPayloadPartsType splitPayloadParts
Definition DataHeader.h:651
TFCounterType tfCounter
Definition DataHeader.h:684
uint32_t SplitPayloadIndexType
Definition DataHeader.h:626
SerializationMethod payloadSerializationMethod
Definition DataHeader.h:656
constexpr DataHeader(DataDescription desc, DataOrigin origin, SubSpecificationType subspec, PayloadSizeType size, SplitPayloadIndexType partIndex, SplitPayloadPartsType parts)
Definition DataHeader.h:725
TForbitType firstTForbit
Definition DataHeader.h:679
DataDescription dataDescription
Definition DataHeader.h:641
SubSpecificationType subSpecification
Definition DataHeader.h:661
PayloadSizeType payloadSize
Definition DataHeader.h:671
DataHeader(const DataHeader &)=default
uint32_t SplitPayloadPartsType
Definition DataHeader.h:627
bool operator==(const DataHeader &) const
RunNumberType runNumber
Definition DataHeader.h:689
static constexpr uint32_t sVersion
Definition DataHeader.h:634
uint32_t SubSpecificationType
Definition DataHeader.h:625
constexpr DataHeader(DataDescription desc, DataOrigin origin, SubSpecificationType subspec, PayloadSizeType size=0)
Definition DataHeader.h:709
static constexpr o2::header::HeaderType sHeaderType
Definition DataHeader.h:635
static constexpr o2::header::SerializationMethod sSerializationMethod
Definition DataHeader.h:636
DataHeader & operator=(const DataHeader &)=default
static const DataHeader * Get(const BaseHeader *baseHeader)
Definition DataHeader.h:748
SplitPayloadIndexType splitPayloadIndex
Definition DataHeader.h:666
Helper struct to encode origin and description of data.
Definition DataHeader.h:762
DataIdentifier(const DataIdentifier &)=default
DataDescription dataDescription
Definition DataHeader.h:764
bool operator==(const DataIdentifier &) const
DataIdentifier(const char(&desc)[N], const char(&origin)[M])
Definition DataHeader.h:769
std::conditional_t<(size<=8), ItgType, std::string_view > ImplicitConversion
Definition DataHeader.h:226
friend bool operator==(const Descriptor &lhs, ImplicitConversion rhs)
Definition DataHeader.h:292
bool operator==(const Descriptor &other) const
Definition DataHeader.h:287
constexpr Descriptor(const char(&in)[L])
constructor from a compile-time string
Definition DataHeader.h:245
bool operator==(const T *) const =delete
static int constexpr bitcount
Definition DataHeader.h:211
bool operator!=(const Descriptor &other) const
Definition DataHeader.h:289
constexpr Descriptor(ItgType initializer)
Definition DataHeader.h:220
void runtimeInit(const char *buffer, size_t length)
compatibility version for explicit length
Definition DataHeader.h:282
static constexpr int arraySize
Definition DataHeader.h:212
bool operator!=(const T *) const =delete
typename internal::TraitsIntType< N >::Type ItgType
Definition DataHeader.h:213
bool operator<(const Descriptor &other) const
Definition DataHeader.h:288
Descriptor & operator=(const Descriptor &other)=default
void runtimeInit(const char *string)
compatibility version for null-terminated strings
Definition DataHeader.h:276
void runtimeInit(std::string_view string)
Definition DataHeader.h:260
constexpr Descriptor(const Descriptor &other)=default
static int constexpr size
Definition DataHeader.h:210
ItgType itg[arraySize]
Definition DataHeader.h:217
T as() const
get the descriptor as std::string
Definition DataHeader.h:304
get the number of active bits (set to 1) in a bitfield
Definition DataHeader.h:115
select uint type depending on size, default is uint64_t
Definition DataHeader.h:132
constexpr size_t max
VectorOfTObjectPtrs other
const std::string str