iceoryx_hoofs 2.0.3
Public Types | Public Member Functions | List of all members
iox::cxx::MethodCallback< ReturnValue, Args > Class Template Reference

Public Types

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

Public Member Functions

 MethodCallback (const MethodCallback &rhs) noexcept=default
 
MethodCallbackoperator= (const MethodCallback &rhs) 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. More...
 
 MethodCallback (MethodCallback &&rhs) noexcept
 Move constructor. More...
 
MethodCallbackoperator= (MethodCallback &&rhs) noexcept
 Move assignment operator. More...
 
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. More...
 
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.
 
 operator bool () const noexcept
 Verifies if the MethodCallback is valid. More...
 
bool isValid () const noexcept
 Verifies if the MethodCallback is valid. More...
 
template<typename ClassType >
void setCallback (ClassType &objectRef, MethodPointer< ClassType > methodPtr) noexcept
 Sets a new callback. More...
 
template<typename ClassType >
ClassType * getObjectPointer () const noexcept
 Returns objectRef.
 
template<typename ClassType >
auto getMethodPointer () const noexcept -> MethodPointer< ClassType >
 Returns cond method pointer.
 

Constructor & Destructor Documentation

◆ MethodCallback() [1/2]

template<typename ReturnValue , typename... Args>
template<typename ClassType >
iox::cxx::MethodCallback< ReturnValue, Args >::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
[in]objectRefobject reference
[in]methodPtrpointer to a method

◆ MethodCallback() [2/2]

template<typename ReturnValue , typename... Args>
iox::cxx::MethodCallback< ReturnValue, Args >::MethodCallback ( MethodCallback< ReturnValue, Args > &&  rhs)
noexcept

Move constructor.

Parameters
[in]rhsmove origin

Member Function Documentation

◆ isValid()

template<typename ReturnValue , typename... Args>
bool iox::cxx::MethodCallback< ReturnValue, Args >::isValid ( ) const
noexcept

Verifies if the MethodCallback is valid.

Returns
true if objectRef != nullptr otherwise false

◆ operator bool()

template<typename ReturnValue , typename... Args>
iox::cxx::MethodCallback< ReturnValue, Args >::operator bool ( ) const
explicitnoexcept

Verifies if the MethodCallback is valid.

Returns
true if objectRef != nullptr otherwise false

◆ operator()()

template<typename ReturnValue , typename... Args>
template<typename... MethodArguments>
expected< ReturnValue, MethodCallbackError > iox::cxx::MethodCallback< ReturnValue, Args >::operator() ( MethodArguments &&...  args)
noexcept

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

Parameters
[in]args...arguments which will be perfectly forwarded to the method
Returns
If MethodCallback is valid the return value of the method, otherwise an error.

◆ operator=()

template<typename ReturnValue , typename... Args>
MethodCallback & iox::cxx::MethodCallback< ReturnValue, Args >::operator= ( MethodCallback< ReturnValue, Args > &&  rhs)
noexcept

Move assignment operator.

Parameters
[in]rhsmove origin
Returns
reference to this

◆ setCallback()

template<typename ReturnValue , typename... Args>
template<typename ClassType >
void iox::cxx::MethodCallback< ReturnValue, Args >::setCallback ( ClassType &  objectRef,
MethodPointer< ClassType >  methodPtr 
)
noexcept

Sets a new callback.

Parameters
[in]objectRefconst reference to the object
[in]methodPtrpointer to the method

The documentation for this class was generated from the following file: