ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
PyModuleGroup.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#include <pybind11/embed.h>
5// pybind11 includes should come first
6
7#include "PyModuleGroup.h"
8
9#include <pybind11/stl.h>
10
11namespace py = pybind11;
12
13namespace ChimeraTK {
14
15 /********************************************************************************************************************/
16
22 py::class_<ModuleGroup>(m, "ModuleGroupBase")
23 .def("getName", &ModuleGroup::getName, R"(Get the name of the module instance.)");
24
28 // return_value_policy::reference is not enough in constructor factory function.
29 // in order to turn off memory management by python, we also need to adapt custom holder type and remove deleter.
30 py::class_<PyModuleGroup, ModuleGroup, PyOwningObject, std::unique_ptr<PyModuleGroup, py::nodelete>> mg(
31 m, "ModuleGroup", py::dynamic_attr(), py::multiple_inheritance());
32 mg.def(py::init([](ModuleGroup& owner, const std::string& name, const std::string& description,
33 const std::unordered_set<std::string>& tags) {
34 return dynamic_cast<PyOwningObject&>(owner).make_child<PyModuleGroup>(&owner, name, description, tags);
35 }),
36 py::return_value_policy::reference,
37 // doc and default args:
38 "", py::arg("owner"), py::arg("name"), py::arg("description"),
39 py::arg("tags") = std::unordered_set<std::string>{});
40 }
41
42 /********************************************************************************************************************/
43
44} // namespace ChimeraTK
const std::string & getName() const
Get the name of the module instance.
Definition EntityOwner.h:59
static void bind(pybind11::module &mod)
Base class used for all objects in the Python world which can own other objects and can be owned them...
InvalidityTracer application module.
module_ module