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
14
15
#ifndef CONFFWK_DAL_OBJECT_PRINT_H_
16
#define CONFFWK_DAL_OBJECT_PRINT_H_
17
18
#include <iostream>
19
namespace
dunedaq
{
20
namespace
conffwk
{
21
enum
PrintNumBase
22
{
23
dec
,
24
hex
,
25
oct
26
};
27
28
template
<
class
T>
29
void
30
p_val
(std::ostream& s,
const
T& data)
31
{
32
s << data;
33
}
34
35
template
<>
36
void
inline
p_val<uint8_t>
(std::ostream& s,
const
uint8_t& data)
37
{
38
s << static_cast<uint16_t>(data);
39
}
40
41
template
<>
42
void
inline
p_val<int8_t>
(std::ostream& s,
const
int8_t& data)
43
{
44
s << static_cast<int16_t>(data);
45
}
46
47
template
<Pr
int
NumBase NUM_BASE = dec>
48
void
49
p_base_start
(std::ostream& s)
noexcept
50
{
51
if
constexpr
(NUM_BASE ==
hex
)
52
s.setf(std::ios::hex, std::ios::basefield);
53
else
if
constexpr
(NUM_BASE ==
oct
)
54
s.setf(std::ios::oct, std::ios::basefield);
55
56
if
constexpr
(NUM_BASE !=
dec
)
57
s.setf(std::ios::showbase);
58
}
59
60
template
<Pr
int
NumBase NUM_BASE>
61
void
62
p_base_end
(std::ostream& s)
noexcept
63
{
64
if
constexpr
(NUM_BASE !=
dec
)
65
s.setf(std::ios::dec, std::ios::basefield);
66
}
67
69
template
<Pr
int
NumBase NUM_BASE = dec,
class
T>
70
void
71
p_sv_attr
(std::ostream& s,
const
std::string& str,
const
std::string& name,
const
T& val)
noexcept
72
{
73
s << str << name <<
": "
;
74
p_base_start<NUM_BASE>
(s);
75
p_val
(s, val);
76
p_base_end<NUM_BASE>
(s);
77
s <<
'\n'
;
78
}
79
81
template
<Pr
int
NumBase NUM_BASE = dec,
class
T>
82
void
83
p_mv_attr
(std::ostream& s,
const
std::string& str,
const
std::string& name,
const
T& val)
noexcept
84
{
85
if
(!val.empty()) {
86
s << str << val.size() <<
" value(s) in "
<< name <<
": "
;
87
p_base_start<NUM_BASE>
(s);
88
for
(
const
auto
& x : val) {
89
if
(x != *val.begin())
90
s <<
", "
;
91
p_val
(s, x);
92
}
93
p_base_end<NUM_BASE>
(s);
94
s <<
'\n'
;
95
}
else
{
96
s << str << name <<
" value is empty\n"
;
97
}
98
}
99
101
void
102
p_sv_rel
(std::ostream& s,
const
std::string& str,
const
std::string& name,
const
DalObject*
obj
);
103
105
template
<
class
T>
106
void
107
p_sv_rel
(std::ostream& s,
const
std::string& str,
unsigned
int
indent,
const
std::string& name,
const
T*
obj
)
noexcept
108
{
109
s << str << name <<
":\n"
;
110
111
if
(
obj
)
112
obj
->print(indent + 4,
true
, s);
113
else
114
s << str <<
" (null)\n"
;
115
}
116
118
template
<
class
T>
119
void
120
p_mv_rel
(std::ostream& s,
const
std::string& str,
const
std::string& name,
const
T& objs)
noexcept
121
{
122
if
(
auto
len = objs.size())
123
s << str << len <<
" object(s) in "
<< name <<
": "
;
124
else
125
s << str << name <<
" value is empty"
;
126
127
for
(
const
auto
& x : objs) {
128
if
(x != *objs.begin())
129
s <<
", "
;
130
s << x;
131
}
132
133
s <<
'\n'
;
134
}
135
137
template
<
class
T>
138
void
139
p_mv_rel
(std::ostream& s,
const
std::string& str,
unsigned
int
indent,
const
std::string& name,
const
T& objs)
noexcept
140
{
141
if
(
auto
len = objs.size())
142
s << str << len <<
" object(s) in "
<< name <<
":\n"
;
143
else
144
s << str << name <<
" value is empty\n"
;
145
146
for
(
const
auto
& x : objs)
147
x->print(indent + 4,
true
, s);
148
}
149
150
}
// namespace conffwk
151
}
// namespace dunedaq
152
153
#endif
// CONFFWK_CONFIGOBJECT_H_
dunedaq::conffwk
Definition
test_circular_dependency.hpp:5
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:103
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:120
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:83
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:71
dunedaq::conffwk::p_base_start
void p_base_start(std::ostream &s) noexcept
Definition
DalObjectPrint.hpp:49
dunedaq::conffwk::PrintNumBase
PrintNumBase
Definition
DalObjectPrint.hpp:22
dunedaq::conffwk::dec
@ dec
Definition
DalObjectPrint.hpp:23
dunedaq::conffwk::oct
@ oct
Definition
DalObjectPrint.hpp:25
dunedaq::conffwk::hex
@ hex
Definition
DalObjectPrint.hpp:24
dunedaq::conffwk::p_val
void p_val(std::ostream &s, const T &data)
Definition
DalObjectPrint.hpp:30
dunedaq::conffwk::p_base_end
void p_base_end(std::ostream &s) noexcept
Definition
DalObjectPrint.hpp:62
dunedaq
The DUNE-DAQ namespace.
Definition
cib_utilities.cpp:5
dunedaq::obj
msgpack::object obj
Definition
Serialization.hpp:252
Generated on
for DUNE-DAQ by
1.18.0