S2OPC OPCUA Toolkit
sopc_encodeabletype.h
Go to the documentation of this file.
1 /*
2  * Licensed to Systerel under one or more contributor license
3  * agreements. See the NOTICE file distributed with this work
4  * for additional information regarding copyright ownership.
5  * Systerel licenses this file to you under the Apache
6  * License, Version 2.0 (the "License"); you may not use this
7  * file except in compliance with the License. You may obtain
8  * a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
44 #ifndef SOPC_ENCODEABLETYPE_H_
45 #define SOPC_ENCODEABLETYPE_H_
46 
47 #include <stddef.h>
48 #include <stdint.h>
49 
50 #include "sopc_buffer.h"
51 #include "sopc_enums.h"
52 
56 typedef void(SOPC_EncodeableObject_PfnInitialize)(void* value);
57 
61 typedef void(SOPC_EncodeableObject_PfnClear)(void* value);
62 
75  SOPC_Buffer* buffer,
76  uint32_t nestedStructLevel);
77 
90  SOPC_Buffer* msgBuffer,
91  uint32_t nestedStructLevel);
92 
104 typedef SOPC_ReturnStatus(SOPC_EncodeableObject_PfnCopy)(void* dest, const void* src);
105 
122 typedef SOPC_ReturnStatus(SOPC_EncodeableObject_PfnComp)(const void* left, const void* right, int32_t* comp);
123 
124 /*
125  * \brief Description of an encodeable type field.
126  *
127  * This structure has been designed to be very compact and fit into 8 bytes.
128  * The \c isBuiltIn field indicates whether the field type is built-in or
129  * defined in the address space. In the first case, the type index is a member
130  * of the \c SOPC_BuiltinId enumeration. In the second case, it is a member of
131  * the \c SOPC_TypeInternalIndex enumeration.
132  *
133  * The \c isArrayLength field indicates whether this field contains the length
134  * of an array. When true, the field must be of built-in type \c Int32, and the
135  * array is described by the next field.
136  *
137  * The \c isToEncode field indicates whether this field shall be encoded and
138  * decoded. When false, the field is only initialized and cleared.
139  *
140  * The \c typeIndex field indicates the index of type in internal types array
141  * (namespaceTypesArray of encodeable type containing the field descriptor)
142  * It shall be a valid value of ::SOPC_TypeInternalIndex enum type.
143  * Note: fields can only be of internal defined types for user-defined types.
144  *
145  * Finally, the \c offset field gives the offset in bytes of the field in the
146  * object structure.
147  */
149 {
150  bool isBuiltIn : 1;
151  bool isArrayLength : 1;
152  bool isToEncode : 1;
153  uint32_t typeIndex : 29;
154  uint32_t offset;
156 
163 typedef const struct SOPC_EncodeableType_Struct
164 {
165  char* TypeName;
166  uint32_t TypeId;
169  char* NamespaceUri;
171  uint16_t NamespaceIndex;
175  int32_t NoOfFields;
177 
180 
193 
202 
210 SOPC_EncodeableType* SOPC_EncodeableType_GetUserType(uint16_t nsIndex, uint32_t typeId);
211 
220 SOPC_EncodeableType* SOPC_EncodeableType_GetEncodeableType(uint16_t nsIndex, uint32_t typeId);
221 
229 
242 
255 
264 
273 
291  const void* pValue,
292  SOPC_Buffer* buf,
293  uint32_t nestedStructLevel);
294 
312  void* pValue,
313  SOPC_Buffer* buf,
314  uint32_t nestedStructLevel);
315 
334 SOPC_ReturnStatus SOPC_EncodeableObject_Copy(SOPC_EncodeableType* type, void* destValue, const void* srcValue);
335 
344 SOPC_ReturnStatus SOPC_EncodeableObject_Move(void* destObj, void* srcObj);
345 
369  const void* leftValue,
370  const void* rightValue,
371  int32_t* comp);
372 
373 #endif /* SOPC_ENCODEABLETYPE_H_ */
SOPC_EncodeableType_FieldDescriptor
Definition: sopc_encodeabletype.h:149
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.
SOPC_EncodeableType_Struct::XmlEncodingTypeId
uint32_t XmlEncodingTypeId
Definition: sopc_encodeabletype.h:168
SOPC_EncodeableType_Struct::NoOfFields
int32_t NoOfFields
Definition: sopc_encodeabletype.h:175
SOPC_EncodeableObject_PfnClear
void() SOPC_EncodeableObject_PfnClear(void *value)
Clear function generic signature for an encodeable object.
Definition: sopc_encodeabletype.h:61
SOPC_EncodeableType_Struct::Initialize
SOPC_EncodeableObject_PfnInitialize * Initialize
Definition: sopc_encodeabletype.h:173
SOPC_EncodeableType_Struct::Fields
const SOPC_EncodeableType_FieldDescriptor * Fields
Definition: sopc_encodeabletype.h:176
SOPC_EncodeableObject_Clear
void SOPC_EncodeableObject_Clear(SOPC_EncodeableType *type, void *pValue)
Clear an encodeable object of the given encodeable type.
SOPC_EncodeableType_Struct::AllocationSize
size_t AllocationSize
Definition: sopc_encodeabletype.h:172
SOPC_EncodeableType_FieldDescriptor::isToEncode
bool isToEncode
Definition: sopc_encodeabletype.h:152
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.
SOPC_EncodeableObject_PfnDecode
SOPC_ReturnStatus() SOPC_EncodeableObject_PfnDecode(void *value, SOPC_Buffer *msgBuffer, uint32_t nestedStructLevel)
Decoding function generic signature for an encodeable object.
Definition: sopc_encodeabletype.h:89
SOPC_Buffer
Bytes buffer structure.
Definition: sopc_buffer.h:38
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-...
sopc_enums.h
SOPC_EncodeableType_RemoveUserType
SOPC_ReturnStatus SOPC_EncodeableType_RemoveUserType(SOPC_EncodeableType *encoder)
Removes a user-defined encodeable type previously created by SOPC_EncodeableType_AddUserType.
SOPC_EncodeableObject_Create
SOPC_ReturnStatus SOPC_EncodeableObject_Create(SOPC_EncodeableType *encTyp, void **encObject)
Instantiate and initialize an encodeable object of the given encodeable 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.
SOPC_EncodeableType_FieldDescriptor::isBuiltIn
bool isBuiltIn
Definition: sopc_encodeabletype.h:150
SOPC_EncodeableType_Struct::TypeId
uint32_t TypeId
Definition: sopc_encodeabletype.h:166
SOPC_EncodeableType_Struct::NamespaceIndex
uint16_t NamespaceIndex
Definition: sopc_encodeabletype.h:171
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.
SOPC_EncodeableType_Struct::TypeName
char * TypeName
Definition: sopc_encodeabletype.h:165
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.
SOPC_EncodeableType_Struct::Clear
SOPC_EncodeableObject_PfnClear * Clear
Definition: sopc_encodeabletype.h:174
SOPC_EncodeableType_FieldDescriptor::offset
uint32_t offset
Definition: sopc_encodeabletype.h:154
SOPC_EncodeableObject_PfnComp
SOPC_ReturnStatus() SOPC_EncodeableObject_PfnComp(const void *left, const void *right, int32_t *comp)
Compare function generic signature for an encodeable object.
Definition: sopc_encodeabletype.h:122
SOPC_EncodeableType_GetName
const char * SOPC_EncodeableType_GetName(SOPC_EncodeableType *encType)
Get the name of the given encodeable type.
SOPC_EncodeableObject_Delete
SOPC_ReturnStatus SOPC_EncodeableObject_Delete(SOPC_EncodeableType *encTyp, void **encObject)
Clear and deallocate an encodeable object of the given encodeable type.
SOPC_EncodeableType_AddUserType
SOPC_ReturnStatus SOPC_EncodeableType_AddUserType(SOPC_EncodeableType *encoder)
Registers a user-defined encodeable type. further calls to SOPC_EncodeableType_GetEncodeableType will...
SOPC_EncodeableType_Struct::BinaryEncodingTypeId
uint32_t BinaryEncodingTypeId
Definition: sopc_encodeabletype.h:167
SOPC_EncodeableType_FieldDescriptor::typeIndex
uint32_t typeIndex
Definition: sopc_encodeabletype.h:153
SOPC_EncodeableType_Struct::NamespaceUri
char * NamespaceUri
Definition: sopc_encodeabletype.h:169
SOPC_EncodeableType
const struct SOPC_EncodeableType_Struct SOPC_EncodeableType
Encodeable object type structure definition. It provides all the services functions associated with t...
SOPC_EncodeableObject_PfnInitialize
void() SOPC_EncodeableObject_PfnInitialize(void *value)
Initialization function generic signature for an encodeable object.
Definition: sopc_encodeabletype.h:56
SOPC_EncodeableObject_PfnCopy
SOPC_ReturnStatus() SOPC_EncodeableObject_PfnCopy(void *dest, const void *src)
Copy function generic signature for an encodeable object.
Definition: sopc_encodeabletype.h:104
SOPC_EncodeableObject_Initialize
void SOPC_EncodeableObject_Initialize(SOPC_EncodeableType *type, void *pValue)
Initialize an encodeable object of the given encodeable type.
SOPC_EncodeableType_FieldDescriptor
struct SOPC_EncodeableType_FieldDescriptor SOPC_EncodeableType_FieldDescriptor
SOPC_EncodeableType_Struct::namespaceTypesArray
const struct SOPC_EncodeableType_Struct ** namespaceTypesArray
Definition: sopc_encodeabletype.h:178
SOPC_EncodeableObject_PfnEncode
SOPC_ReturnStatus() SOPC_EncodeableObject_PfnEncode(const void *value, SOPC_Buffer *buffer, uint32_t nestedStructLevel)
Encoding function generic signature for an encodeable object *.
Definition: sopc_encodeabletype.h:74
SOPC_EncodeableType_FieldDescriptor::isArrayLength
bool isArrayLength
Definition: sopc_encodeabletype.h:151
SOPC_EncodeableType_Struct
Encodeable object type structure definition. It provides all the services functions associated with t...
Definition: sopc_encodeabletype.h:164
sopc_buffer.h
A buffer of bytes with a maximum size, length and position.
SOPC_EncodeableObject_Move
SOPC_ReturnStatus SOPC_EncodeableObject_Move(void *destObj, void *srcObj)
Moves content of srcObj to destObj, i.e. copy srcObj structure content to destObj and reset srcObj....
SOPC_ReturnStatus
SOPC_ReturnStatus
Definition: libs2opc_client.h:64