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 "fdreadoutlibs/CRTBernTypeAdapter.hpp"
15 : #include "fdreadoutlibs/CRTGrenobleTypeAdapter.hpp"
16 :
17 : #include "datahandlinglibs/DataHandlingIssues.hpp"
18 :
19 : #include <memory>
20 :
21 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::CRTBernTypeAdapter, "CRTBernFrame")
22 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter, "CRTGrenobleFrame")
23 :
24 : namespace dunedaq::asiolibs {
25 :
26 : std::shared_ptr<GenericReceiverConcept>
27 0 : createGenericReceiver(const std::string& conn_uid, const std::string& raw_data_receiver_connection_name)
28 : {
29 0 : const auto datatypes = dunedaq::iomanager::IOManager::get()->get_datatypes(conn_uid);
30 0 : if (datatypes.size() != 1) {
31 0 : ers::error(dunedaq::datahandlinglibs::GenericConfigurationError(ERS_HERE,
32 0 : "Multiple output data types specified! Expected only a single type!"));
33 : }
34 0 : const std::string raw_dt = *datatypes.begin();
35 0 : TLOG() << "Choosing specializations for GenericReceiverConcept for output connection "
36 0 : << " [uid:" << conn_uid << " , data_type:" << raw_dt << ']';
37 :
38 0 : if (raw_dt.find("CRTBernFrame") != std::string::npos) {
39 0 : return std::make_shared<GenericReceiverModel<fdreadoutlibs::types::CRTBernTypeAdapter>>(raw_data_receiver_connection_name);
40 0 : } else if (raw_dt.find("CRTGrenobleFrame") != std::string::npos) {
41 0 : return std::make_shared<GenericReceiverModel<fdreadoutlibs::types::CRTGrenobleTypeAdapter>>(raw_data_receiver_connection_name);
42 : }
43 :
44 0 : return nullptr;
45 0 : }
46 :
47 : } // namespace dunedaq::asiolibs
48 :
49 : #endif // ASIOLIBS_SRC_CREATEGENERICRECEIVER_HPP_
|