Line data Source code
1 : /**
2 : *
3 : * Implementations of DaphneV3Interface's functions
4 : *
5 : * This is part of the DUNE DAQ Software Suite, copyright 2020.
6 : * Licensing/copyright details are in the COPYING file that you should have
7 : */
8 :
9 : template<class T>
10 : T
11 2 : dunedaq::daphnemodules::DaphneV3Interface::send(std::string&& message,
12 : daphne::MessageTypeV2 sent_type,
13 : daphne::MessageTypeV2 received_type)
14 : {
15 :
16 2 : std::unique_lock<std::mutex> lock(m_access_mutex);
17 :
18 2 : _send(std::move(message), sent_type);
19 :
20 0 : auto ret = _receive();
21 :
22 0 : lock.unlock();
23 :
24 0 : const auto ty = ret.type();
25 0 : T out;
26 0 : if (ty != received_type) {
27 0 : throw FailedDecoding(ERS_HERE,
28 0 : out.GetTypeName(),
29 0 : ret.payload(),
30 0 : TypeMismatch(ERS_HERE, MessageTypeV2_Name(ty), MessageTypeV2_Name(received_type)));
31 : }
32 :
33 0 : if (!out.ParseFromString(ret.payload())) {
34 0 : throw FailedDecoding(ERS_HERE, out.GetTypeName(), ret.payload());
35 : }
36 :
37 0 : return out;
38 2 : }
|