UA Server SDK C++ Bundle  1.3.2.200
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
UaNodeId Class Reference

This class encapsulates the native OpcUa_NodeId structure and handles memory allocation and cleanup for you. More...

#include <uanodeid.h>

Public Member Functions

 UaNodeId ()
 Creates an empty NodeId with NS=0, IdentifierType=Numeric, Identifier=0.
 UaNodeId (const UaNodeId &other)
 Constructs a copy of other.
 UaNodeId (const OpcUa_NodeId &other)
 Construct a copy of the native OpcUa_NodeId structure.
 UaNodeId (OpcUa_UInt32 id, OpcUa_UInt16 NsIdx=0)
 Creates a new numeric NodeId.
 UaNodeId (const UaString &sId, OpcUa_UInt16 NsIdx)
 Creates a new string NodeId.
 UaNodeId (const UaGuid &guid, OpcUa_UInt16 NsIdx)
 Creates a new GUID NodeId.
 UaNodeId (const UaByteString &data, OpcUa_UInt16 NsIdx)
 Creates a new opaque NodeId.
 ~UaNodeId ()
 Cleans up everything.
OpcUa_Boolean isNull () const
 Checks whether a value is Null or not.
void clear ()
 Clear data.
void attach (const OpcUa_NodeId *pOther)
 Attaches to the native NodeId structure.
OpcUa_NodeId * detach (OpcUa_NodeId *pDst)
 Reset OpcUa_NodeId structure without clearing the data.
void setNamespaceIndex (OpcUa_UInt16 NsIdx)
 Set the namespace index.
void setNodeId (OpcUa_UInt32 id, OpcUa_UInt16 NsIdx=0)
 Set the actual used node id.
void setNodeId (const UaString &sId, OpcUa_UInt16 NsIdx=1)
 Set the actual used node id.
void setNodeId (const UaGuid &id, OpcUa_UInt16 NsIdx)
 Set the actual used node id.
void setNodeId (const UaByteString &id, OpcUa_UInt16 NsIdx)
 Set the actual used node id.
 operator const OpcUa_NodeId * () const
 Returns the OpcUa_NodeId pointer to the internal data structure.
OpcUa_NodeId * copy () const
 Copy OpcUa_NodeId data to a newly allocated OpcUa_NodeId.
void copyTo (OpcUa_NodeId *pDst) const
 Copy a value to a new destination.
UaNodeIdoperator= (const UaNodeId &other)
 Assigns another NodeId to the current instance.
bool operator< (const UaNodeId &other) const
 Is lower than operator.
bool operator== (const UaNodeId &other) const
 Compares another NodeId to the current instance.
bool operator!= (const UaNodeId &other) const
 Compares another NodeId to the current instance.
bool nodeIdCompare (OpcUa_NodeId *pNodeId) const
 Compares another NodeId to the current instance.
UaString toString () const
 Converts the identifier of the NodeId to a string.
UaString toFullString () const
 Converts all elements of a NodeId to a human readable string.
UaString toXmlString () const
 Converts all elements of a NodeId to a string where the syntax is defined by the OPC UA XML Schema.
OpcUa_IdentifierType identifierType () const
 Returns the identifier type of the NodeId.
OpcUa_UInt16 namespaceIndex () const
 Returns the namespace index as numeric value.
OpcUa_UInt32 identifierNumeric () const
 Returns the numeric identifier as numeric value.
const OpcUa_String * identifierString () const
 Returns the string identifier as string value.

Static Public Member Functions

static OpcUa_NodeId * clone (const OpcUa_NodeId &source)
 Copy OpcUa_NodeId data to a newly allocated OpcUa_NodeId.
static void cloneTo (const OpcUa_NodeId &source, OpcUa_NodeId &copy)
 Creates a copy of the source NodeId.
static bool compare (const OpcUa_NodeId &, const OpcUa_NodeId &)
 Compares two nodeIds and returns true if they are equal.
static UaNodeId fromXmlString (UaString xmlString)
 Creates a NodeId to from a string where the syntax is defined by the OPC UA XML Schema.

Detailed Description

This class encapsulates the native OpcUa_NodeId structure and handles memory allocation and cleanup for you.

UaNodeId uses implicit sharing to avoid needless copying and to boost the performance. Only if you modify a shared NodeId it creates a copy for that (copy-on-write). So assigning another UaNodeId or passing it as parameter is as fast as assigning a pointer.

Constructor & Destructor Documentation

UaNodeId::UaNodeId ( )

Creates an empty NodeId with NS=0, IdentifierType=Numeric, Identifier=0.

UaNodeId::UaNodeId ( const UaNodeId other)

Constructs a copy of other.

This operation takes constant time, because UaNodeId is implicitly shared. This makes returning a UaNodeId from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

Parameters
otherthe UaNodeId.
UaNodeId::UaNodeId ( const OpcUa_NodeId &  other)

Construct a copy of the native OpcUa_NodeId structure.

This creates a copy of the native data and doesn't modify other. You can also attach the native structure so no copying is needed

Parameters
otherthe OpcUa_NodeId.
See Also
attach
UaNodeId::UaNodeId ( OpcUa_UInt32  id,
OpcUa_UInt16  NsIdx = 0 
)

Creates a new numeric NodeId.

Parameters
idThe numeric identifier.
NsIdxThe namespace index. The default value for the namespace index is 0 to allow simple assignment of OPC UA defined numeric NodeIds
UaNodeId::UaNodeId ( const UaString sId,
OpcUa_UInt16  NsIdx 
)

Creates a new string NodeId.

Parameters
sIdThe string identifier.
NsIdxThe namespace index.
UaNodeId::UaNodeId ( const UaGuid guid,
OpcUa_UInt16  NsIdx 
)

Creates a new GUID NodeId.

Parameters
guidThe GUID identifier.
NsIdxThe namespace index.
UaNodeId::UaNodeId ( const UaByteString data,
OpcUa_UInt16  NsIdx 
)

Creates a new opaque NodeId.

Parameters
dataThe opaque data identifier.
NsIdxThe namespace index.
UaNodeId::~UaNodeId ( )

Cleans up everything.

If you want to prevent deleting the internal OpcUa_NodeId structure you can also detach it before deleting the UaNodeId instance.

See Also
detach

Member Function Documentation

void UaNodeId::attach ( const OpcUa_NodeId *  pOther)

Attaches to the native NodeId structure.

This means UaNodeId takes ownership of the NodeId data and clears this in the destructor automatically. It does not clear the OpcUa_NodeId structure itself.

Parameters
pOtherPointer to native OpcUa_NodeId structure.
void UaNodeId::clear ( )

Clear data.

Clears the current NodeId.

OpcUa_NodeId * UaNodeId::clone ( const OpcUa_NodeId &  source)
static

Copy OpcUa_NodeId data to a newly allocated OpcUa_NodeId.

Creates a copy of the source NodeId.

Parameters
sourcethe source of this operation.
Returns
a newly allocated OpcUa_NodeId.

This method creates a complete new OpcUa_NodeId structure. You have to call OpcUa_NodeId_Clear to clear the NodeId contents and you have to free the structure itself using OpcUa_Memory_Free.

Parameters
sourceSource NodeId to clone.
Returns
New copy of source NodeId.
void UaNodeId::cloneTo ( const OpcUa_NodeId &  source,
OpcUa_NodeId &  copy 
)
static

Creates a copy of the source NodeId.

This method copies the NodeId data into an existing OpcUa_NodeId structure. You have to call OpcUa_NodeId_Clear to clear the NodeId contents.

Parameters
sourceSource NodeId to clone.
copyNew copy of source NodeId.
bool UaNodeId::compare ( const OpcUa_NodeId &  nodeId1,
const OpcUa_NodeId &  nodeId2 
)
static

Compares two nodeIds and returns true if they are equal.

Parameters
nodeId1the source to compare to.
nodeId2the destination to compare to.
Returns
true if the two nodeIds are equal.
See Also
operator==
OpcUa_NodeId * UaNodeId::copy ( ) const

Copy OpcUa_NodeId data to a newly allocated OpcUa_NodeId.

Creates a copy of the internal NodeId.

Returns
a newly allocated OpcUa_NodeId.

This method creates a complete new OpcUa_NodeId structure. You have to call OpcUa_NodeId_Clear to clear the NodeId contents and you have to free the structure itself using OpcUa_Memory_Free.

Returns
copy of this NodeId.
void UaNodeId::copyTo ( OpcUa_NodeId *  pDst) const

Copy a value to a new destination.

Creates a copy of the internal NodeId.

Parameters
pDstthe destination of this operation
Returns
a new copy.

This method copies the NodeId data into an existing OpcUa_NodeId structure. You have to call OpcUa_NodeId_Clear to clear the NodeId contents.

Parameters
pDstthe destination of this copy operation.
OpcUa_NodeId * UaNodeId::detach ( OpcUa_NodeId *  pDst)

Reset OpcUa_NodeId structure without clearing the data.

Detaches the internal NodeId structure from this class.

Parameters
pDstthe destination of this operation

This way you take over the control of releasing the NodeId data. You can only detach the data if not more than one references exists.

Parameters
pDstPointer to OpcUa_NodeId structure that receives the NodeId data.
Returns
If the functions succeeds pDst is returned, otherwise 0 is returned.
UaNodeId UaNodeId::fromXmlString ( UaString  xmlString)
static

Creates a NodeId to from a string where the syntax is defined by the OPC UA XML Schema.

The format of the string is
ns=<namespaceindex>;<type>=<identifier>
with the fields

  • <namespaceindex> The namespace index formatted as a base 10 number. If the index is 0 then the entire 'ns=0;' clause is omitted.
  • <type> A flag that specifies the identifier type. The flag has the following values:
    • i NUMERIC (UInteger)
    • s STRING (String)
    • g GUID (Guid)
    • b OPAQUE (ByteString)
  • <identifier> The identifier encoded as string. The identifier is formatted using the XML data type mapping for the identifier type. Note that the identifier may contain any non-null UTF8 character including whitespace.
OpcUa_UInt32 UaNodeId::identifierNumeric ( ) const

Returns the numeric identifier as numeric value.

Get an identifier as numeric.

Returns
an identifier as numeric.
const OpcUa_String * UaNodeId::identifierString ( ) const

Returns the string identifier as string value.

Get an identifier as sting.

Returns
an identifier as sting.
OpcUa_IdentifierType UaNodeId::identifierType ( ) const

Returns the identifier type of the NodeId.

Get the identifier type.

Possible values are

  • OpcUa_IdentifierType_Numeric = 0x00
  • OpcUa_IdentifierType_String = 0x01
  • OpcUa_IdentifierType_Guid = 0x02
  • OpcUa_IdentifierType_Opaque = 0x03
Returns
the identifier type.
OpcUa_Boolean UaNodeId::isNull ( ) const

Checks whether a value is Null or not.

Checks if the NodeId is NULL or not.

Returns
true if Null false if not.
true if it is NULL false if not.
OpcUa_UInt16 UaNodeId::namespaceIndex ( ) const

Returns the namespace index as numeric value.

Get the namespace index.

Returns
the namespace index.
bool UaNodeId::nodeIdCompare ( OpcUa_NodeId *  pNodeId) const

Compares another NodeId to the current instance.

Compares two nodeIds and returns true if they are equal.

Parameters
pNodeIdthe UaNodeId to assign.
Returns
another NodeId to the current instance.
Parameters
pNodeIdthe node id of the actual node.
Returns
true if the nodeIds are equal.
See Also
operator==
UaNodeId::operator const OpcUa_NodeId * ( ) const

Returns the OpcUa_NodeId pointer to the internal data structure.

Returns
OpcUa_NodeId pointer to the internal data structure.
bool UaNodeId::operator!= ( const UaNodeId other) const

Compares another NodeId to the current instance.

Returns true if other is not equal to this.

Parameters
otherthe UaNodeId to assign.
Returns
another NodeId to the current instance.
See Also
operator==
Parameters
otherthe UaString to compare.
Returns
true if other is not equal to this.
bool UaNodeId::operator< ( const UaNodeId other) const

Is lower than operator.

This is used to sort NodeIds e.g. to use it as key in map

Parameters
otherthe UaNodeId to append.
Returns
true if lower false if not.
UaNodeId & UaNodeId::operator= ( const UaNodeId other)

Assigns another NodeId to the current instance.

Parameters
otherthe UaNodeId to assign.
Returns
another NodeId to the current instance.
bool UaNodeId::operator== ( const UaNodeId other) const

Compares another NodeId to the current instance.

Is equal operator.

Parameters
otherthe UaNodeId to assign.
Returns
another NodeId to the current instance.
Parameters
otherthe UaNodeId to compare.
Returns
true if the two nodeIds are equal
void UaNodeId::setNamespaceIndex ( OpcUa_UInt16  NsIdx)

Set the namespace index.

Assigns a new namespace index to the NodeId.

Parameters
NsIdxThe namespace index.
void UaNodeId::setNodeId ( OpcUa_UInt32  id,
OpcUa_UInt16  NsIdx = 0 
)

Set the actual used node id.

Assigns a new NodeId.

Parameters
idThe numeric identifier.
NsIdxThe namespace index. The default value for the namespace index is 0 to allow simple assignment of OPC UA defined numeric NodeIds
idThe numeric identifier.
NsIdxThe namespace index.
void UaNodeId::setNodeId ( const UaString sId,
OpcUa_UInt16  NsIdx = 1 
)

Set the actual used node id.

Assigns a new NodeId.

Parameters
sIdThe string identifier.
NsIdxThe namespace index. The default value for the namespace index is 1. Namespace 0 can only have numeric NodeIds.
sIdThe string identifier.
NsIdxThe namespace index.
void UaNodeId::setNodeId ( const UaGuid id,
OpcUa_UInt16  NsIdx 
)

Set the actual used node id.

Assigns a new NodeId.

Parameters
idThe guid identifier.
NsIdxThe namespace index.
idThe GUID identifier.
NsIdxThe namespace index.
void UaNodeId::setNodeId ( const UaByteString id,
OpcUa_UInt16  NsIdx 
)

Set the actual used node id.

Assigns a new NodeId.

Parameters
idThe byte string identifier.
NsIdxThe namespace index.
idThe ByteString identifier.
NsIdxThe namespace index.
UaString UaNodeId::toFullString ( ) const

Converts all elements of a NodeId to a human readable string.

The format of the string is
NS<namespace index>|<indentifier type>|<identifier>
with the fields

  • <namespace index> is the namespace index in the NodeId as numeric value
  • <identifier type> is Numeric, String, Guid or Opaque
  • <identifier> is the string representation of the Identifier field of the NodeId
UaString UaNodeId::toString ( ) const

Converts the identifier of the NodeId to a string.

Converts the NodeId into a UaString.

Returns
the converted NodeId.
UaString UaNodeId::toXmlString ( ) const

Converts all elements of a NodeId to a string where the syntax is defined by the OPC UA XML Schema.

The format of the string is
ns=<namespaceindex>;<type>=<identifier>
with the fields

  • <namespaceindex> The namespace index formatted as a base 10 number. If the index is 0 then the entire 'ns=0;' clause is omitted.
  • <type> A flag that specifies the identifier type. The flag has the following values:
    • i NUMERIC (UInteger)
    • s STRING (String)
    • g GUID (Guid)
    • b OPAQUE (ByteString)
  • <identifier> The identifier encoded as string. The identifier is formatted using the XML data type mapping for the identifier type. Note that the identifier may contain any non-null UTF8 character including whitespace.

The documentation for this class was generated from the following files: