ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
PyVariableGroup.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 "PyVariableGroup.h"
5
6#include "PyReadAnyGroup.h"
7
8#include <pybind11/stl.h>
9
10namespace py = pybind11;
11
12namespace ChimeraTK {
13
14 /********************************************************************************************************************/
15
21 py::class_<VariableGroup>(m, "VariableGroupBase")
22 .def("getName", &VariableGroup::getName, "Get the name of the module instance.")
23 .def(
24 "readAnyGroup", [](VariableGroup& self) { return PyReadAnyGroup(self.readAnyGroup()); },
25 "Create a ChimeraTK::ReadAnyGroup for all readable variables in this Module.")
26 .def(
27 "readAll",
28 [](VariableGroup& self, bool includeReturnChannels) {
29 py::gil_scoped_release release;
30 self.readAll(includeReturnChannels);
31 },
32 "Read all readable variables in the group.\n\nIf there are push-type variables in the group, this call "
33 "will block until all of the variables have received an update. All push-type variables are read first, "
34 "the poll-type variables are therefore updated with the latest values upon return. includeReturnChannels "
35 "determines whether return channels of *OutputRB accessors are included in the read.",
36 py::arg("includeReturnChannels") = false)
37 .def(
38 "readAllLatest",
39 [](VariableGroup& self, bool includeReturnChannels) {
40 py::gil_scoped_release release;
41 self.readAllLatest(includeReturnChannels);
42 },
43 "Just call readLatest() on all readable variables in the group.\n\nincludeReturnChannels determines "
44 "whether return channels of *OutputRB accessors are included in the read.",
45 py::arg("includeReturnChannels") = false)
46
47 .def(
48 "readAllNonBlocking",
49 [](VariableGroup& self, bool includeReturnChannels) {
50 py::gil_scoped_release release;
51 self.readAllNonBlocking(includeReturnChannels);
52 },
53 "Just call readNonBlocking() on all readable variables in the group.\n\nincludeReturnChannels determines "
54 "whether return channels of *OutputRB accessors are included in the read.",
55 py::arg("includeReturnChannels") = false)
56 .def(
57 "writeAll",
58 [](VariableGroup& self, bool includeReturnChannels) {
59 py::gil_scoped_release release;
60 self.writeAll(includeReturnChannels);
61 },
62 "Just call write() on all writable variables in the group.\n\nincludeReturnChannels determines whether "
63 "return channels of *InputWB accessors are included in the write.",
64 py::arg("includeReturnChannels") = false)
65 .def(
66 "writeAllDestructively",
67 [](VariableGroup& self, bool includeReturnChannels) {
68 py::gil_scoped_release release;
69 self.writeAllDestructively(includeReturnChannels);
70 },
71 "Just call writeDestructively() on all writable variables in the group.\n\nincludeReturnChannels "
72 "determines whether return channels of *InputWB accessors are included in the write.",
73 py::arg("includeReturnChannels") = false);
74
78 // return_value_policy::reference is not enough in constructor factory function.
79 // in order to turn off memory management by python, we also need to adapt custom holder type and remove deleter.
80 py::class_<PyVariableGroup, VariableGroup, PyOwningObject, std::unique_ptr<PyVariableGroup, py::nodelete>> vg(
81 m, "VariableGroup", py::dynamic_attr(), py::multiple_inheritance());
82
83 vg.def(py::init([](VariableGroup& owner, const std::string& name, const std::string& description,
84 const std::unordered_set<std::string>& tags) {
85 return dynamic_cast<PyOwningObject&>(owner).make_child<PyVariableGroup>(&owner, name, description, tags);
86 }),
87 py::return_value_policy::reference,
88 // doc and default args:
89 "", py::arg("owner"), py::arg("name"), py::arg("description"),
90 py::arg("tags") = std::unordered_set<std::string>{});
91 }
92
93 /********************************************************************************************************************/
94
95} // namespace ChimeraTK
const std::string & getName() const
Get the name of the module instance.
Definition EntityOwner.h:59
void readAllLatest(bool includeReturnChannels=false)
Just call readLatest() on all readable variables in the group.
Definition Module.cc:138
void readAll(bool includeReturnChannels=false)
Read all readable variables in the group.
Definition Module.cc:72
void readAllNonBlocking(bool includeReturnChannels=false)
Just call readNonBlocking() on all readable variables in the group.
Definition Module.cc:106
void writeAllDestructively(bool includeReturnChannels=false)
Just call writeDestructively() on all writable variables in the group.
Definition Module.cc:177
ChimeraTK::ReadAnyGroup readAnyGroup()
Create a ChimeraTK::ReadAnyGroup for all readable variables in this Module.
Definition Module.cc:54
void writeAll(bool includeReturnChannels=false)
Just call write() on all writable variables in the group.
Definition Module.cc:157
Base class used for all objects in the Python world which can own other objects and can be owned them...
static void bind(py::module &m)
InvalidityTracer application module.
module_ module