Kanzi Connect 3.9.10
kanzi::connect::Method Class Reference

Method class implementation. More...

#include <genericserviceclient.hpp>

Inheritance diagram for kanzi::connect::Method:

Classes

class  CallbackEx
 Traditional c++ callback interface for external application bindings (Java) More...
 

Public Types

typedef function< void(MethodSharedPtr, Method::InvocationResult, string)> InvocationCallback
 invocation callback function prototype
 
enum  InvocationResult {
  InvokeInProgress , InvokeSucceeded , InvokeFailedSignatureMismatch , InvokeFailedIntrospectionFailure ,
  InvokeFailedTimedOut , InvokeFailedLinkBroken , InvokeFailedNoService , InvokeFailed
}
 Result of a method invocation. More...
 

Public Member Functions

MethodaddArgument (const string &argumentName, bool argumentValue)
 add named boolean argument
 
MethodaddArgument (const string &argumentName, const char *argumentValue)
 add named string argument
 
MethodaddArgument (const string &argumentName, const string &argumentValue)
 Adds named string argument.
 
MethodaddArgument (const string &argumentName, float argumentValue)
 add named float argument
 
MethodaddArgument (const string &argumentName, int argumentValue)
 add named integer argument
 
MethodaddBinaryArgument (const string &argumentName, const string &argumentValue)
 add named binary argument
 
bool argumentHasType (const string &argumentName, int messagePackageArgumentType) const
 Check is the argument type correct or not.
 
bool cancel ()
 Cancel a method invocation.
 
template<class _T >
_T getArgument (const string &argumentName) const
 Retrieve typed argument from variant map.
 
uint32_t getInvocationTimeout () const
 Return configured invocation timeout.
 
const string & getName () const
 Returns the method name.
 
bool hasArgument (const string &argumentName) const
 Is the named argument provided.
 
InvocationResult invoke (InvocationCallback callback)
 Invokes the method immediately.
 
InvocationResult invokeEx (CallbackEx *callback)
 
InvocationResult invokeQueued (InvocationCallback callback)
 Invokes the method immediately but if that is not possible then invocation is queued and executed later when invocation is possible again.
 
InvocationResult invokeQueuedEx (CallbackEx *callback)
 
 Method (GenericServiceClientSharedPtr service, const string &methodName)
 C++ constructor.
 
void setInvocationTimeout (uint32_t milliseconds)
 Configures method invcation timeout.
 
 ~Method ()
 dtor
 

Friends

class GenericServiceClient
 

Detailed Description

Method class implementation.

Member Typedef Documentation

◆ InvocationCallback

invocation callback function prototype

Member Enumeration Documentation

◆ InvocationResult

Result of a method invocation.

Enumerator
InvokeInProgress 

Returned from invocation methods when invocation requires asynchronous processing or returns a value in which case the final comletion is through callback.

After invoke returns this value then the final value will be available in the callback.

InvokeSucceeded 

Method invocation succeeded.

InvokeFailedSignatureMismatch 

Method could not invoked because either the method name is wrong, or passed in arguments don't mach with method signature.

InvokeFailedIntrospectionFailure 

Method could not be invoed because method signature introspection failed for some reason.

InvokeFailedTimedOut 

Method was triggered but returnvalue was not received within specified invocation timeout.

InvokeFailedLinkBroken 

Method was triggered but invocation overall status is not known since connection got broken.

InvokeFailedNoService 

returned if service is not available when invoking a method.

InvokeFailed 

Method invocation failed for unknown reason.

Constructor & Destructor Documentation

◆ Method()

kanzi::connect::Method::Method ( GenericServiceClientSharedPtr service,
const string & methodName )
explicit

C++ constructor.

This is not intenteded to be used directly, instead use GenericServiceClient::createMethod to factorize methods bound to a service.

Parameters
servicethe service method is bound to
methodNamename of the method.

◆ ~Method()

kanzi::connect::Method::~Method ( )

dtor

Member Function Documentation

◆ addArgument() [1/5]

Method & kanzi::connect::Method::addArgument ( const string & argumentName,
bool argumentValue )

add named boolean argument

Parameters
argumentNamethe name of the argument
argumentValuevalue for the argument.
Returns
reference to the method to allow chaining setup of arguments.

◆ addArgument() [2/5]

Method & kanzi::connect::Method::addArgument ( const string & argumentName,
const char * argumentValue )

add named string argument

Parameters
argumentNamethe name of the argument
argumentValuevalue for the argument.
Returns
reference to the method to allow chaining setup of arguments.

◆ addArgument() [3/5]

Method & kanzi::connect::Method::addArgument ( const string & argumentName,
const string & argumentValue )

Adds named string argument.

Parameters
argumentNamethe name of the argument
argumentValuevalue for the argument.
Returns
reference to the method to allow chaining setup of arguments.

◆ addArgument() [4/5]

Method & kanzi::connect::Method::addArgument ( const string & argumentName,
float argumentValue )

add named float argument

Parameters
argumentNamethe name of the argument
argumentValuevalue for the argument.
Returns
reference to the method to allow chaining setup of arguments.

◆ addArgument() [5/5]

Method & kanzi::connect::Method::addArgument ( const string & argumentName,
int argumentValue )

add named integer argument

Parameters
argumentNamethe name of the argument
argumentValuevalue for the argument.
Returns
reference to the method to allow chaining setup of arguments.

◆ addBinaryArgument()

Method & kanzi::connect::Method::addBinaryArgument ( const string & argumentName,
const string & argumentValue )

add named binary argument

Parameters
argumentNamethe name of the argument
argumentValuevalue for the argument.
Returns
reference to the method to allow chaining setup of arguments.

◆ argumentHasType()

bool kanzi::connect::Method::argumentHasType ( const string & argumentName,
int messagePackageArgumentType ) const

Check is the argument type correct or not.

Parameters
argumentNamename of the argument to inspect
messagePackageArgumentTypeone of MessagePackage::ATTRIBUTE_VALUE_TYPE_* enumerations.
Returns
true if type matches.

◆ cancel()

bool kanzi::connect::Method::cancel ( )

Cancel a method invocation.

Effectivy only if method was invoked in queued manner and it was still waiting for invocation.

Returns
true if operation was canceled.

◆ getArgument()

template<class _T >
_T kanzi::connect::Method::getArgument ( const string & argumentName) const
inline

Retrieve typed argument from variant map.

Parameters
argumentNamename of the argument

◆ getInvocationTimeout()

uint32_t kanzi::connect::Method::getInvocationTimeout ( ) const

Return configured invocation timeout.

Returns
milliseconds

◆ getName()

const string & kanzi::connect::Method::getName ( ) const

Returns the method name.

Returns
the name

◆ hasArgument()

bool kanzi::connect::Method::hasArgument ( const string & argumentName) const

Is the named argument provided.

Parameters
argumentNamename of the argument to inspect
Returns
true if argument with provided name exists.

◆ invoke()

InvocationResult kanzi::connect::Method::invoke ( InvocationCallback callback)

Invokes the method immediately.

If immediate invocation is not possible based on preconditions, then returns false.

Parameters
callbackthe callback that is invoked when method invocation is complete or it has failed due the some error. If method returns true then callback will be called at some point.
Returns
true if method invocation was started.

◆ invokeEx()

InvocationResult kanzi::connect::Method::invokeEx ( CallbackEx * callback)
See also
invokeImmediate
Note
This is intented for external application bindings (Java)

◆ invokeQueued()

InvocationResult kanzi::connect::Method::invokeQueued ( InvocationCallback callback)

Invokes the method immediately but if that is not possible then invocation is queued and executed later when invocation is possible again.

Parameters
callbackthe callback that is invoked when method invocation is complete or it has failed due the some error. If method returns true then callback will be called at some point.
Returns
true if method invocation was started.

◆ invokeQueuedEx()

InvocationResult kanzi::connect::Method::invokeQueuedEx ( CallbackEx * callback)
See also
invokeQueued
Note
This is intented for external application bindings (Java)

◆ setInvocationTimeout()

void kanzi::connect::Method::setInvocationTimeout ( uint32_t milliseconds)

Configures method invcation timeout.

Parameters
millisecondsthe timeout value. Mimimum accepted value is 100, maximum is INT_MAX.

Friends And Related Symbol Documentation

◆ GenericServiceClient

friend class GenericServiceClient
friend

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