Callback
-
class CallbackBase
The CallbackBase class.
This class represents a base class for callback functions. A callback function is a function that is passed as an argument to another function. This class provides functionality for setting, resetting, and checking if the callback function is set.
Subclassed by Module::Callback< CommandResponseState >, Module::Callback< bool >, Module::Callback< T >, Module::Callback< void >
Public Functions
-
inline void reset(py::object &callable)
Resets the callback function to a new value.
This function generates a signature for the
callableobject, and compares it with the expected signature. If the signatures don’t match, the callback function is unset, and aninvalid_argumentexception is thrown.- Parameters:
callable – The new callback function.
- Throws:
std::invalid_argument – If the
callableobject is not a callable or if its signature does not match the expected signature.
-
inline bool is_set() const
Check if the callback function is set.
This function checks if the callback object is not None.
- Returns:
true if the callback function is set, false otherwise.
-
inline void reset(py::object &callable)
-
template<typename T>
class Callback : public Module::CallbackBase The Callback class (with return type).
This class is used for managing user-defined callback functions. It allows assigning a function with well-known signature to be executed at a specific point, and provides mechanisms for invoking the function securely and receiving the return value.
Public Functions
-
template<typename ...Types>
inline bool call(Types&&... values) Calls the callback function with the given values.
- Template Parameters:
Types – The types of the values to pass to the callback
- Parameters:
values – The values to pass to the callback
- Returns:
bool True if the callback was called successfully, false otherwise
-
template<typename ...Types>
-
template<>
class Callback<void> : public Module::CallbackBase The Callback class (no return type).
This class is used for managing user-defined callback functions. It allows assigning a function with well-known signature to be executed at a specific point, and provides mechanisms for invoking the function securely without receiving a return value.
Public Functions
-
template<typename ...Types>
inline bool call(Types&&... values) Calls the callback function with the given values.
- Template Parameters:
Types – The types of the values.
- Parameters:
values – The values to pass to the callback function.
- Returns:
bool Returns true if the callback function is called successfully, false otherwise.
-
inline void getResult()
This callback does not provide a result.
-
template<typename ...Types>