S2OPC OPCUA Toolkit
Data Structures | Typedefs | Functions
sopc_encodeabletype.h File Reference

EncodeableType and services on encodeable object. More...

#include <stddef.h>
#include <stdint.h>
#include "sopc_buffer.h"
#include "sopc_enums.h"

Go to the source code of this file.

Data Structures

struct  SOPC_EncodeableType_FieldDescriptor
 
struct  SOPC_EncodeableType_Struct
 Encodeable object type structure definition. It provides all the services functions associated with the encodeable object for encoding needs. More...
 

Typedefs

typedef void() SOPC_EncodeableObject_PfnInitialize(void *value)
 Initialization function generic signature for an encodeable object. More...
 
typedef void() SOPC_EncodeableObject_PfnClear(void *value)
 Clear function generic signature for an encodeable object. More...
 
typedef SOPC_ReturnStatus() SOPC_EncodeableObject_PfnEncode(const void *value, SOPC_Buffer *buffer, uint32_t nestedStructLevel)
 Encoding function generic signature for an encodeable object *. More...
 
typedef SOPC_ReturnStatus() SOPC_EncodeableObject_PfnDecode(void *value, SOPC_Buffer *msgBuffer, uint32_t nestedStructLevel)
 Decoding function generic signature for an encodeable object. More...
 
typedef SOPC_ReturnStatus() SOPC_EncodeableObject_PfnCopy(void *dest, const void *src)
 Copy function generic signature for an encodeable object. More...
 
typedef SOPC_ReturnStatus() SOPC_EncodeableObject_PfnComp(const void *left, const void *right, int32_t *comp)
 Compare function generic signature for an encodeable object. More...
 
typedef struct SOPC_EncodeableType_FieldDescriptor SOPC_EncodeableType_FieldDescriptor
 
typedef const struct SOPC_EncodeableType_Struct SOPC_EncodeableType
 Encodeable object type structure definition. It provides all the services functions associated with the encodeable object for encoding needs. More...
 

Functions

SOPC_ReturnStatus SOPC_EncodeableType_AddUserType (SOPC_EncodeableType *encoder)
 Registers a user-defined encodeable type. further calls to SOPC_EncodeableType_GetEncodeableType will successfully identify the registered encodeable type. More...
 
SOPC_ReturnStatus SOPC_EncodeableType_RemoveUserType (SOPC_EncodeableType *encoder)
 Removes a user-defined encodeable type previously created by SOPC_EncodeableType_AddUserType. More...
 
SOPC_EncodeableTypeSOPC_EncodeableType_GetUserType (uint16_t nsIndex, uint32_t typeId)
 Retrieve a user-defined encodeable type with the given type Id. More...
 
SOPC_EncodeableTypeSOPC_EncodeableType_GetEncodeableType (uint16_t nsIndex, uint32_t typeId)
 Retrieve a defined encodeable type with the given type Id. It can be a internal defined type or user-defined type. More...
 
const char * SOPC_EncodeableType_GetName (SOPC_EncodeableType *encType)
 Get the name of the given encodeable type. More...
 
void SOPC_EncodeableObject_Initialize (SOPC_EncodeableType *type, void *pValue)
 Initialize an encodeable object of the given encodeable type. More...
 
void SOPC_EncodeableObject_Clear (SOPC_EncodeableType *type, void *pValue)
 Clear an encodeable object of the given encodeable type. More...
 
SOPC_ReturnStatus SOPC_EncodeableObject_Encode (SOPC_EncodeableType *type, const void *pValue, SOPC_Buffer *buf, uint32_t nestedStructLevel)
 Encode an encodeable object of the given encodeable type into a bytes buffer. More...
 
SOPC_ReturnStatus SOPC_EncodeableObject_Decode (SOPC_EncodeableType *type, void *pValue, SOPC_Buffer *buf, uint32_t nestedStructLevel)
 Decode an encodeable object of the given encodeable type from a bytes buffer. More...
 
SOPC_ReturnStatus SOPC_EncodeableObject_Copy (SOPC_EncodeableType *type, void *destValue, const void *srcValue)
 Copy an encodeable object of the given encodeable type. More...
 
SOPC_ReturnStatus SOPC_EncodeableObject_Compare (SOPC_EncodeableType *type, const void *leftValue, const void *rightValue, int32_t *comp)
 Compare 2 encodeable objects of the given encodeable type. More...
 

Detailed Description

EncodeableType and services on encodeable object.

An SOPC_EncodeableType is the description uniquely identified OPC UA type which is composed of an ordered list of type fields which can be either SOPC_EncodeableType or OPC UA built-in types (see sopc_builtintypes.h).

An instance of an SOPC_EncodeableType type is a C structure which contains as first field a pointer to its SOPC_EncodeableType and then the fields of expected types described by its SOPC_EncodeableType (see sopc_types.h, e.g. OpcUa_ReadRequest is the C structure instance of encodeable type OpcUa_ReadRequest_EncodeableType).

An encodeable object is either an instance of an OPC UA built-in type or an instance of an SOPC_EncodeableType. Each encodeable object has several services functions:

Encodeable object types are defined in sopc_builtintypes.h for built-in types and sopc_types.h for internally defined SOPC_EncodeableType types.

Typedef Documentation

◆ SOPC_EncodeableObject_PfnInitialize

typedef void() SOPC_EncodeableObject_PfnInitialize(void *value)

Initialization function generic signature for an encodeable object.

◆ SOPC_EncodeableObject_PfnClear

typedef void() SOPC_EncodeableObject_PfnClear(void *value)

Clear function generic signature for an encodeable object.

◆ SOPC_EncodeableObject_PfnEncode

typedef SOPC_ReturnStatus() SOPC_EncodeableObject_PfnEncode(const void *value, SOPC_Buffer *buffer, uint32_t nestedStructLevel)

Encoding function generic signature for an encodeable object *.

Parameters
valueThe encodeable object instance to encode into buffer. it might be either of encodeable type object with SOPC_EncodeableType* as first field or a built-in type object.
bufferThe buffer in which the encodeable object will be encoded
nestedStructLevelThe number of structure levels encoded until then
Returns
SOPC_STATUS_OK in case of success, the appropriate error status otherwise.

◆ SOPC_EncodeableObject_PfnDecode

typedef SOPC_ReturnStatus() SOPC_EncodeableObject_PfnDecode(void *value, SOPC_Buffer *msgBuffer, uint32_t nestedStructLevel)

Decoding function generic signature for an encodeable object.

Parameters
valueThe encodeable object instance in which buffer will be decoded, it might be either of encodeable type object with SOPC_EncodeableType* as first field or a built-in type object.
bufferThe buffer to decode to fill the encodeable object content
nestedStructLevelThe number of structure levels decoded until then
Returns
SOPC_STATUS_OK in case of success, the appropriate error status otherwise.

◆ SOPC_EncodeableObject_PfnCopy

typedef SOPC_ReturnStatus() SOPC_EncodeableObject_PfnCopy(void *dest, const void *src)

Copy function generic signature for an encodeable object.

Parameters
destThe encodeable object instance in which copy will be done It shall be either an encodeable type object with SOPC_EncodeableType* as first field or a built-in type object.
srcThe encodeable object instance copied into dest. It shall be either an encodeable type object with SOPC_EncodeableType* as first field or a built-in type object.
Returns
SOPC_STATUS_OK in case of success, the appropriate error status otherwise.

◆ SOPC_EncodeableObject_PfnComp

typedef SOPC_ReturnStatus() SOPC_EncodeableObject_PfnComp(const void *left, const void *right, int32_t *comp)

Compare function generic signature for an encodeable object.

Parameters
leftThe left operand encodeable object instance to be compared. It shall be either an encodeable type object with SOPC_EncodeableType* as first field or a built-in type object.
rightThe right operand encodeable object instance to be compared. It shall be either an encodeable type object with SOPC_EncodeableType* as first field or a built-in type object.
[out]compPointer to an integer that will store the comparison result when returned status is SOPC_STATUS_OK. In this latter case:
  • comp < 0 if left < right,
  • comp > 0 if left > right and
  • comp == 0 if left == right.
Returns
SOPC_STATUS_OK in case of success, the appropriate error status otherwise.

◆ SOPC_EncodeableType_FieldDescriptor

◆ SOPC_EncodeableType

Encodeable object type structure definition. It provides all the services functions associated with the encodeable object for encoding needs.

Function Documentation

◆ SOPC_EncodeableType_AddUserType()

SOPC_ReturnStatus SOPC_EncodeableType_AddUserType ( SOPC_EncodeableType encoder)

Registers a user-defined encodeable type. further calls to SOPC_EncodeableType_GetEncodeableType will successfully identify the registered encodeable type.

Note
All registered encoders must be freed by SOPC_EncodeableType_RemoveUserType
Parameters
encoderThe encoder definition to register
Returns
A status code indicating the result of operation

◆ SOPC_EncodeableType_RemoveUserType()

SOPC_ReturnStatus SOPC_EncodeableType_RemoveUserType ( SOPC_EncodeableType encoder)

Removes a user-defined encodeable type previously created by SOPC_EncodeableType_AddUserType.

Parameters
encoderThe encoder definition to register
Returns
A status code indicating the result of operation

◆ SOPC_EncodeableType_GetUserType()

SOPC_EncodeableType* SOPC_EncodeableType_GetUserType ( uint16_t  nsIndex,
uint32_t  typeId 
)

Retrieve a user-defined encodeable type with the given type Id.

Parameters
nsIndexNamespace index of the typeId
typeIdType identifier for which corresponding encodeable type must be returned
Returns
The searched encodeable type or NULL if parameters are incorrect or type is not found

◆ SOPC_EncodeableType_GetEncodeableType()

SOPC_EncodeableType* SOPC_EncodeableType_GetEncodeableType ( uint16_t  nsIndex,
uint32_t  typeId 
)

Retrieve a defined encodeable type with the given type Id. It can be a internal defined type or user-defined type.

Parameters
nsIndexNamespace index of the typeId
typeIdType identifier for which corresponding encodeable type must be returned
Returns
The searched encodeable type or NULL if parameters are incorrect or type is not found

◆ SOPC_EncodeableType_GetName()

const char* SOPC_EncodeableType_GetName ( SOPC_EncodeableType encType)

Get the name of the given encodeable type.

Parameters
encTypeThe encodeable type for which name is requested
Returns
The name of the encodeable type as a C string

◆ SOPC_EncodeableObject_Initialize()

void SOPC_EncodeableObject_Initialize ( SOPC_EncodeableType type,
void *  pValue 
)

Initialize an encodeable object of the given encodeable type.

Parameters
typeThe encodeable type of the object instance to initialize.
pValueAn object instance of the appropriate encodeable type. It shall at least have allocation size described in the encodeable type and is expected to be the C structure corresponding to an instance of the encodeable type (The first field of the structure shall be a SOPC_EncodeableType* which value will be set to type. The following fields shall have types described by type)

◆ SOPC_EncodeableObject_Clear()

void SOPC_EncodeableObject_Clear ( SOPC_EncodeableType type,
void *  pValue 
)

Clear an encodeable object of the given encodeable type.

Parameters
typeThe encodeable type of the object instance to clear.
pValueAn object instance of the appropriate encodeable type. It shall at least have allocation size described in the encodeable type and is expected to be the C structure corresponding to an instance of the encodeable type (The first field of the structure shall be a SOPC_EncodeableType* which value shall be type. The following fields shall have types described by type)

◆ SOPC_EncodeableObject_Encode()

SOPC_ReturnStatus SOPC_EncodeableObject_Encode ( SOPC_EncodeableType type,
const void *  pValue,
SOPC_Buffer buf,
uint32_t  nestedStructLevel 
)

Encode an encodeable object of the given encodeable type into a bytes buffer.

Parameters
typeThe encodeable type of the object instance to encode.
pValueThe object instance of the appropriate encodeable type to encode. It shall at least have allocation size described in the encodeable type and shall be the C structure corresponding to an instance of the encodeable type (The first field of the structure shall be a SOPC_EncodeableType* which value shall be type. The following fields shall have types described by type)
bufThe buffer in which the encodeable object will be encoded
nestedStructLevelThe number of structure levels encoded until then. Value 0 shall be used for first call.
Returns
A status code indicating the result of operation

◆ SOPC_EncodeableObject_Decode()

SOPC_ReturnStatus SOPC_EncodeableObject_Decode ( SOPC_EncodeableType type,
void *  pValue,
SOPC_Buffer buf,
uint32_t  nestedStructLevel 
)

Decode an encodeable object of the given encodeable type from a bytes buffer.

Parameters
typeThe encodeable type of the object instance to decode.
pValueAn initialized object instance of the appropriate encodeable type to decode. It shall at least have allocation size described in the encodeable type and shall be the C structure corresponding to an instance of the encodeable type (The first field of the structure shall be a SOPC_EncodeableType* which value shall be type. The following fields shall have types described by type)
bufThe buffer to decode to fill the encodeable object content
nestedStructLevelThe number of structure levels decoded until then Value 0 shall be used for first call.
Returns
A status code indicating the result of operation

◆ SOPC_EncodeableObject_Copy()

SOPC_ReturnStatus SOPC_EncodeableObject_Copy ( SOPC_EncodeableType type,
void *  destValue,
const void *  srcValue 
)

Copy an encodeable object of the given encodeable type.

Parameters
typeThe encodeableType of destValue and srcValue.
destValueThe destination encodeable object instance of the given encodeable type in which the content copy will be done. It shall have been initialized SOPC_EncodeableObject_Initialize and cleared SOPC_EncodeableObject_Clear if necessary with type as encodeable type.
srcValueThe source encodeable object instance of the given encodeable type from which the content copy will be done. It shall at least have allocation size described in the encodeable type and shall be the C structure corresponding to an instance of the encodeable type (The first field of the structure shall be a SOPC_EncodeableType* which value shall be type. The following fields shall have types described by type)
Returns
SOPC_STATUS_OK in case of success, reason of failure otherwise.

◆ SOPC_EncodeableObject_Compare()

SOPC_ReturnStatus SOPC_EncodeableObject_Compare ( SOPC_EncodeableType type,
const void *  leftValue,
const void *  rightValue,
int32_t *  comp 
)

Compare 2 encodeable objects of the given encodeable type.

Parameters
typeThe encodeableType of leftValue and rightValue.
leftValueThe left encodeable object of the given encodeable type operand to compare. It shall at least have allocation size described in the encodeable type and shall be the C structure corresponding to an instance of the encodeable type (The first field of the structure shall be a SOPC_EncodeableType* which value shall be type. The following fields shall have types described by type)
rightValueThe right encodeable object of the given encodeable type operand to compare. It shall at least have allocation size described in the encodeable type and shall be the C structure corresponding to an instance of the encodeable type (The first field of the structure shall be a SOPC_EncodeableType* which value shall be type. The following fields shall have types described by type)
[out]compPointer to an integer that will store the comparison result when returned status is SOPC_STATUS_OK. In this latter case:
  • comp < 0 if leftValue < rightValue,
  • comp > 0 if leftValue > rightValue and
  • comp == 0 if leftValue == rightValue.
Returns
SOPC_STATUS_OK in case of success, reason of failure otherwise.