Template Class ConstMethodCallback

Class Documentation

template<typename ReturnValue, typename ...Args>
class ConstMethodCallback

Public Types

template<typename T>
using ConstMethodPointer = ReturnValue (T::*)(Args...) const

Public Functions

ConstMethodCallback() noexcept = default
ConstMethodCallback(const ConstMethodCallback &rhs) noexcept = default
ConstMethodCallback &operator=(const ConstMethodCallback &rhs) noexcept = default
~ConstMethodCallback() noexcept = default
template<typename ClassType>
ConstMethodCallback(const ClassType &objectRef, ConstMethodPointer<ClassType> const methodPtr) noexcept

Constructs a ConstMethodCallback from a pointer to a specific object and a pointer to a method of that class.

Parameters:
  • objectRef[in] const object reference

  • methodPtr[in] pointer to a const method

ConstMethodCallback(ConstMethodCallback &&rhs) noexcept

Move constructor.

Parameters:

rhs[in] move origin

ConstMethodCallback &operator=(ConstMethodCallback &&rhs) noexcept

Move assignment operator.

Parameters:

rhs[in] move origin

Returns:

reference to this

template<typename ...MethodArguments>
expected<ReturnValue, MethodCallbackError> operator()(MethodArguments&&... args) const noexcept

Calls the method if the ConstMethodCallback is valid, otherwise it will return MethodCallbackError::UNINITIALIZED_CALLBACK.

Parameters:

args...[in] arguments which will be perfectly forwarded to the method

Returns:

If ConstMethodCallback is valid the return value of the method, otherwise an error.

bool operator==(const ConstMethodCallback &rhs) const noexcept

Comparison operator. Two ConstMethodCallbacks are equal if they have the same object pointer and method pointer.

bool operator!=(const ConstMethodCallback &rhs) const noexcept

Inequality operator. Two ConstMethodCallback are not equal if they have different object or method pointer.

explicit operator bool() const noexcept

Verifies if the ConstMethodCallback is valid.

Returns:

true if objectRef != nullptr otherwise false

bool isValid() const noexcept

Verifies if the ConstMethodCallback is valid.

Returns:

true if objectRef != nullptr otherwise false

template<typename ClassType>
void setCallback(const ClassType &objectRef, ConstMethodPointer<ClassType> methodPtr) noexcept

Sets a new callback.

Parameters:
  • objectRef[in] const reference to the object

  • methodPtr[in] pointer to the method

template<typename ClassType>
const ClassType *getObjectPointer() const noexcept

Returns object pointer.

template<typename ClassType>
auto getMethodPointer() const noexcept -> ConstMethodPointer<ClassType>

Returns cond method pointer.