Wraps a class derived from pybind11::object and ensures that the GIL is acquired when the PyObject is destroyed. For any other operation on this wrapper, the GIL still needs to be acquired manually before!
More...
|
void | Remove () |
| Removes the owned pybind11::object after locking the GIL. More...
|
|
|
std::unique_ptr< T > | Object |
| Object derived from pybind11::object owned by this PyObject instance. More...
|
|
template<typename T, std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
class Util::PyObject< T, >
Wraps a class derived from pybind11::object and ensures that the GIL is acquired when the PyObject is destroyed. For any other operation on this wrapper, the GIL still needs to be acquired manually before!
- Template Parameters
-
T | Type derived from pybind11::object |
Definition at line 66 of file PyUtil.h.
◆ ObjectType
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
◆ PyObject() [1/2]
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
◆ PyObject() [2/2]
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
Copy-constructs a PyObject from Object
.
- Parameters
-
Definition at line 80 of file PyUtil.h.
◆ ~PyObject()
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
Removes the owned pybind11::object
after locking the GIL.
Definition at line 85 of file PyUtil.h.
◆ Get() [1/2]
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
Returns the wrapped pybind11::object
.
- Returns
- Owned object or nullptr if no object is owned
Definition at line 102 of file PyUtil.h.
◆ Get() [2/2]
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
Returns the wrapped pybind11::object
. noexcept
- Returns
- Owned object or nullptr if no object is owned noexcept
Definition at line 107 of file PyUtil.h.
◆ operator()()
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
template<typename... ArgTs>
Calls the wrapped object if it is not nullptr and if the wrapped object is not pybind11::none.
- Template Parameters
-
...ArgTs | Types of the perfectly forward arguments |
- Parameters
-
...Args | Arguments to perfectly forward to the wrapped object's call. |
- Returns
- Return value of the call of type derived from pybind11::object or pybind11::none if the call did not happen.
Definition at line 128 of file PyUtil.h.
◆ operator=()
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
Locks the GIL, removes the owned object and copy-assigns from Object
.
- Parameters
-
- Returns
- Reference to this PyObject instance
Definition at line 92 of file PyUtil.h.
◆ Remove()
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
Removes the owned pybind11::object
after locking the GIL.
Definition at line 140 of file PyUtil.h.
◆ Reset()
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
Removes the owned pybind11::object
after locking the GIL.
This PyObject instance does not own an object after this operation.
Definition at line 113 of file PyUtil.h.
◆ Object
template<typename T , std::enable_if_t< std::is_base_of_v< py::object, T >, int > = 0>
Object derived from pybind11::object
owned by this PyObject instance.
Definition at line 149 of file PyUtil.h.
The documentation for this class was generated from the following file: