Line data Source code
1 : /**
2 : * @file CreateGenericReceiver.hpp Specific GenericReceiverConcept creator.
3 : *
4 : * This is part of the DUNE DAQ , copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 : #ifndef ASIOLIBS_SRC_CREATEGENERICRECEIVER_HPP_
9 : #define ASIOLIBS_SRC_CREATEGENERICRECEIVER_HPP_
10 :
11 : #include "GenericReceiverConcept.hpp"
12 : #include "GenericReceiverModel.hpp"
13 :
14 : #include "fddetdataformats/CRTBernFrame.hpp"
15 : #include "fddetdataformats/CRTGrenobleFrame.hpp"
16 :
17 : #include "datahandlinglibs/DataHandlingIssues.hpp"
18 :
19 : #include <memory>
20 : #include <string>
21 :
22 0 : DUNE_DAQ_TYPESTRING(dunedaq::fddetdataformats::CRTBernFrame, "CRTBernFrame")
23 0 : DUNE_DAQ_TYPESTRING(dunedaq::fddetdataformats::CRTGrenobleFrame, "CRTGrenobleFrame")
24 :
25 : namespace dunedaq::asiolibs {
26 :
27 : std::shared_ptr<GenericReceiverConcept>
28 0 : createGenericReceiver(const std::string& receiver_connection_name)
29 : {
30 0 : const auto datatypes = dunedaq::iomanager::IOManager::get()->get_datatypes(receiver_connection_name);
31 0 : if (datatypes.size() != 1) {
32 0 : ers::error(datahandlinglibs::GenericConfigurationError(ERS_HERE,
33 0 : "Multiple input data types specified! Expected only a single type!"));
34 : }
35 0 : const std::string dt = *datatypes.begin();
36 0 : TLOG() << "Choosing specializations for GenericReceiverConcept for input connection "
37 0 : << " [uid:" << receiver_connection_name << " , data_type:" << dt << ']';
38 :
39 0 : if (dt.find("CRTBernFrame") != std::string::npos) {
40 0 : return std::make_shared<GenericReceiverModel<fddetdataformats::CRTBernFrame>>(receiver_connection_name);
41 0 : } else if (dt.find("CRTGrenobleFrame") != std::string::npos) {
42 0 : return std::make_shared<GenericReceiverModel<fddetdataformats::CRTGrenobleFrame>>(receiver_connection_name);
43 : }
44 :
45 0 : return nullptr;
46 0 : }
47 :
48 : } // namespace dunedaq::asiolibs
49 :
50 : #endif // ASIOLIBS_SRC_CREATEGENERICRECEIVER_HPP_
|