DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Utils.hxx
Go to the documentation of this file.
1template<class M>
2M
4{
5
6 M ret;
7
8 if (ret.GetTypeName() != e.measurement()) {
9 throw opmonlib::NameMismatch(ERS_HERE, ret.GetTypeName(), e.measurement());
10 }
11
12 from_entry(ret, e);
13
14 return ret;
15}
16
17template<class T>
18void
19dunedaq::opmonlib::set_value(google::protobuf::Message& m, const std::string& name, T value)
20{
21
22 const auto* descriptor_p = m.GetDescriptor();
23 const auto& des = *descriptor_p;
24
25 auto field_p = des.FindFieldByName(name);
26 if (!field_p) {
27 throw MissingField(ERS_HERE, name, m.GetTypeName());
28 }
29
30 const auto* reflection_p = m.GetReflection();
31 const auto& ref = *reflection_p;
32
33 set_value(ref, m, field_p, value);
34}
#define ERS_HERE
const std::string & measurement() const
void set_value(google::protobuf::Message &m, const std::string &name, T value)
Definition Utils.hxx:19
M from_entry(const dunedaq::opmon::OpMonEntry &)
Definition Utils.hxx:3