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