Project
Loading...
Searching...
No Matches
DataHeaderHelpers.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
12
#ifndef O2_BASE_DATA_HEADER_HELPERS_
13
#define O2_BASE_DATA_HEADER_HELPERS_
14
15
#include "
Headers/DataHeader.h
"
16
#include <fmt/format.h>
17
18
template
<
typename
T>
19
struct
fmt::formatter<T,
std
::enable_if_t<o2::header::is_descriptor<T>::value, char>> {
20
// Presentation format: 'f' - fixed, 'e' - exponential.
21
char
presentation =
's'
;
22
23
// Parses format specifications of the form ['f' | 'e'].
24
constexpr
auto
parse
(format_parse_context& ctx)
25
{
26
auto
it = ctx.begin(),
end
= ctx.end();
27
if
(it !=
end
&& (*it ==
's'
)) {
28
presentation = *it++;
29
}
30
31
// Check if reached the end of the range:
32
if
(it !=
end
&& *it !=
'}'
) {
33
throw
format_error(
"invalid pick format"
);
34
}
35
36
// Return an iterator past the end of the parsed range:
37
return
it;
38
}
39
40
template
<
typename
FormatContext>
41
auto
format
(
const
T& p, FormatContext& ctx)
const
42
{
43
return
fmt::format_to(ctx.out(),
"{}"
, p.template as<std::string>());
44
}
45
};
46
47
template
<>
48
struct
fmt::formatter<
o2
::header::DataHeader> {
49
char
presentation =
's'
;
50
51
constexpr
auto
parse
(format_parse_context& ctx)
52
{
53
auto
it = ctx.begin(),
end
= ctx.end();
54
if
(it !=
end
&& (*it ==
's'
)) {
55
presentation = *it++;
56
}
else
if
(it !=
end
&& (*it ==
'x'
)) {
57
presentation = *it++;
58
}
59
60
// Check if reached the end of the range:
61
if
(it !=
end
&& *it !=
'}'
) {
62
throw
format_error(
"invalid format"
);
63
}
64
65
// Return an iterator past the end of the parsed range:
66
return
it;
67
}
68
69
template
<
typename
FormatContext>
70
auto
format
(
const
o2::header::DataHeader
&
h
, FormatContext& ctx)
const
71
{
72
if
(presentation ==
's'
) {
73
auto
res
= fmt::format(
"Data header version {}, flags: {}\n"
,
h
.headerVersion,
h
.flags) +
74
fmt::format(
" origin : {}\n"
,
h
.dataOrigin.str) +
75
fmt::format(
" serialization: {}\n"
,
h
.payloadSerializationMethod.str) +
76
fmt::format(
" description : {}\n"
,
h
.dataDescription.str) +
77
fmt::format(
" sub spec. : {}\n"
, (
long
long
unsigned
int
)
h
.subSpecification) +
78
fmt::format(
" header size : {}\n"
,
h
.headerSize) +
79
fmt::format(
" payloadSize : {}\n"
, (
long
long
unsigned
int
)
h
.payloadSize) +
80
fmt::format(
" firstTForbit : {}\n"
,
h
.firstTForbit) +
81
fmt::format(
" tfCounter : {}\n"
,
h
.tfCounter) +
82
fmt::format(
" runNumber : {}\n"
,
h
.runNumber);
83
return
fmt::format_to(ctx.out(),
"{}"
,
res
);
84
}
else
{
85
auto
res
= fmt::format(
"{}/{}/{}"
,
86
h
.dataOrigin.str,
87
h
.dataDescription.str,
88
(
long
long
unsigned
int
)
h
.subSpecification);
89
return
fmt::format_to(ctx.out(),
"{}"
,
res
);
90
}
91
}
92
};
93
94
#endif
// O2_BASE_DATA_HEADER_HELPERS_
DataHeader.h
res
uint32_t res
Definition
RawData.h:0
h
Class for time synchronization of RawReader instances.
end
GLuint GLuint end
Definition
glcorearb.h:469
o2
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Definition
BitstreamReader.h:24
std
Defining DataPointCompositeObject explicitly as copiable.
Definition
CcdbObjectInfo.h:121
fmt::formatter< T, std::enable_if_t< o2::header::is_descriptor< T >::value, char > >::parse
constexpr auto parse(format_parse_context &ctx)
Definition
DataHeaderHelpers.h:24
fmt::formatter< T, std::enable_if_t< o2::header::is_descriptor< T >::value, char > >::format
auto format(const T &p, FormatContext &ctx) const
Definition
DataHeaderHelpers.h:41
fmt::formatter< o2::header::DataHeader >::format
auto format(const o2::header::DataHeader &h, FormatContext &ctx) const
Definition
DataHeaderHelpers.h:70
fmt::formatter< o2::header::DataHeader >::parse
constexpr auto parse(format_parse_context &ctx)
Definition
DataHeaderHelpers.h:51
o2::header::DataHeader
the main header struct
Definition
DataHeader.h:618
DataFormats
Headers
include
Headers
DataHeaderHelpers.h
Generated on Tue Feb 25 2025 23:16:11 for Project by
1.9.8