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 0 : ObjectLocator(const std::string& id_arg, const std::string& class_name_arg) :
26 0 : id(id_arg), class_name(class_name_arg)
27 0 : {}
28 : const std::string id;
29 : const std::string class_name;
30 : };
31 :
32 : std::vector<ObjectLocator>
33 0 : smart_daq_application_generate_modules(const conffwk::Configuration& confdb, const std::string& app_id, const std::string& session_id)
34 : {
35 0 : auto app =
36 0 : const_cast<conffwk::Configuration&>(confdb).get<appmodel::SmartDaqApplication>(app_id);
37 0 : auto session =
38 0 : const_cast<conffwk::Configuration&>(confdb).get<confmodel::Session>(session_id);
39 :
40 0 : auto helper = std::make_shared<ConfigurationHelper>(session);
41 0 : app->generate_modules(helper);
42 0 : std::vector<ObjectLocator> mods;
43 0 : for (auto mod : app->get_modules()) {
44 0 : mods.push_back({mod->UID(),mod->class_name()});
45 : }
46 0 : return mods;
47 0 : }
48 :
49 :
50 : void
51 0 : register_dal_methods(py::module& m)
52 : {
53 0 : py::class_<ObjectLocator>(m, "ObjectLocator")
54 0 : .def(py::init<const std::string&, const std::string&>())
55 0 : .def_readonly("id", &ObjectLocator::id)
56 0 : .def_readonly("class_name", &ObjectLocator::class_name)
57 : ;
58 :
59 0 : m.def("smart_daq_application_generate_modules", &smart_daq_application_generate_modules, "Generate DaqModules");
60 0 : }
61 :
62 : } // namespace dunedaq::appmodel::python
|