open62541++ 0.13.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
opcua::ExtensionObject Class Reference

#include <ExtensionObject.h>

Inheritance diagram for opcua::ExtensionObject:
[legend]

Detailed Description

UA_ExtensionObject wrapper class.

ExtensionObjects may contain scalars of any data type. Even those that are unknown to the receiver. If the received data type is unknown, the encoded string and target NodeId is stored instead of the decoded data.

See also
https://reference.opcfoundation.org/Core/Part6/v105/docs/5.1.6
https://reference.opcfoundation.org/Core/Part6/v105/docs/5.2.2.15
Examples
custom_datatypes/client_custom_datatypes.cpp, and server_accesscontrol.cpp.

Definition at line 39 of file ExtensionObject.h.

Public Member Functions

bool isEmpty () const noexcept
 
bool isEncoded () const noexcept
 
bool isDecoded () const noexcept
 
ExtensionObjectEncoding getEncoding () const noexcept
 
const NodeIdgetEncodedTypeId () const noexcept
 
const ByteStringgetEncodedBody () const noexcept
 
const UA_DataTypegetDecodedDataType () const noexcept
 
template<typename T >
T * getDecodedData () noexcept
 
template<typename T >
const T * getDecodedData () const noexcept
 
void * getDecodedData () noexcept
 
const void * getDecodedData () const noexcept
 
constexpr TypeWrapper ()=default
 
constexpr TypeWrapper (const T &native)
 
constexpr TypeWrapper (T &&native) noexcept
 
constexpr TypeWrapper (const TypeWrapper &other)
 
constexpr TypeWrapper (TypeWrapper &&other) noexcept
 
- Public Member Functions inherited from opcua::TypeWrapper< UA_ExtensionObject, UA_TYPES_EXTENSIONOBJECT >
constexpr TypeWrapper ()=default
 
constexpr TypeWrapper (const UA_ExtensionObject &native)
 
constexpr TypeWrapper (UA_ExtensionObject &&native) noexcept
 
constexpr TypeWrapper (const TypeWrapper &other)
 
constexpr TypeWrapper (TypeWrapper &&other) noexcept
 
 ~TypeWrapper ()
 
constexpr TypeWrapperoperator= (const TypeWrapper &other)
 
constexpr TypeWrapperoperator= (const UA_ExtensionObject &native)
 
constexpr TypeWrapperoperator= (TypeWrapper &&other) noexcept
 
constexpr TypeWrapperoperator= (UA_ExtensionObject &&native) noexcept
 
constexpr void swap (TypeWrapper &other) noexcept
 
constexpr void swap (UA_ExtensionObject &native) noexcept
 
- Public Member Functions inherited from opcua::Wrapper< T >
constexpr Wrapper ()=default
 
constexpr Wrapper (const T &native)
 
constexpr Wrapper (T &&native) noexcept
 
constexpr operator T& () noexcept
 
constexpr operator const T & () const noexcept
 
constexpr T * operator-> () noexcept
 
constexpr const T * operator-> () const noexcept
 
constexpr T * handle () noexcept
 
constexpr const T * handle () const noexcept
 

Static Public Member Functions

template<typename T >
static ExtensionObject fromDecoded (T &data) noexcept
 
static ExtensionObject fromDecoded (void *data, const UA_DataType &type) noexcept
 
template<typename T >
static ExtensionObject fromDecodedCopy (const T &data)
 
static ExtensionObject fromDecodedCopy (const void *data, const UA_DataType &type)
 
- Static Public Member Functions inherited from opcua::TypeWrapper< UA_ExtensionObject, UA_TYPES_EXTENSIONOBJECT >
static constexpr TypeIndex getTypeIndex ()
 

Additional Inherited Members

- Public Types inherited from opcua::Wrapper< T >
using NativeType = T
 
- Protected Member Functions inherited from opcua::TypeWrapper< UA_ExtensionObject, UA_TYPES_EXTENSIONOBJECT >
constexpr void clear () noexcept
 
- Protected Member Functions inherited from opcua::Wrapper< T >
constexpr const T & native () const noexcept
 
constexpr T & native () noexcept
 

Member Function Documentation

◆ fromDecoded() [1/2]

template<typename T >
static ExtensionObject opcua::ExtensionObject::fromDecoded ( T & data)
inlinestaticnoexcept

Create an ExtensionObject from a decoded object (reference).

The data will not be deleted when the ExtensionObject is destructed.

Parameters
dataDecoded data

Definition at line 47 of file ExtensionObject.h.

Referenced by fromDecoded(), and opcua::services::detail::wrapNodeAttributes().

◆ fromDecoded() [2/2]

static ExtensionObject opcua::ExtensionObject::fromDecoded ( void * data,
const UA_DataType & type )
inlinestaticnoexcept

Create an ExtensionObject from a decoded object (reference).

The data will not be deleted when the ExtensionObject is destructed.

Parameters
dataDecoded data
typeData type of the decoded data
Warning
Type erased version, use with caution.

Definition at line 56 of file ExtensionObject.h.

◆ fromDecodedCopy() [1/2]

template<typename T >
static ExtensionObject opcua::ExtensionObject::fromDecodedCopy ( const T & data)
inlinestatic

Create an ExtensionObject from a decoded object (copy).

Set the "decoded" data to a copy of the given object.

Parameters
dataDecoded data

Definition at line 68 of file ExtensionObject.h.

Referenced by fromDecodedCopy(), and opcua::Subscription< Connection >::subscribeEvent().

◆ fromDecodedCopy() [2/2]

static ExtensionObject opcua::ExtensionObject::fromDecodedCopy ( const void * data,
const UA_DataType & type )
inlinestatic

Create an ExtensionObject from a decoded object (copy).

Parameters
dataDecoded data
typeData type of the decoded data
Warning
Type erased version, use with caution.

Definition at line 76 of file ExtensionObject.h.

◆ isEmpty()

bool opcua::ExtensionObject::isEmpty ( ) const
inlinenoexcept

Check if the ExtensionObject is empty.

Definition at line 90 of file ExtensionObject.h.

◆ isEncoded()

bool opcua::ExtensionObject::isEncoded ( ) const
inlinenoexcept

Check if the ExtensionObject is encoded (usually if the data type is unknown).

Definition at line 95 of file ExtensionObject.h.

Referenced by getEncodedBody(), and getEncodedTypeId().

◆ isDecoded()

bool opcua::ExtensionObject::isDecoded ( ) const
inlinenoexcept

Check if the ExtensionObject is decoded.

Definition at line 101 of file ExtensionObject.h.

Referenced by getDecodedData(), getDecodedData(), and getDecodedDataType().

◆ getEncoding()

ExtensionObjectEncoding opcua::ExtensionObject::getEncoding ( ) const
inlinenoexcept

Get the encoding.

Definition at line 107 of file ExtensionObject.h.

◆ getEncodedTypeId()

const NodeId * opcua::ExtensionObject::getEncodedTypeId ( ) const
inlinenoexcept

Get the encoded type id.

Returns nullptr if ExtensionObject is not encoded.

Definition at line 113 of file ExtensionObject.h.

◆ getEncodedBody()

const ByteString * opcua::ExtensionObject::getEncodedBody ( ) const
inlinenoexcept

Get the encoded body.

Returns nullptr if ExtensionObject is not encoded.

Definition at line 120 of file ExtensionObject.h.

◆ getDecodedDataType()

const UA_DataType * opcua::ExtensionObject::getDecodedDataType ( ) const
inlinenoexcept

Get the decoded data type.

Returns nullptr if ExtensionObject is not decoded.

Definition at line 127 of file ExtensionObject.h.

◆ getDecodedData() [1/4]

template<typename T >
T * opcua::ExtensionObject::getDecodedData ( )
inlinenoexcept

Get pointer to the decoded data with given template type.

Returns nullptr if the ExtensionObject is either not decoded or the decoded data is not of type T.

Examples
server_accesscontrol.cpp.

Definition at line 136 of file ExtensionObject.h.

Referenced by getDecodedData(), and getDecodedData().

◆ getDecodedData() [2/4]

template<typename T >
const T * opcua::ExtensionObject::getDecodedData ( ) const
inlinenoexcept

Get const pointer to the decoded data with given template type.

Returns nullptr if the ExtensionObject is either not decoded or the decoded data is not of type T.

Definition at line 144 of file ExtensionObject.h.

◆ getDecodedData() [3/4]

void * opcua::ExtensionObject::getDecodedData ( )
inlinenoexcept

Get pointer to the decoded data.

Returns nullptr if the ExtensionObject is not decoded.

Warning
Type erased version, use with caution.

Definition at line 151 of file ExtensionObject.h.

◆ getDecodedData() [4/4]

const void * opcua::ExtensionObject::getDecodedData ( ) const
inlinenoexcept

Get pointer to the decoded data.

Returns nullptr if the ExtensionObject is not decoded.

Warning
Type erased version, use with caution.

Definition at line 159 of file ExtensionObject.h.

◆ TypeWrapper() [1/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( )
constexprdefault

◆ TypeWrapper() [2/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( const T & native)
inlineexplicitconstexpr

Constructor with native object (deep copy).

Definition at line 36 of file TypeWrapper.h.

◆ TypeWrapper() [3/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( T && native)
inlineconstexprnoexcept

Constructor with native object (move rvalue).

Definition at line 40 of file TypeWrapper.h.

◆ TypeWrapper() [4/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( const TypeWrapper & other)
inlineconstexpr

Copy constructor (deep copy).

Definition at line 48 of file TypeWrapper.h.

◆ TypeWrapper() [5/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( TypeWrapper && other)
inlineconstexprnoexcept

Move constructor.

Definition at line 52 of file TypeWrapper.h.