Kanzi Connect  3.9.9
Kanzi Connect C++ API
kanzi::connect::RPCResultImpl< _T > Class Template Reference

Base template class for non-void RPC results. More...

#include <rpcresult.hpp>

Inheritance diagram for kanzi::connect::RPCResultImpl< _T >:
kanzi::connect::RPCResultBase< _T >

Public Types

typedef function< void(RPCResult< _T > &)> CallbackFunctionType
 Callback function type. More...
 

Public Member Functions

RPCTypes::CallbackFunctionSubscriptionToken addCallback (CallbackFunctionType callback)
 Adds a callback to listen method response. More...
 
bool completeIfTimedOut (const chrono::steady_clock::time_point &)
 Completes the operation if it has been timed out. More...
 
void completeLinkBroken ()
 Completes the operation with link broken status. More...
 
void doComplete (_T value, int32_t rpcresult=GenericRPCReplyMessage::RPC_RESULT_OK)
 Completes the RPC result promise. More...
 
_T getValue ()
 Gets the value. More...
 
void removeCallback (RPCTypes::CallbackFunctionSubscriptionToken token)
 Removes callback from the callback array. More...
 
 RPCResultImpl (RPCTypes::CommHandle handle)
 C++ constructs - initializes the object. More...
 
- Public Member Functions inherited from kanzi::connect::RPCResultBase< _T >
RPCTypes::CommHandle getHandle () const
 Retrieve the communication handle. More...
 
int32_t getRPCCallResult () const
 Returns the low level RPC result. More...
 
void invalidate ()
 Invalidates the object. More...
 
bool isComplete () const
 Checks whether RPC call is complete. More...
 
 RPCResultBase ()
 C++ constructor - initialize the object. More...
 
bool testIsTimedOut (const chrono::steady_clock::time_point &now) const
 Tests whether operation has timed out. More...
 
bool valid () const
 Determines whether the RPC Result is still valid. More...
 
bool waitComplete (int msToWait) const
 Checks whether RPC call is complete. More...
 

Protected Member Functions

void invokeCallbacks ()
 Invokes all callbacks. More...
 
- Protected Member Functions inherited from kanzi::connect::RPCResultBase< _T >
void setHandle (RPCTypes::CommHandle handle)
 Attach a handle to this object. More...
 
void setTimeout (int ms)
 Sets the timeout for a RPC operation. More...
 

Additional Inherited Members

- Protected Attributes inherited from kanzi::connect::RPCResultBase< _T >
optional< chrono::steady_clock::time_point > m_expires
 
std::shared_future< _T > m_future
 
RPCTypes::CommHandle m_handle
 
shared_ptr< std::promise< _T > > m_promise
 
int32_t m_rpcresult
 

Detailed Description

template<class _T>
class kanzi::connect::RPCResultImpl< _T >

Base template class for non-void RPC results.

Member Typedef Documentation

◆ CallbackFunctionType

template<class _T >
typedef function<void(RPCResult<_T>&)> kanzi::connect::RPCResultImpl< _T >::CallbackFunctionType

Callback function type.

Constructor & Destructor Documentation

◆ RPCResultImpl()

template<class _T >
kanzi::connect::RPCResultImpl< _T >::RPCResultImpl ( RPCTypes::CommHandle  handle)
inline

C++ constructs - initializes the object.

Parameters
handlethe handle for the operation.

Member Function Documentation

◆ addCallback()

template<class _T >
RPCTypes::CallbackFunctionSubscriptionToken kanzi::connect::RPCResultImpl< _T >::addCallback ( CallbackFunctionType  callback)
inline

Adds a callback to listen method response.

Invoked when response is received.

Parameters
callbackpointer to function to call.
Returns
token that can be used to remove callback if needed.

◆ completeIfTimedOut()

template<class _T >
bool kanzi::connect::RPCResultImpl< _T >::completeIfTimedOut ( const chrono::steady_clock::time_point &  )

Completes the operation if it has been timed out.

Returns
true if timed out

◆ completeLinkBroken()

template<class _T >
void kanzi::connect::RPCResultImpl< _T >::completeLinkBroken ( )

Completes the operation with link broken status.

◆ doComplete()

template<class _T >
void kanzi::connect::RPCResultImpl< _T >::doComplete ( _T  value,
int32_t  rpcresult = GenericRPCReplyMessage::RPC_RESULT_OK 
)
inline

Completes the RPC result promise.

Parameters
valuecomplete value

◆ getValue()

template<class _T >
_T kanzi::connect::RPCResultImpl< _T >::getValue ( )
inline

Gets the value.

Note
can be called only once.
Returns
the value of the future.

◆ invokeCallbacks()

template<class _T >
void kanzi::connect::RPCResultImpl< _T >::invokeCallbacks ( )
inlineprotected

Invokes all callbacks.

There can be any number of them configured for a single RPC call completion.

allow callback to get removed from callback itself. If new callback is added from callback it won't be called.

◆ removeCallback()

template<class _T >
void kanzi::connect::RPCResultImpl< _T >::removeCallback ( RPCTypes::CallbackFunctionSubscriptionToken  token)
inline

Removes callback from the callback array.

Parameters
tokencallback to remove, token returned by addCallback function.

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