Template Class MethodCallback
Defined in File method_callback.hpp
Class Documentation
-
template<typename ReturnValue, typename ...Args>
class MethodCallback Public Types
-
template<typename T>
using MethodPointer = ReturnValue (T::*)(Args...)
Public Functions
-
MethodCallback() noexcept = default
-
MethodCallback(const MethodCallback &rhs) noexcept = default
-
MethodCallback &operator=(const MethodCallback &rhs) noexcept = default
-
~MethodCallback() noexcept = default
-
template<typename ClassType>
MethodCallback(ClassType &objectRef, MethodPointer<ClassType> methodPtr) noexcept Constructs a MethodCallback from a pointer to a specific object and a pointer to a method of that object.
- Parameters:
objectRef – [in] object reference
methodPtr – [in] pointer to a method
-
MethodCallback(MethodCallback &&rhs) noexcept
Move constructor.
- Parameters:
rhs – [in] move origin
-
MethodCallback &operator=(MethodCallback &&rhs) noexcept
Move assignment operator.
- Parameters:
rhs – [in] move origin
- Returns:
reference to this
-
template<typename ...MethodArguments>
expected<ReturnValue, MethodCallbackError> operator()(MethodArguments&&... args) noexcept Calls the method if the MethodCallback is valid, otherwise it will return MethodCallbackError::UNINITIALIZED_CALLBACK.
- Parameters:
args... – [in] arguments which will be perfectly forwarded to the method
- Returns:
If MethodCallback is valid the return value of the method, otherwise an error.
-
bool operator==(const MethodCallback &rhs) const noexcept
Comparison operator. Two MethodCallbacks are equal if they have the same object pointer and method pointer.
-
bool operator!=(const MethodCallback &rhs) const noexcept
Inequality operator. Two MethodCallbacks are not equal if they have different object or method pointer.
-
explicit operator bool() const noexcept
Verifies if the MethodCallback is valid.
- Returns:
true if objectRef != nullptr otherwise false
-
bool isValid() const noexcept
Verifies if the MethodCallback is valid.
- Returns:
true if objectRef != nullptr otherwise false
-
template<typename ClassType>
void setCallback(ClassType &objectRef, MethodPointer<ClassType> methodPtr) noexcept Sets a new callback.
- Parameters:
objectRef – [in] const reference to the object
methodPtr – [in] pointer to the method
-
template<typename ClassType>
auto getMethodPointer() const noexcept -> MethodPointer<ClassType> Returns cond method pointer.
-
template<typename T>