Line data Source code
1 : /**
2 : * @file CreateSource.hpp Specific SourceConcept 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 CRTMODULES_SRC_CREATESOURCE_HPP_
9 : #define CRTMODULES_SRC_CREATESOURCE_HPP_
10 :
11 : #include "SourceConcept.hpp"
12 : #include "SourceModel.hpp"
13 : #include "datahandlinglibs/DataHandlingIssues.hpp"
14 :
15 : #include "fdreadoutlibs/CRTBernTypeAdapter.hpp"
16 : #include "fdreadoutlibs/CRTGrenobleTypeAdapter.hpp"
17 :
18 : #include <memory>
19 : #include <string>
20 :
21 : namespace dunedaq {
22 :
23 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::CRTBernTypeAdapter, "CRTBernFrame")
24 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter, "CRTGrenobleFrame")
25 :
26 : namespace crtmodules {
27 :
28 : std::shared_ptr<SourceConcept>
29 0 : createSourceModel(const std::string& conn_uid, bool callback_mode)
30 : {
31 0 : auto datatypes = dunedaq::iomanager::IOManager::get()->get_datatypes(conn_uid);
32 0 : if (datatypes.size() != 1) {
33 0 : ers::error(dunedaq::datahandlinglibs::GenericConfigurationError(ERS_HERE,
34 0 : "Multiple output data types specified! Expected only a single type!"));
35 : }
36 0 : std::string raw_dt{ *datatypes.begin() };
37 0 : TLOG() << "Choosing specializations for SourceModel for output connection "
38 0 : << " [uid:" << conn_uid << " , data_type:" << raw_dt << ']';
39 :
40 0 : if (raw_dt.find("CRTBernFrame") != std::string::npos) {
41 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::CRTBernTypeAdapter>>();
42 0 : source_model->set_sink_name(conn_uid);
43 0 : source_model->set_sink(conn_uid, callback_mode);
44 0 : return source_model;
45 0 : } else if (raw_dt.find("CRTGrenobleFrame") != std::string::npos) {
46 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::CRTGrenobleTypeAdapter>>();
47 0 : source_model->set_sink_name(conn_uid);
48 0 : source_model->set_sink(conn_uid, callback_mode);
49 0 : return source_model;
50 0 : }
51 :
52 0 : return nullptr;
53 0 : }
54 :
55 : } // namespace crtmodules
56 : } // namespace dunedaq
57 :
58 : #endif // CRTMODULES_SRC_CREATESOURCE_HPP_
|