UA Server SDK C++ Bundle
1.4.2.275
|
Wrapper class for the UA stack structure OpcUa_NodeId. More...
#include <uanodeid.h>
Public Member Functions | |
UaNodeId () | |
Creates an empty NodeId with NS=0, IdentifierType=Numeric, Identifier=0. More... | |
UaNodeId (const UaNodeId &other) | |
Constructs a copy of other. More... | |
UaNodeId (const OpcUa_NodeId &other) | |
Constructs a copy of the native OpcUa_NodeId structure. More... | |
UaNodeId (OpcUa_UInt32 id, OpcUa_UInt16 NsIdx=0) | |
Creates a new NodeId with a numeric identifier. More... | |
UaNodeId (const UaString &sId, OpcUa_UInt16 NsIdx) | |
Creates a new NodeId with a string identifier. More... | |
UaNodeId (const UaGuid &guid, OpcUa_UInt16 NsIdx) | |
Creates a new NodeId with a GUID identifier. More... | |
UaNodeId (const UaByteString &data, OpcUa_UInt16 NsIdx) | |
Creates a new NodeId with a ByteString identifier. More... | |
~UaNodeId () | |
Cleans up everything. More... | |
OpcUa_Boolean | isNull () const |
Checks whether the NodeId is Null or not. More... | |
void | clear () |
Clears the current NodeId. More... | |
void | attach (const OpcUa_NodeId *pOther) |
Attaches to the native NodeId structure. More... | |
OpcUa_NodeId * | detach (OpcUa_NodeId *pDst) |
Detaches the internal NodeId structure from this class. More... | |
void | setNamespaceIndex (OpcUa_UInt16 NsIdx) |
Assigns a new namespace index to the NodeId. More... | |
void | setNodeId (OpcUa_UInt32 id, OpcUa_UInt16 NsIdx=0) |
Sets the currently used NodeId to a numeric identifier. More... | |
void | setNodeId (const UaString &sId, OpcUa_UInt16 NsIdx=1) |
Sets the currently used NodeId to a string identifier. More... | |
void | setNodeId (const UaGuid &id, OpcUa_UInt16 NsIdx) |
Sets the currently used NodeId to a GUID identifier. More... | |
void | setNodeId (const UaByteString &id, OpcUa_UInt16 NsIdx) |
Sets the currently used NodeId to a ByteString identyfier. More... | |
operator const OpcUa_NodeId * () const | |
Returns the OpcUa_NodeId pointer to the internal data structure. More... | |
OpcUa_NodeId * | copy () const |
Creates a copy of the internal NodeId. More... | |
void | copyTo (OpcUa_NodeId *pDst) const |
Creates a copy of the internal NodeId. More... | |
UaNodeId & | operator= (const UaNodeId &other) |
Assigns another NodeId to the current instance. More... | |
bool | operator< (const UaNodeId &other) const |
Is lower than operator for two NodeIds. More... | |
bool | operator== (const UaNodeId &other) const |
Is equal operator for two NodeIds. More... | |
bool | operator!= (const UaNodeId &other) const |
Is not equal operator for two NodeIds. More... | |
bool | nodeIdCompare (OpcUa_NodeId *pNodeId) const |
Compares two nodeIds and returns true if they are equal. More... | |
UaString | toString () const |
Converts the identifier of the NodeId to a UaString. More... | |
UaString | toFullString () const |
Converts all elements of a NodeId to a human readable string. More... | |
UaString | toXmlString () const |
Converts all elements of a NodeId to a string where the syntax is defined by the OPC UA XML Schema. More... | |
OpcUa_IdentifierType | identifierType () const |
Gets the identifier type of a NodeId. More... | |
OpcUa_UInt16 | namespaceIndex () const |
Gets the namespace index. More... | |
OpcUa_UInt32 | identifierNumeric () const |
Gets the identifier of a node as numeric value. More... | |
const OpcUa_String * | identifierString () const |
Get the identifier of a node as string value. More... | |
Static Public Member Functions | |
static OpcUa_NodeId * | clone (const OpcUa_NodeId &source) |
Creates a copy of the source NodeId. More... | |
static void | cloneTo (const OpcUa_NodeId &source, OpcUa_NodeId ©) |
Creates a copy of the source NodeId. More... | |
static bool | compare (const OpcUa_NodeId &, const OpcUa_NodeId &) |
Compares two nodeIds and returns true if they are equal. More... | |
static UaNodeId | fromXmlString (UaString xmlString) |
Creates a NodeId to from a string where the syntax is defined by the OPC UA XML Schema. More... | |
Friends | |
UABASE_EXPORT UaDataStream & | operator<< (UaDataStream &, const UaNodeId &) |
Writes a NodeId to the stream. More... | |
UABASE_EXPORT UaDataStream & | operator>> (UaDataStream &, UaNodeId &) |
Reads a NodeId from the stream. More... | |
Wrapper class for the UA stack structure OpcUa_NodeId.
Helper class for handling the OPC UA built-in data type NodeId. It provides conversion and comparison functions and handles memory allocation and cleanup.
The NodeId data type is a structure with the following elements
Name | Type | Description |
---|---|---|
namespaceIndex | UInt16 | The index for a namespace URI used in an OPC UA server |
identifierType | enum | The format and data type of the identifier |
identifier | * | The identifier for a node in the address space of an OPC UA server |
The namespace is a URI that identifies the naming authority responsible for assigning the identifier element of the NodeId. Naming authorities include the local server, the underlying system, standards bodies, and consortia. It is expected that most nodes will use the URI of the server or of the underlying system.
Using a namespace URI allows multiple OPC UA servers attached to the same underlying system to use the same identifier to identify the same object. This enables clients that connect to those Servers to recognise Objects that they have in common. The namespace URI is case sensitive. Namespace URIs are identified by numeric values in OPC UA services to permit more efficient transfer and processing (e.g. table lookups). The numeric values used to identify namespaces correspond to the index into the NamespaceArray. The NamespaceArray is a variable that is part of the Server object in the address space.
The URI for the OPC UA namespace is “http://opcfoundation.org/UA/”. Its corresponding index in the namespace table is 0.
The following IdentifierTypes are available:
Value | Description |
---|---|
OpcUa_IdentifierType_Numeric | Numeric value |
OpcUa_IdentifierType_String | String value |
OpcUa_IdentifierType_Guid | Globally Unique Identifier |
OpcUa_IdentifierType_Opaque | Namespace specific format in a ByteString |
Normally the scope of NodeIds is the server in which they are defined. For certain types of NodeIds, NodeIds can uniquely identify a Node within a system, or across systems (e.g. GUIDs). System-wide and globally-unique identifiers allow clients to track Nodes, such as work orders, as they move between OPC UA servers as they progress through the system.
String identifiers are case sensitive. That is, clients shall consider them case sensitive. Servers are allowed to provide alternative NodeIds and using this mechanism severs can handle NodeIds as case insensitive.
The identifier value element is used within the context of the first two elements to identify a node. Its data type and format is defined by the identifierType.
Identifier values of IdentifierType STRING are restricted to 4096 characters. Identifier values of IdentifierType OPAQUE are restricted to 4096 bytes.
A null NodeId has special meaning. For example, many services define special behaviour if a null NodeId is passed as a parameter. A node in the address space cannot have a null NodeId.
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.
UaNodeId::UaNodeId | ( | ) |
Creates an empty NodeId with NS=0, IdentifierType=Numeric, Identifier=0.
UaNodeId::UaNodeId | ( | const UaNodeId & | other | ) |
UaNodeId::UaNodeId | ( | const OpcUa_NodeId & | other | ) |
Constructs 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 that no copying is needed.
other | the OpcUa_NodeId. |
UaNodeId::UaNodeId | ( | OpcUa_UInt32 | id, |
OpcUa_UInt16 | NsIdx = 0 |
||
) |
Creates a new NodeId with a numeric identifier.
id | The numeric identifier. |
NsIdx | The 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 NodeId with a string identifier.
sId | The string identifier. |
NsIdx | The namespace index. |
UaNodeId::UaNodeId | ( | const UaGuid & | guid, |
OpcUa_UInt16 | NsIdx | ||
) |
Creates a new NodeId with a GUID identifier.
guid | The GUID identifier. |
NsIdx | The namespace index. |
UaNodeId::UaNodeId | ( | const UaByteString & | data, |
OpcUa_UInt16 | NsIdx | ||
) |
Creates a new NodeId with a ByteString identifier.
data | The ByteString identifier. |
NsIdx | The namespace index. |
UaNodeId::~UaNodeId | ( | ) |
void UaNodeId::attach | ( | const OpcUa_NodeId * | pOther | ) |
Attaches to the native NodeId structure.
This means UaNodeId takes ownership of the NodeId data and automatically clears it in the destructor. It does not clear the OpcUa_NodeId structure itself.
pOther | Pointer to native OpcUa_NodeId structure. |
void UaNodeId::clear | ( | ) |
Clears the current NodeId.
|
static |
Creates a copy of the source NodeId.
This method creates a complete new OpcUa_NodeId structure. You have to call OpcUa_NodeId_Clear to clear the contents of the NodeId and you have to free the structure itself using OpcUa_Memory_Free.
source | Source NodeId to clone. |
|
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 contents of the NodeId.
source | Source NodeId to clone. |
copy | New copy of source NodeId. |
|
static |
Compares two nodeIds and returns true if they are equal.
nodeId1 | The source to compare to. |
nodeId2 | The destination to compare to. |
OpcUa_NodeId * UaNodeId::copy | ( | ) | const |
Creates a copy of the internal NodeId.
This method creates a completely new OpcUa_NodeId structure. You have to call OpcUa_NodeId_Clear to clear the contents of the NodeId and you have to free the structure itself using OpcUa_Memory_Free.
void UaNodeId::copyTo | ( | OpcUa_NodeId * | pDst | ) | const |
Creates a copy of the internal NodeId.
This method copies the NodeId data into an existing OpcUa_NodeId structure. You have to call OpcUa_NodeId_Clear to clear the contents of the NodeId.
pDst | The destination of this copy operation. |
OpcUa_NodeId * UaNodeId::detach | ( | OpcUa_NodeId * | pDst | ) |
Detaches the internal NodeId structure from this class.
This way you take over the control of releasing the NodeId data. You can only detach the data if not more than one reference exists.
pDst | Pointer to OpcUa_NodeId structure that receives the NodeId data. |
Creates a NodeId to from a string where the syntax is defined by the OPC UA XML Schema.
The reverse function is
The format of the string is
ns=<namespaceindex>;<identifier type>=<identifier>
with the fields
Flag | Identifier Type |
---|---|
i | NUMERIC (UInteger) |
s | STRING (String) |
g | GUID (Guid) |
b | OPAQUE (ByteString) |
OpcUa_UInt32 UaNodeId::identifierNumeric | ( | ) | const |
Gets the identifier of a node as numeric value.
const OpcUa_String * UaNodeId::identifierString | ( | ) | const |
Get the identifier of a node as string value.
OpcUa_IdentifierType UaNodeId::identifierType | ( | ) | const |
Gets the identifier type of a NodeId.
Possible values are
OpcUa_Boolean UaNodeId::isNull | ( | ) | const |
Checks whether the NodeId is Null or not.
OpcUa_UInt16 UaNodeId::namespaceIndex | ( | ) | const |
Gets the namespace index.
bool UaNodeId::nodeIdCompare | ( | OpcUa_NodeId * | pNodeId | ) | const |
Compares two nodeIds and returns true if they are equal.
pNodeId | The node id of the actual node. |
UaNodeId::operator const OpcUa_NodeId * | ( | ) | const |
Returns the OpcUa_NodeId pointer to the internal data structure.
bool UaNodeId::operator!= | ( | const UaNodeId & | other | ) | const |
Is not equal operator for two NodeIds.
other | The UaString to compare. |
bool UaNodeId::operator< | ( | const UaNodeId & | other | ) | const |
Is lower than operator for two NodeIds.
This is used to sort NodeIds, e.g. to use it as key in map.
other | The UaNodeId to compare. |
Assigns another NodeId to the current instance.
other | The UaNodeId to assign. |
bool UaNodeId::operator== | ( | const UaNodeId & | other | ) | const |
Is equal operator for two NodeIds.
other | The UaNodeId to compare. |
void UaNodeId::setNamespaceIndex | ( | OpcUa_UInt16 | NsIdx | ) |
Assigns a new namespace index to the NodeId.
NsIdx | The namespace index. |
void UaNodeId::setNodeId | ( | OpcUa_UInt32 | id, |
OpcUa_UInt16 | NsIdx = 0 |
||
) |
Sets the currently used NodeId to a numeric identifier.
id | The numeric identifier. |
NsIdx | The namespace index. |
void UaNodeId::setNodeId | ( | const UaString & | sId, |
OpcUa_UInt16 | NsIdx = 1 |
||
) |
Sets the currently used NodeId to a string identifier.
sId | The string identifier. |
NsIdx | The namespace index. |
void UaNodeId::setNodeId | ( | const UaGuid & | id, |
OpcUa_UInt16 | NsIdx | ||
) |
Sets the currently used NodeId to a GUID identifier.
id | The GUID identifier. |
NsIdx | The namespace index. |
void UaNodeId::setNodeId | ( | const UaByteString & | id, |
OpcUa_UInt16 | NsIdx | ||
) |
Sets the currently used NodeId to a ByteString identyfier.
id | The ByteString identifier. |
NsIdx | The 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>|<identifier type>|<identifier>s
with the fields
There is no reverse function available for toFullString. If you want to create a string that can be used later to create a UaNodeId from this string, toXmlString() must be used.
Examples are
UaString UaNodeId::toString | ( | ) | const |
Converts the identifier of the NodeId to a UaString.
Only the identifier part of the NodeId is returned as UaString. The namespace index and the identifier type is not contained. Use toFullString() or toXmlString() to get all information contained in the NodeId.
There is no reverse function available for toString. If you want to create a string that can be used later to create a UaNodeId from this string, toXmlString() must be used.
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 reverse function is
The format of the string is
ns=<namespaceindex>;<identifier type>=<identifier>
with the fields
Flag | Identifier Type |
---|---|
i | NUMERIC (UInteger) |
s | STRING (String) |
g | GUID (Guid) |
b | OPAQUE (ByteString) |
Examples are
|
friend |
Writes a NodeId to the stream.
|
friend |
Reads a NodeId from the stream.