DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
conffwk
include
conffwk
DalObjectPrint.hpp
Go to the documentation of this file.
1
//
2
// DUNE DAQ modification notice:
3
// This file has been modified from the original ATLAS config source for the DUNE DAQ project.
4
// Fork baseline commit: 67a24e731 (2022-10-27).
5
// Renamed since fork: yes (from config/DalObjectPrint.h to include/conffwk/DalObjectPrint.hpp).
6
//
7
13
14
#ifndef CONFFWK_DAL_OBJECT_PRINT_H_
15
#define CONFFWK_DAL_OBJECT_PRINT_H_
16
17
#include <iostream>
18
namespace
dunedaq
{
19
namespace
conffwk
{
20
enum
PrintNumBase
{
dec
,
hex
,
oct
};
21
22
template
<
class
T>
23
void
24
p_val
(std::ostream& s,
const
T & data)
25
{
26
s << data;
27
}
28
29
template
<>
30
void
inline
31
p_val<uint8_t>
(std::ostream& s,
const
uint8_t & data)
32
{
33
s << static_cast<uint16_t>(data);
34
}
35
36
template
<>
37
void
inline
38
p_val<int8_t>
(std::ostream& s,
const
int8_t & data)
39
{
40
s << static_cast<int16_t>(data);
41
}
42
43
44
template
<Pr
int
NumBase NUM_BASE = dec>
45
void
46
p_base_start
(std::ostream &s)
noexcept
47
{
48
if
constexpr
(NUM_BASE ==
hex
)
49
s.setf(std::ios::hex, std::ios::basefield);
50
else
if
constexpr
(NUM_BASE ==
oct
)
51
s.setf(std::ios::oct, std::ios::basefield);
52
53
if
constexpr
(NUM_BASE !=
dec
)
54
s.setf(std::ios::showbase);
55
}
56
57
template
<Pr
int
NumBase NUM_BASE>
58
void
59
p_base_end
(std::ostream &s)
noexcept
60
{
61
if
constexpr
(NUM_BASE !=
dec
)
62
s.setf(std::ios::dec, std::ios::basefield);
63
}
64
66
template
<Pr
int
NumBase NUM_BASE=dec,
class
T>
67
void
68
p_sv_attr
(std::ostream &s,
const
std::string &str,
const
std::string &name,
const
T &val)
noexcept
69
{
70
s << str << name <<
": "
;
71
p_base_start<NUM_BASE>
(s);
72
p_val
(s, val);
73
p_base_end<NUM_BASE>
(s);
74
s <<
'\n'
;
75
}
76
78
template
<Pr
int
NumBase NUM_BASE=dec,
class
T>
79
void
80
p_mv_attr
(std::ostream &s,
const
std::string &str,
const
std::string &name,
const
T &val)
noexcept
81
{
82
if
(!val.empty())
83
{
84
s << str << val.size() <<
" value(s) in "
<< name <<
": "
;
85
p_base_start<NUM_BASE>
(s);
86
for
(
const
auto
&x : val)
87
{
88
if
(x != *val.begin())
89
s <<
", "
;
90
p_val
(s, x);
91
}
92
p_base_end<NUM_BASE>
(s);
93
s <<
'\n'
;
94
}
95
else
96
{
97
s << str << name <<
" value is empty\n"
;
98
}
99
}
100
102
void
103
p_sv_rel
(std::ostream &s,
const
std::string &str,
const
std::string &name,
const
DalObject *
obj
);
104
106
template
<
class
T>
107
void
108
p_sv_rel
(std::ostream &s,
const
std::string &str,
unsigned
int
indent,
const
std::string &name,
const
T *
obj
)
noexcept
109
{
110
s << str << name <<
":\n"
;
111
112
if
(
obj
)
113
obj
->print(indent + 4,
true
, s);
114
else
115
s << str <<
" (null)\n"
;
116
}
117
119
template
<
class
T>
120
void
121
p_mv_rel
(std::ostream &s,
const
std::string &str,
const
std::string &name,
const
T &objs)
noexcept
122
{
123
if
(
auto
len = objs.size())
124
s << str << len <<
" object(s) in "
<< name <<
": "
;
125
else
126
s << str << name <<
" value is empty"
;
127
128
for
(
const
auto
&x : objs)
129
{
130
if
(x != *objs.begin())
131
s <<
", "
;
132
s << x;
133
}
134
135
s <<
'\n'
;
136
}
137
139
template
<
class
T>
140
void
141
p_mv_rel
(std::ostream &s,
const
std::string &str,
unsigned
int
indent,
const
std::string &name,
const
T &objs)
noexcept
142
{
143
if
(
auto
len = objs.size())
144
s << str << len <<
" object(s) in "
<< name <<
":\n"
;
145
else
146
s << str << name <<
" value is empty\n"
;
147
148
for
(
const
auto
&x : objs)
149
x->print(indent + 4,
true
, s);
150
}
151
152
}
// namespace conffwk
153
}
// namespace dunedaq
154
155
156
#endif
// CONFFWK_CONFIGOBJECT_H_
dunedaq::conffwk
Definition
Change.hpp:23
dunedaq::conffwk::p_sv_rel
void p_sv_rel(std::ostream &s, const std::string &str, const std::string &name, const DalObject *obj)
print weak single-value relationship
Definition
DalObject.cpp:105
dunedaq::conffwk::p_mv_rel
void p_mv_rel(std::ostream &s, const std::string &str, const std::string &name, const T &objs) noexcept
print weak multi-value relationship
Definition
DalObjectPrint.hpp:121
dunedaq::conffwk::p_mv_attr
void p_mv_attr(std::ostream &s, const std::string &str, const std::string &name, const T &val) noexcept
print multi-value attribute
Definition
DalObjectPrint.hpp:80
dunedaq::conffwk::p_sv_attr
void p_sv_attr(std::ostream &s, const std::string &str, const std::string &name, const T &val) noexcept
print single-value attribute
Definition
DalObjectPrint.hpp:68
dunedaq::conffwk::p_base_start
void p_base_start(std::ostream &s) noexcept
Definition
DalObjectPrint.hpp:46
dunedaq::conffwk::PrintNumBase
PrintNumBase
Definition
DalObjectPrint.hpp:20
dunedaq::conffwk::dec
@ dec
Definition
DalObjectPrint.hpp:20
dunedaq::conffwk::oct
@ oct
Definition
DalObjectPrint.hpp:20
dunedaq::conffwk::hex
@ hex
Definition
DalObjectPrint.hpp:20
dunedaq::conffwk::p_val
void p_val(std::ostream &s, const T &data)
Definition
DalObjectPrint.hpp:24
dunedaq::conffwk::p_base_end
void p_base_end(std::ostream &s) noexcept
Definition
DalObjectPrint.hpp:59
dunedaq::conffwk::p_val< uint8_t >
void p_val< uint8_t >(std::ostream &s, const uint8_t &data)
Definition
DalObjectPrint.hpp:31
dunedaq::conffwk::p_val< int8_t >
void p_val< int8_t >(std::ostream &s, const int8_t &data)
Definition
DalObjectPrint.hpp:38
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::obj
msgpack::object obj
Definition
Serialization.hpp:257
Generated on
for DUNE-DAQ by
1.17.0