DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
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>
18namespace dunedaq {
19namespace conffwk {
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<PrintNumBase 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<PrintNumBase 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<PrintNumBase 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 << ": ";
72 p_val(s, val);
74 s << '\n';
75 }
76
78 template<PrintNumBase 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 << ": ";
86 for (const auto &x : val)
87 {
88 if (x != *val.begin())
89 s << ", ";
90 p_val(s, x);
91 }
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_
void p_sv_rel(std::ostream &s, const std::string &str, const std::string &name, const DalObject *obj)
print weak single-value relationship
void p_mv_rel(std::ostream &s, const std::string &str, const std::string &name, const T &objs) noexcept
print weak multi-value relationship
void p_mv_attr(std::ostream &s, const std::string &str, const std::string &name, const T &val) noexcept
print multi-value attribute
void p_sv_attr(std::ostream &s, const std::string &str, const std::string &name, const T &val) noexcept
print single-value attribute
void p_base_start(std::ostream &s) noexcept
void p_val(std::ostream &s, const T &data)
void p_base_end(std::ostream &s) noexcept
void p_val< uint8_t >(std::ostream &s, const uint8_t &data)
void p_val< int8_t >(std::ostream &s, const int8_t &data)
Including Qt Headers.
Definition module.cpp:16
msgpack::object obj