Line data Source code
1 : /**
2 : * @file dal_methods.cpp
3 : *
4 : * This is part of the DUNE DAQ Software Suite, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "pybind11/operators.h"
10 : #include "pybind11/pybind11.h"
11 : #include "pybind11/stl.h"
12 :
13 : #include "confmodel/DaqModule.hpp"
14 : #include "confmodel/Session.hpp"
15 :
16 : #include "appmodel/SmartDaqApplication.hpp"
17 :
18 : #include <sstream>
19 :
20 : namespace py = pybind11;
21 :
22 : namespace dunedaq::appmodel::python {
23 :
24 : struct ObjectLocator
25 : {
26 0 : ObjectLocator(const std::string& id_arg, const std::string& class_name_arg)
27 0 : : id(id_arg)
28 0 : , class_name(class_name_arg)
29 : {
30 0 : }
31 : const std::string id;
32 : const std::string class_name;
33 : };
34 :
35 : std::vector<ObjectLocator>
36 0 : smart_daq_application_generate_modules(const conffwk::Configuration& confdb,
37 : const std::string& app_id,
38 : const std::string& session_id)
39 : {
40 0 : auto app = const_cast<conffwk::Configuration&>(confdb).get<appmodel::SmartDaqApplication>(app_id);
41 0 : auto session = const_cast<conffwk::Configuration&>(confdb).get<confmodel::Session>(session_id);
42 :
43 0 : auto helper = std::make_shared<ConfigurationHelper>(session);
44 0 : app->generate_modules(helper);
45 0 : std::vector<ObjectLocator> mods;
46 0 : for (auto mod : app->get_modules()) {
47 0 : mods.push_back({ mod->UID(), mod->class_name() });
48 : }
49 0 : return mods;
50 0 : }
51 :
52 : void
53 0 : register_dal_methods(py::module& m)
54 : {
55 0 : py::class_<ObjectLocator>(m, "ObjectLocator")
56 0 : .def(py::init<const std::string&, const std::string&>())
57 0 : .def_readonly("id", &ObjectLocator::id)
58 0 : .def_readonly("class_name", &ObjectLocator::class_name);
59 :
60 0 : m.def("smart_daq_application_generate_modules", &smart_daq_application_generate_modules, "Generate DaqModules");
61 0 : }
62 :
63 : } // namespace dunedaq::appmodel::python
|