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 <climits>
42#include <limits>
43#include <cerrno>
44
45namespace o2::header
46{
47
48//__________________________________________________________________________________________________
53
54//__________________________________________________________________________________________________
64
65//__________________________________________________________________________________________________
74
76constexpr uint32_t gSizeMagicString = 4;
78constexpr uint32_t gSizeDataOriginString = 4;
80constexpr uint32_t gSizeSerializationMethodString = 8;
82constexpr uint32_t gSizeDataDescriptionString = 16;
84constexpr uint32_t gSizeHeaderDescriptionString = 8;
85
87
88//__________________________________________________________________________________________________
89struct DataHeader;
90struct DataIdentifier;
91
92//__________________________________________________________________________________________________
94void hexDump(const char* desc, const void* voidaddr, size_t len, size_t max = 0);
95
96//__________________________________________________________________________________________________
97// internal implementations
99namespace internal
100{
101// terminating initializer implementation
102template <typename T>
103constexpr T String2__()
104{
105 return 0;
106}
107// recursive initializer implementation
108template <typename T, typename... Targs>
109constexpr T String2__(char c, Targs... Fargs)
110{
111 return (T)c | String2__<T>(Fargs...) << 8;
112}
113
115template <unsigned int N>
117 static int const value = NumberOfActiveBits<(N >> 1)>::value + (N & 0x1);
118};
119template <>
121 static int const value = 0;
122};
123
125template <typename T, int N>
126constexpr int ArraySize()
127{
128 return N / sizeof(T) + ((N % sizeof(T)) ? 1 : 0);
129}
130
132template <int N>
134 using Type = uint64_t;
135};
136template <>
137struct TraitsIntType<1> {
138 using Type = uint8_t;
139};
140template <>
141struct TraitsIntType<2> {
142 using Type = uint16_t;
143};
144template <>
145struct TraitsIntType<4> {
146 using Type = uint32_t;
147};
148
151template <int N>
152constexpr std::size_t strLength(const char (&str)[N], std::size_t pos = 0)
153{
154 return ((pos >= N || str[pos] == 0) ? 0 : 1 + strLength(str, pos + 1));
155}
156}; // namespace internal
157
158//__________________________________________________________________________________________________
161template <typename T, typename... Targs>
162constexpr T String2(char c, Targs... Fargs)
163{
164 // number of arguments has either to match the size of the type, or the last element is treated
165 // as '0' if missing
166 // TODO: this is a bit of a question, do we allow the number of characters to
167 // be smaller than the size of the type and just pad with 0 like in the case
168 // of a char array argument?
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...);
173}
174
179template <typename T, std::size_t N, std::size_t pos = 0, bool suppressAssert = false>
180constexpr T String2(const char (&str)[N])
181{
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");
186 // clang-format off
187 return ((T)str[0 + pos] |
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));
196 // clang-format on
197}
198
199//__________________________________________________________________________________________________
206template <std::size_t N>
209 "Descriptor size is required to be a power of 2");
211 static int constexpr size = N;
212 static int constexpr bitcount = size * 8;
213 static constexpr int arraySize = internal::ArraySize<uint64_t, size>();
215
216 union {
217 char str[N];
219 };
220 constexpr Descriptor() : itg{0} {};
221 constexpr Descriptor(ItgType initializer) : itg{initializer} {};
222 constexpr Descriptor(const Descriptor& other) = default;
224
225 // Note: don't need to define operator=(ItgType v) because the compiler
226 // can use Descriptor(ItgType initializer) for conversion
227 using ImplicitConversion = std::conditional_t<(size <= 8), ItgType, std::string_view>;
228
229 // type cast operator for simplified usage of the descriptor's integer member
230 // in case it does not fit into the descriptor, the string representation is returned
231 operator ImplicitConversion() const
232 {
233 if constexpr (std::is_same_v<ImplicitConversion, ItgType>) {
234 return itg[0];
235 } else {
236 size_t len = size;
237 while (len > 1 && str[len - 1] == 0) {
238 --len;
239 }
240 return std::string_view(str, len);
241 }
242 }
243
245 template <std::size_t L>
246 constexpr Descriptor(const char (&in)[L]) : str{0}
247 {
248 static_assert(L <= N + 1, "initializer string must not exceed descriptor size");
249 unsigned i = 0;
250 for (; i < (N < L ? N : L) && in[i]; ++i) {
251 str[i] = in[i];
252 }
253 }
254
261 void runtimeInit(const char* string, short length = -1)
262 {
263 char* target = str;
264 char* targetEnd = target;
265 if (length >= 0 && length < (int)N) {
266 targetEnd += length;
267 } else {
268 targetEnd += N;
269 }
270 const char* source = string;
271 for (; source != nullptr && target < targetEnd && *source != 0; ++target, ++source) {
272 *target = *source;
273 }
274 targetEnd = str + N;
275 for (; target < targetEnd; ++target) {
276 *target = 0;
277 }
278 // require the string to be not longer than the descriptor size
279 if (source != nullptr && (*source == 0 || (length >= 0 && length <= (int)N))) {
280 } else {
281 throw std::invalid_argument("argument must not be longer than descriptor size");
282 }
283 }
284
285 bool operator==(const Descriptor& other) const { return std::memcmp(this->str, other.str, N) == 0; }
286 bool operator<(const Descriptor& other) const { return std::memcmp(this->str, other.str, N) < 0; }
287 bool operator!=(const Descriptor& other) const { return not this->operator==(other); }
288
289 // Convesion operators for comparison with their implicitly convertible types
290 friend bool operator==(const Descriptor& lhs, ImplicitConversion rhs) { return static_cast<ImplicitConversion>(lhs) == rhs; }
291 // explicitly forbid comparison with e.g. const char* strings
292 // use: value == Descriptor<N>("DESC") for the appropriate
293 // template instantiation instead
294 template <typename T>
295 bool operator==(const T*) const = delete;
296 template <typename T>
297 bool operator!=(const T*) const = delete;
298
300 template <typename T>
301 std::enable_if_t<std::is_same<T, std::string>::value == true, T> as() const
302 {
303 // backward search to find first non-zero char
304 // FIXME: can optimize this by using the int value to start at e.g. size/2
305 // if the upper part of the string is just zeros.
306 size_t len = size;
307 while (len > 1 && str[len - 1] == 0) {
308 --len;
309 }
310 std::string ret(str, len);
311 return ret;
312 }
313};
314
315//__________________________________________________________________________________________________
317const uint32_t gInvalidToken32 = 0xFFFFFFFF;
319const uint64_t gInvalidToken64 = 0xFFFFFFFFFFFFFFFF;
320
323
324// possible serialization types
332
333//__________________________________________________________________________________________________
352 // static definitions
353 static constexpr uint32_t sMagicString{String2<uint32_t>("O2O2")};
354
355 static const uint32_t sVersion;
358
359 //__the data layout:
360
362 union {
365 };
366
369 uint32_t headerSize;
370
372 union {
373 uint32_t flags;
374 struct {
375 uint32_t flagsNextHeader : 1, // do we have a next header after this one?
376 flagsReserved : 15, // reserved for future use
377 flagsDerivedHeader : 16; // reserved for usage by the derived header
378 };
379 };
380
383
386
389
390 //___the functions:
391
393 BaseHeader() = delete;
394 BaseHeader(const BaseHeader&) = default;
396 constexpr BaseHeader(uint32_t mySize, HeaderType desc,
397 SerializationMethod ser, uint32_t version)
399 {
400 }
401
405 inline static const BaseHeader* get(const std::byte* b, size_t /*len*/ = 0)
406 {
407 return (b != nullptr && *(reinterpret_cast<const uint32_t*>(b)) == sMagicString)
408 ? reinterpret_cast<const BaseHeader*>(b)
409 : nullptr;
410 }
411
415 inline static BaseHeader* get(std::byte* b, size_t /*len*/ = 0)
416 {
417 return (b != nullptr && *(reinterpret_cast<uint32_t*>(b)) == sMagicString) ? reinterpret_cast<BaseHeader*>(b)
418 : nullptr;
419 }
420
421 constexpr uint32_t size() const noexcept { return headerSize; }
422 inline const std::byte* data() const noexcept { return reinterpret_cast<const std::byte*>(this); }
423
425 inline const BaseHeader* next() const noexcept
426 {
427 // BaseHeader::get checks that next header starts with the BaseHeader information at the
428 // offset given by the size of the current header.
429 return (flagsNextHeader) ? BaseHeader::get(reinterpret_cast<const std::byte*>(this) + headerSize) : nullptr;
430 }
431
433 inline BaseHeader* next() noexcept
434 {
435 return (flagsNextHeader) ? BaseHeader::get(reinterpret_cast<std::byte*>(this) + headerSize) : nullptr;
436 }
437
443 bool sanityCheck(uint32_t expectedVersion) const;
444
447 void throwInconsistentStackError() const;
448};
449
453template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value, int> = 0>
454auto get(const std::byte* buffer, size_t /*len*/ = 0)
455{
456 using HeaderConstPtrType = const typename std::remove_pointer<HeaderType>::type*;
457 using HeaderValueType = typename std::remove_pointer<HeaderType>::type;
458
459 const BaseHeader* current = BaseHeader::get(buffer);
460 if (!current) {
461 return HeaderConstPtrType{nullptr};
462 }
463 if (current->description == HeaderValueType::sHeaderType) {
464 // FIXME: We need to think how to handle multiple versions.
465 // For the moment we require the version to exactly match the expected version, which
466 // is part of the header definition. The check function 'sanityCheck' will throw
467 // otherwise, we keep the code related to the exception outside the header file.
468 // Note: Can not check on size because the O2 data model requires variable size headers
469 // to be supported.
470 if (current->sanityCheck(HeaderValueType::sVersion)) {
471 return reinterpret_cast<HeaderConstPtrType>(current);
472 }
473 }
474 auto* prev = current;
475 while ((current = current->next())) {
476 prev = current;
477 if (current->description == HeaderValueType::sHeaderType) {
478 if (current->sanityCheck(HeaderValueType::sVersion)) {
479 return reinterpret_cast<HeaderConstPtrType>(current);
480 }
481 }
482 }
483 // if a next header was expected but not found, the header stack is inconsistent
484 // either the flag is wrongly set, or the size of the current header is wrong so
485 // that the BaseHeader information is not found at the expected offset.
486 if (prev->flagsNextHeader) {
488 }
489 return HeaderConstPtrType{nullptr};
490}
491
492template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value, int> = 0>
493auto get(const void* buffer, size_t len = 0)
494{
495 return get<HeaderType>(reinterpret_cast<const std::byte*>(buffer), len);
496}
497
498//__________________________________________________________________________________________________
499// utilities for converting strings to ints - tries to mimick the stadard API, but the result is
500// strongly typed - can be used for fixed width and short unsigned integer types unlike the standard
501// utilities.
502template <typename T>
503T strtoui(const char* str, char** str_end, int base) noexcept
504{
505 static_assert(std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed,
506 "Target must be an unsigned integer type");
507 // standard lib gives us 2 specializations of strtouX, so let's use them both where appropriate
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()) {
511 errno = ERANGE;
512 return std::numeric_limits<T>::max();
513 } else {
514 return static_cast<T>(res);
515 };
516 } else {
517 unsigned long long res = strtoull(str, str_end, base);
518 if (res > std::numeric_limits<T>::max()) {
519 errno = ERANGE;
520 return std::numeric_limits<T>::max();
521 } else {
522 return static_cast<T>(res);
523 };
524 }
525};
526
527template <typename T>
528T stoui(const std::string& str, size_t* pos = nullptr, int base = 10)
529{
530 static_assert(std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed,
531 "Target must be an unsigned integer type");
532 // standard lib gives us 2 specializations of stouX, so let's use them both where appropriate
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");
537 } else {
538 return static_cast<T>(res);
539 };
540 } else {
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");
544 } else {
545 return static_cast<T>(res);
546 };
547 }
548};
549
552
553//__________________________________________________________________________________________________
557
558//__________________________________________________________________________________________________
559// possible data origins
580constexpr o2::header::DataOrigin gDataOriginACO{"ACO"}; // for bwd compatibility with DD
581
590constexpr o2::header::DataOrigin gDataOriginECL{"ECL"}; // upgrades
591
593
594// possible data types
605
606//__________________________________________________________________________________________________
618struct DataHeader : public BaseHeader {
619 // allows DataHeader::SubSpecificationType to be used as generic type in the code
620 using SubSpecificationType = uint32_t;
621 using SplitPayloadIndexType = uint32_t;
622 using SplitPayloadPartsType = uint32_t;
623 using PayloadSizeType = uint64_t;
624 using TForbitType = uint32_t;
625 using TFCounterType = uint32_t;
626 using RunNumberType = uint32_t;
627
628 // static data for this header type/version
629 static constexpr uint32_t sVersion{3};
630 static constexpr o2::header::HeaderType sHeaderType{String2<uint64_t>("DataHead")};
632
637
642
647
652
657
662
667
668 //___NEVER MODIFY THE ABOVE
669 //___NEW STUFF GOES BELOW
670
675
680
685
686 //___the functions:
687 //__________________________________________________________________________________________________
702
703 //__________________________________________________________________________________________________
718
719 //__________________________________________________________________________________________________
734
735 DataHeader(const DataHeader&) = default;
736 DataHeader& operator=(const DataHeader&) = default; // assignment
737
738 bool operator==(const DataHeader&) const; // comparison
739 bool operator==(const DataOrigin&) const; // comparison
740 bool operator==(const DataDescription&) const; // comparison
741 bool operator==(const SerializationMethod&) const; // comparison
742
743 static const DataHeader* Get(const BaseHeader* baseHeader)
744 {
745 return (baseHeader->description == DataHeader::sHeaderType) ? static_cast<const DataHeader*>(baseHeader) : nullptr;
746 }
747};
748
749//__________________________________________________________________________________________________
758 // a full data identifier combining origin and description
763 template <std::size_t N, std::size_t M>
764 DataIdentifier(const char (&desc)[N], const char (&origin)[M])
765 : dataDescription(desc), dataOrigin(origin)
766 {
767 }
768
769 bool operator==(const DataIdentifier&) const;
770};
771
772//__________________________________________________________________________________________________
775static_assert(sizeof(HeaderType) == 8,
776 "HeaderType struct must be of size 8");
777static_assert(sizeof(SerializationMethod) == 8,
778 "SerializationMethod struct must be of size 8");
779static_assert(sizeof(BaseHeader) == 32,
780 "BaseHeader struct must be of size 32");
781static_assert(sizeof(DataOrigin) == 4,
782 "DataOrigin struct must be of size 4");
783static_assert(sizeof(DataHeader) == 96,
784 "DataHeader struct must be of size 96");
785static_assert(gSizeMagicString == sizeof(BaseHeader::magicStringInt),
786 "Size mismatch in magic string union");
787static_assert(sizeof(BaseHeader::sMagicString) == sizeof(BaseHeader::magicStringInt),
788 "Inconsitent size of global magic identifier");
789
790template <typename T>
791struct is_descriptor : std::false_type {
792};
793
794template <std::size_t S>
795struct is_descriptor<o2::header::Descriptor<S>> : std::true_type {
796};
797
798} // namespace o2::header
799
800#endif
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
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 GLsizei GLchar * source
Definition glcorearb.h:798
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLenum target
Definition glcorearb.h:1641
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:574
constexpr o2::header::DataOrigin gDataOriginMFT
Definition DataHeader.h:572
constexpr o2::header::DataOrigin gDataOriginMCH
Definition DataHeader.h:571
constexpr o2::header::DataDescription gDataDescriptionInvalid
Definition DataHeader.h:596
constexpr o2::header::DataOrigin gDataOriginCTP
Definition DataHeader.h:564
constexpr o2::header::DataOrigin gDataOriginFLP
Definition DataHeader.h:562
constexpr o2::header::DataOrigin gDataOriginIT3
Definition DataHeader.h:582
constexpr o2::header::DataOrigin gDataOriginTST
Definition DataHeader.h:579
constexpr o2::header::DataDescription gDataDescriptionInfo
Definition DataHeader.h:601
constexpr o2::header::DataOrigin gDataOriginMI3
Definition DataHeader.h:589
constexpr o2::header::DataOrigin gDataOriginTRK
Definition DataHeader.h:584
constexpr o2::header::DataOrigin gDataOriginHMP
Definition DataHeader.h:569
constexpr o2::header::DataOrigin gDataOriginTPC
Definition DataHeader.h:576
constexpr o2::header::DataOrigin gDataOriginACO
Definition DataHeader.h:580
constexpr o2::header::DataDescription gDataDescriptionROOTStreamers
Definition DataHeader.h:602
constexpr o2::header::DataOrigin gDataOriginFOC
Definition DataHeader.h:583
constexpr o2::header::DataOrigin gDataOriginFCT
Definition DataHeader.h:586
constexpr o2::header::DataOrigin gDataOriginFT3
Definition DataHeader.h:585
constexpr o2::header::DataOrigin gDataOriginZDC
Definition DataHeader.h:578
constexpr o2::header::DataDescription gDataDescriptionTracks
Definition DataHeader.h:599
constexpr o2::header::DataOrigin gDataOriginInvalid
Definition DataHeader.h:561
constexpr o2::header::DataOrigin gDataOriginRCH
Definition DataHeader.h:588
constexpr o2::header::DataDescription gDataDescriptionConfig
Definition DataHeader.h:600
constexpr o2::header::DataOrigin gDataOriginMID
Definition DataHeader.h:573
constexpr o2::header::DataOrigin gDataOriginECL
Definition DataHeader.h:590
constexpr o2::header::DataOrigin gDataOriginFDD
Definition DataHeader.h:568
constexpr o2::header::DataDescription gDataDescriptionRawData
Definition DataHeader.h:597
constexpr o2::header::DataOrigin gDataOriginFT0
Definition DataHeader.h:566
constexpr o2::header::DataOrigin gDataOriginTRD
Definition DataHeader.h:577
constexpr o2::header::DataOrigin gDataOriginEMC
Definition DataHeader.h:565
constexpr o2::header::DataOrigin gDataOriginTF3
Definition DataHeader.h:587
constexpr o2::header::DataOrigin gDataOriginTOF
Definition DataHeader.h:575
constexpr o2::header::DataOrigin gDataOriginITS
Definition DataHeader.h:570
constexpr o2::header::DataOrigin gDataOriginCPV
Definition DataHeader.h:563
constexpr o2::header::DataOrigin gDataOriginAny
Definition DataHeader.h:560
constexpr o2::header::DataDescription gDataDescriptionClusters
Definition DataHeader.h:598
constexpr o2::header::DataOrigin gDataOriginFV0
Definition DataHeader.h:567
constexpr o2::header::DataDescription gDataDescriptionAny
Definition DataHeader.h:595
constexpr o2::header::DataOrigin gDataOriginGPU
Definition DataHeader.h:592
constexpr o2::header::DataDescription gDataDescriptionDISTSTF
Definition DataHeader.h:603
constexpr uint32_t gSizeDataOriginString
size of the data origin field
Definition DataHeader.h:78
constexpr uint32_t gSizeHeaderDescriptionString
size of the header description field
Definition DataHeader.h:84
constexpr uint32_t gSizeMagicString
size of the magic string field
Definition DataHeader.h:76
constexpr uint32_t gSizeDataDescriptionString
size of the data description field
Definition DataHeader.h:82
constexpr uint32_t gSizeSerializationMethodString
size of the payload serialization field
Definition DataHeader.h:80
constexpr T String2__()
Definition DataHeader.h:103
constexpr std::size_t strLength(const char(&str)[N], std::size_t pos=0)
Definition DataHeader.h:152
constexpr int ArraySize()
evaluate the array size necessary to hold a N-byte number with type T
Definition DataHeader.h:126
O2 data header classes and API, v0.1.
Definition DetID.h:49
const uint64_t gInvalidToken64
default int representation of 'invalid' token for 8-byte char field
Definition DataHeader.h:319
constexpr o2::header::SerializationMethod gSerializationMethodAny
Definition DataHeader.h:325
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:162
Descriptor< gSizeHeaderDescriptionString > HeaderType
Definition DataHeader.h:321
auto get(const std::byte *buffer, size_t=0)
Definition DataHeader.h:454
constexpr o2::header::SerializationMethod gSerializationMethodArrow
Definition DataHeader.h:331
constexpr o2::header::SerializationMethod gSerializationMethodInvalid
Definition DataHeader.h:326
constexpr o2::header::SerializationMethod gSerializationMethodROOT
Definition DataHeader.h:328
T strtoui(const char *str, char **str_end, int base) noexcept
Definition DataHeader.h:503
const uint32_t gInvalidToken32
default int representation of 'invalid' token for 4-byte char field
Definition DataHeader.h:317
constexpr o2::header::SerializationMethod gSerializationMethodFlatBuf
Definition DataHeader.h:330
constexpr o2::header::SerializationMethod gSerializationMethodNone
Definition DataHeader.h:327
Descriptor< gSizeDataOriginString > DataOrigin
Definition DataHeader.h:550
Descriptor< gSizeSerializationMethodString > SerializationMethod
Definition DataHeader.h:322
constexpr o2::header::SerializationMethod gSerializationMethodCCDB
Definition DataHeader.h:329
T stoui(const std::string &str, size_t *pos=nullptr, int base=10)
Definition DataHeader.h:528
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
the base header struct Every header type must begin (i.e. derive) with this. Don't use this struct di...
Definition DataHeader.h:351
static BaseHeader * get(std::byte *b, size_t=0)
access header in buffer
Definition DataHeader.h:415
const std::byte * data() const noexcept
Definition DataHeader.h:422
o2::header::HeaderType description
header type description, set by derived header
Definition DataHeader.h:385
bool sanityCheck(uint32_t expectedVersion) const
static const BaseHeader * get(const std::byte *b, size_t=0)
access header in buffer
Definition DataHeader.h:405
const BaseHeader * next() const noexcept
get the next header if any (const version)
Definition DataHeader.h:425
static const o2::header::HeaderType sHeaderType
Definition DataHeader.h:356
constexpr BaseHeader(uint32_t mySize, HeaderType desc, SerializationMethod ser, uint32_t version)
Special ctor for initialization in derived types.
Definition DataHeader.h:396
void throwInconsistentStackError() const
BaseHeader * next() noexcept
get the next header if any (non-const version)
Definition DataHeader.h:433
uint32_t headerVersion
version of the entire header, set by the derived header
Definition DataHeader.h:382
static const o2::header::SerializationMethod sSerializationMethod
Definition DataHeader.h:357
BaseHeader()=delete
dont construct directly
char magicString[gSizeMagicString]
Definition DataHeader.h:363
static constexpr uint32_t sMagicString
Definition DataHeader.h:353
constexpr uint32_t size() const noexcept
Definition DataHeader.h:421
static const uint32_t sVersion
Definition DataHeader.h:355
o2::header::SerializationMethod serialization
header serialization method, set by derived header
Definition DataHeader.h:388
BaseHeader(const BaseHeader &)=default
the main header struct
Definition DataHeader.h:618
SplitPayloadPartsType splitPayloadParts
Definition DataHeader.h:646
TFCounterType tfCounter
Definition DataHeader.h:679
uint32_t SplitPayloadIndexType
Definition DataHeader.h:621
SerializationMethod payloadSerializationMethod
Definition DataHeader.h:651
constexpr DataHeader(DataDescription desc, DataOrigin origin, SubSpecificationType subspec, PayloadSizeType size, SplitPayloadIndexType partIndex, SplitPayloadPartsType parts)
Definition DataHeader.h:720
TForbitType firstTForbit
Definition DataHeader.h:674
DataDescription dataDescription
Definition DataHeader.h:636
SubSpecificationType subSpecification
Definition DataHeader.h:656
PayloadSizeType payloadSize
Definition DataHeader.h:666
DataHeader(const DataHeader &)=default
uint32_t SplitPayloadPartsType
Definition DataHeader.h:622
bool operator==(const DataHeader &) const
RunNumberType runNumber
Definition DataHeader.h:684
static constexpr uint32_t sVersion
Definition DataHeader.h:629
uint32_t SubSpecificationType
Definition DataHeader.h:620
constexpr DataHeader(DataDescription desc, DataOrigin origin, SubSpecificationType subspec, PayloadSizeType size=0)
Definition DataHeader.h:704
static constexpr o2::header::HeaderType sHeaderType
Definition DataHeader.h:630
static constexpr o2::header::SerializationMethod sSerializationMethod
Definition DataHeader.h:631
DataHeader & operator=(const DataHeader &)=default
static const DataHeader * Get(const BaseHeader *baseHeader)
Definition DataHeader.h:743
SplitPayloadIndexType splitPayloadIndex
Definition DataHeader.h:661
Helper struct to encode origin and description of data.
Definition DataHeader.h:757
DataIdentifier(const DataIdentifier &)=default
DataDescription dataDescription
Definition DataHeader.h:759
bool operator==(const DataIdentifier &) const
DataIdentifier(const char(&desc)[N], const char(&origin)[M])
Definition DataHeader.h:764
std::conditional_t<(size<=8), ItgType, std::string_view > ImplicitConversion
Definition DataHeader.h:227
friend bool operator==(const Descriptor &lhs, ImplicitConversion rhs)
Definition DataHeader.h:290
bool operator==(const Descriptor &other) const
Definition DataHeader.h:285
constexpr Descriptor(const char(&in)[L])
constructor from a compile-time string
Definition DataHeader.h:246
std::enable_if_t< std::is_same< T, std::string >::value==true, T > as() const
get the descriptor as std::string
Definition DataHeader.h:301
bool operator==(const T *) const =delete
static int constexpr bitcount
Definition DataHeader.h:212
bool operator!=(const Descriptor &other) const
Definition DataHeader.h:287
constexpr Descriptor(ItgType initializer)
Definition DataHeader.h:221
static constexpr int arraySize
Definition DataHeader.h:213
bool operator!=(const T *) const =delete
typename internal::TraitsIntType< N >::Type ItgType
Definition DataHeader.h:214
bool operator<(const Descriptor &other) const
Definition DataHeader.h:286
Descriptor & operator=(const Descriptor &other)=default
void runtimeInit(const char *string, short length=-1)
Definition DataHeader.h:261
constexpr Descriptor(const Descriptor &other)=default
static int constexpr size
Definition DataHeader.h:211
ItgType itg[arraySize]
Definition DataHeader.h:218
get the number of active bits (set to 1) in a bitfield
Definition DataHeader.h:116
select uint type depending on size, default is uint64_t
Definition DataHeader.h:133
constexpr size_t max
VectorOfTObjectPtrs other
const std::string str