Line data Source code
1 : /**
2 : * @file sourceid.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 "daqdataformats/SourceID.hpp"
10 :
11 : #include <pybind11/operators.h>
12 : #include <pybind11/pybind11.h>
13 : #include <pybind11/stl.h>
14 :
15 : #include <sstream>
16 :
17 : namespace py = pybind11;
18 :
19 : namespace dunedaq::daqdataformats::python {
20 :
21 : void
22 0 : register_sourceid(py::module& m)
23 : {
24 :
25 0 : py::class_<SourceID> py_sourceid(m, "SourceID");
26 0 : py_sourceid.def(py::init()).def(py::init<const SourceID::Subsystem&, const SourceID::ID_t&>());
27 0 : py_sourceid.def(py::self < py::self).def("__repr__", [](const SourceID& gid) {
28 0 : std::ostringstream oss;
29 0 : oss << "<daqdataformats::SourceID " << gid << ">";
30 0 : return oss.str();
31 0 : });
32 :
33 0 : py::enum_<SourceID::Subsystem>(py_sourceid, "Subsystem")
34 0 : .value("kUnknown", SourceID::Subsystem::kUnknown)
35 0 : .value("kDetectorReadout", SourceID::Subsystem::kDetectorReadout)
36 0 : .value("kHwSignalsInterface", SourceID::Subsystem::kHwSignalsInterface)
37 0 : .value("kTrigger", SourceID::Subsystem::kTrigger)
38 0 : .value("kTRBuilder", SourceID::Subsystem::kTRBuilder)
39 0 : .export_values();
40 :
41 0 : py_sourceid.def_readwrite("version", &SourceID::version)
42 0 : .def_readwrite("subsystem", &SourceID::subsystem)
43 0 : .def_readwrite("id", &SourceID::id);
44 :
45 0 : py_sourceid.def("subsystem_to_string", &SourceID::subsystem_to_string)
46 0 : .def("string_to_subsystem", &SourceID::string_to_subsystem)
47 0 : .def("to_string", &SourceID::to_string);
48 0 : }
49 :
50 : } // namespace dunedaq::daqdataformats::python
|