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  * It shall be a valid value of ::SOPC_TypeInternalIndex enum type.
142  * Note: fields can only be of internal defined types for user-defined types.
143  *
144  * Finally, the \c offset field gives the offset in bytes of the field in the
145  * object structure.
146  */
148 {
149  bool isBuiltIn : 1;
150  bool isArrayLength : 1;
151  bool isToEncode : 1;
152  uint32_t typeIndex : 29;
153  uint32_t offset;
155 
160 typedef const struct SOPC_EncodeableType_Struct
161 {
162  char* TypeName;
163  uint32_t TypeId;
170  int32_t NoOfFields;
173 
186 
195 
203 
212 
220 
233 
246 
264  const void* pValue,
265  SOPC_Buffer* buf,
266  uint32_t nestedStructLevel);
267 
285  void* pValue,
286  SOPC_Buffer* buf,
287  uint32_t nestedStructLevel);
288 
307 SOPC_ReturnStatus SOPC_EncodeableObject_Copy(SOPC_EncodeableType* type, void* destValue, const void* srcValue);
308 
332  const void* leftValue,
333  const void* rightValue,
334  int32_t* comp);
335 
336 #endif /* SOPC_ENCODEABLETYPE_H_ */
SOPC_EncodeableType_FieldDescriptor
Definition: sopc_encodeabletype.h:148
SOPC_EncodeableType_GetUserType
SOPC_EncodeableType * SOPC_EncodeableType_GetUserType(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:165
SOPC_EncodeableType_GetEncodeableType
SOPC_EncodeableType * SOPC_EncodeableType_GetEncodeableType(uint32_t typeId)
Retrieve a defined encodeable type with the given type Id. It can be a internal defined type or user-...
SOPC_EncodeableType_Struct::NoOfFields
int32_t NoOfFields
Definition: sopc_encodeabletype.h:170
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:168
SOPC_EncodeableType_Struct::Fields
const SOPC_EncodeableType_FieldDescriptor * Fields
Definition: sopc_encodeabletype.h:171
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:167
SOPC_EncodeableType_FieldDescriptor::isToEncode
bool isToEncode
Definition: sopc_encodeabletype.h:151
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_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_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:149
SOPC_EncodeableType_Struct::TypeId
uint32_t TypeId
Definition: sopc_encodeabletype.h:163
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:162
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:169
SOPC_EncodeableType_FieldDescriptor::offset
uint32_t offset
Definition: sopc_encodeabletype.h:153
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_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:164
SOPC_EncodeableType_FieldDescriptor::typeIndex
uint32_t typeIndex
Definition: sopc_encodeabletype.h:152
SOPC_EncodeableType_Struct::NamespaceUri
char * NamespaceUri
Definition: sopc_encodeabletype.h:166
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_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:150
SOPC_EncodeableType_Struct
Encodeable object type structure definition. It provides all the services functions associated with t...
Definition: sopc_encodeabletype.h:161
sopc_buffer.h
A buffer of bytes with a maximum size, length and position.
SOPC_ReturnStatus
SOPC_ReturnStatus
Definition: libs2opc_client.h:64