S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_call_method_manager.h File Reference

Contains the types to be used by the method call manager to configure the Call service. SOPC_MethodCallManager is thread-safe for adding methods at runtime. More...

Go to the source code of this file.

Data Structures

struct  SOPC_MethodCallFunc
 Object to describe of function associated to a method and user parameter. More...
 

Typedefs

typedef struct SOPC_MethodCallManager SOPC_MethodCallManager
 
typedef struct SOPC_MethodCallFunc SOPC_MethodCallFunc
 
typedef SOPC_StatusCode SOPC_MethodCallFunc_Ptr(const SOPC_CallContext *callContextPtr, const SOPC_NodeId *objectId, uint32_t nbInputArgs, const SOPC_Variant *inputArgs, uint32_t *nbOutputArgs, SOPC_Variant **outputArgs, void *param)
 Type of the function to call associated to a method.
 
typedef void SOPC_MethodCallFunc_Free_Func(void *data)
 Type of the function to free param of SOPC_MethodCallFunc.
 

Functions

SOPC_MethodCallManagerSOPC_MethodCallManager_Create (void)
 Provide an instance of MethodCallManager. This implementation can be used with SOPC_MethodCallManager_AddMethod or SOPC_MethodCallManager_AddMethodWithType to add methods.
 
void SOPC_MethodCallManager_Free (SOPC_MethodCallManager *mcm)
 Free MethodCallManager created with SOPC_MethodCallManager_Create.
 
SOPC_ReturnStatus SOPC_MethodCallManager_AddMethod (SOPC_MethodCallManager *mcm, const SOPC_NodeId *methodId, SOPC_MethodCallFunc_Ptr *methodFunc, void *param, SOPC_MethodCallFunc_Free_Func *fnFree)
 Associates a C function to a NodeId of a Method.
 
SOPC_ReturnStatus SOPC_MethodCallManager_AddMethodWithType (SOPC_MethodCallManager *mcm, const SOPC_NodeId *methodInstanceId, const SOPC_NodeId *methodTypeId, SOPC_MethodCallFunc_Ptr *methodFunc, void *param, SOPC_MethodCallFunc_Free_Func *fnFree)
 Associates a C function to two NodeId of a Method (one for method instance and one for method in object type)
 
SOPC_MethodCallFuncSOPC_MethodCallManager_GetMethod (SOPC_MethodCallManager *mcm, const SOPC_NodeId *methodId)
 

Detailed Description

Contains the types to be used by the method call manager to configure the Call service. SOPC_MethodCallManager is thread-safe for adding methods at runtime.

Warning
Methods call are blocking for server services treatment, methods implementation should be lightweight functions (see Part 3 §4.7).

Typedef Documentation

◆ SOPC_MethodCallManager

◆ SOPC_MethodCallFunc

typedef struct SOPC_MethodCallFunc SOPC_MethodCallFunc

◆ SOPC_MethodCallFunc_Ptr

typedef SOPC_StatusCode SOPC_MethodCallFunc_Ptr(const SOPC_CallContext *callContextPtr, const SOPC_NodeId *objectId, uint32_t nbInputArgs, const SOPC_Variant *inputArgs, uint32_t *nbOutputArgs, SOPC_Variant **outputArgs, void *param)

Type of the function to call associated to a method.

Warning
The method callback call is blocking for server services treatment. Thus local services shall not be called synchronously. Method should be lightweight functions (see Part 3 §4.7) and only operations provided by callContextPtr shall be used to interact with server address space synchronously.
Note
Method call service verifies the input arguments before calling a SOPC_MethodCallFunc_Ptr function.
a ByteString could be provided instead of an expected array of Byte and conversely (See Spec 1.03 part 4 - table 66)
Parameters
callContextPtrcontext provided by server on connection/session associated to method call
objectIda valid pointer to the object on which the method is called or a type if the method is static
nbInputArgsnumber of input argument
inputArgsan array of input argument of the method. The size is nbInputArgs.
nbOutputArgsa valid pointer in which the number of output argument is written by the function
outputArgsa valid pointer to an SOPC_Variant[] in which the output arguments are allocated and written by the function
paramuser defined parameter provided to SOPC_MethodCallManager_AddMethod
Returns
status code of the function. Should be SOPC_STATUS_OK if succeeded.

◆ SOPC_MethodCallFunc_Free_Func

typedef void SOPC_MethodCallFunc_Free_Func(void *data)

Type of the function to free param of SOPC_MethodCallFunc.

Parameters
dataa pointer to the object to free. Can be NULL

Function Documentation

◆ SOPC_MethodCallManager_Create()

SOPC_MethodCallManager * SOPC_MethodCallManager_Create ( void )

Provide an instance of MethodCallManager. This implementation can be used with SOPC_MethodCallManager_AddMethod or SOPC_MethodCallManager_AddMethodWithType to add methods.

Returns
a valid SOPC_MethodCallManager pointer or NULL on memory allocation failure.

◆ SOPC_MethodCallManager_Free()

void SOPC_MethodCallManager_Free ( SOPC_MethodCallManager * mcm)

Free MethodCallManager created with SOPC_MethodCallManager_Create.

◆ SOPC_MethodCallManager_AddMethod()

SOPC_ReturnStatus SOPC_MethodCallManager_AddMethod ( SOPC_MethodCallManager * mcm,
const SOPC_NodeId * methodId,
SOPC_MethodCallFunc_Ptr * methodFunc,
void * param,
SOPC_MethodCallFunc_Free_Func * fnFree )

Associates a C function to a NodeId of a Method.

Parameters
mcma valid pointer on a SOPC_MethodCallManager returned by SOPC_MethodCallManager_Create.
methodIda valid pointer on a SOPC_NodeId of the method, content will be copied.
methodFunca valid pointer on a C function to associate with the given methodId.
parama pointer on data to give as parameter when calling methodFunc. It might be NULL.
fnFreea pointer on a C function to free param. Can be NULL.
Returns
SOPC_STATUS_OK when the function succeeded, otherwise SOPC_STATUS_INVALID_PARAMETERS or SOPC_STATUS_OUT_OF_MEMORY.

◆ SOPC_MethodCallManager_AddMethodWithType()

SOPC_ReturnStatus SOPC_MethodCallManager_AddMethodWithType ( SOPC_MethodCallManager * mcm,
const SOPC_NodeId * methodInstanceId,
const SOPC_NodeId * methodTypeId,
SOPC_MethodCallFunc_Ptr * methodFunc,
void * param,
SOPC_MethodCallFunc_Free_Func * fnFree )

Associates a C function to two NodeId of a Method (one for method instance and one for method in object type)

Note
It is a common pattern to use the well known NodeId of the method instance declaration of the object type instead of using the method instance NodeId. This function provides an easy way to register both at same time.
Parameters
mcma valid pointer on a SOPC_MethodCallManager returned by SOPC_MethodCallManager_Create.
methodInstanceIda valid pointer on a SOPC_NodeId of the method instance, content will be copied.
methodTypeIda valid pointer on a SOPC_NodeId of the method instance declaration in type, content will be copied.
methodFunca valid pointer on a C function to associate with the given methodId.
parama pointer on data to give as parameter when calling methodFunc. It might be NULL.
fnFreea pointer on a C function to free param. Can be NULL.
Returns
SOPC_STATUS_OK when the function succeeded, otherwise SOPC_STATUS_INVALID_PARAMETERS or SOPC_STATUS_OUT_OF_MEMORY.

◆ SOPC_MethodCallManager_GetMethod()

SOPC_MethodCallFunc * SOPC_MethodCallManager_GetMethod ( SOPC_MethodCallManager * mcm,
const SOPC_NodeId * methodId )