| 1 | // Copyright (C) 2018 basysKom GmbH, opensource@basyskom.com |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qopcuanodecreationattributes.h" |
| 5 | #include "qopcuaaddreferenceitem.h" |
| 6 | #include "qopcuaexpandednodeid.h" |
| 7 | |
| 8 | QT_BEGIN_NAMESPACE |
| 9 | |
| 10 | /*! |
| 11 | \class QOpcUaAddReferenceItem |
| 12 | \inmodule QtOpcUa |
| 13 | \brief This class stores the necessary information to add a new reference on the server. |
| 14 | |
| 15 | \sa QOpcUaClient::addReference() |
| 16 | */ |
| 17 | class QOpcUaAddReferenceItemData : public QSharedData |
| 18 | { |
| 19 | public: |
| 20 | QString sourceNodeId; |
| 21 | QString referenceTypeId; |
| 22 | bool isForwardReference {true}; |
| 23 | QOpcUaExpandedNodeId targetNodeId; |
| 24 | QOpcUa::NodeClass targetNodeClass {QOpcUa::NodeClass::Undefined}; |
| 25 | QString targetServerUri; |
| 26 | }; |
| 27 | |
| 28 | /*! |
| 29 | Default constructs an add reference item with no parameters set. |
| 30 | */ |
| 31 | QOpcUaAddReferenceItem::QOpcUaAddReferenceItem() |
| 32 | : data(new QOpcUaAddReferenceItemData) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | /*! |
| 37 | Constructs an add reference item from \a other. |
| 38 | */ |
| 39 | QOpcUaAddReferenceItem::QOpcUaAddReferenceItem(const QOpcUaAddReferenceItem &other) |
| 40 | : data(other.data) |
| 41 | { |
| 42 | |
| 43 | } |
| 44 | |
| 45 | /*! |
| 46 | Sets the values from \a rhs in this add reference item. |
| 47 | */ |
| 48 | QOpcUaAddReferenceItem &QOpcUaAddReferenceItem::operator=(const QOpcUaAddReferenceItem &rhs) |
| 49 | { |
| 50 | if (this != &rhs) |
| 51 | data.operator=(o: rhs.data); |
| 52 | return *this; |
| 53 | } |
| 54 | |
| 55 | QOpcUaAddReferenceItem::~QOpcUaAddReferenceItem() |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | /*! |
| 60 | Returns the target node class. |
| 61 | */ |
| 62 | QOpcUa::NodeClass QOpcUaAddReferenceItem::targetNodeClass() const |
| 63 | { |
| 64 | return data->targetNodeClass; |
| 65 | } |
| 66 | |
| 67 | /*! |
| 68 | Sets the node class of the target node to \a targetNodeClass. |
| 69 | The target node class shall be specified because the target node might be located on another server. |
| 70 | */ |
| 71 | void QOpcUaAddReferenceItem::setTargetNodeClass(QOpcUa::NodeClass targetNodeClass) |
| 72 | { |
| 73 | data->targetNodeClass = targetNodeClass; |
| 74 | } |
| 75 | |
| 76 | /*! |
| 77 | Returns the target server URI. |
| 78 | */ |
| 79 | QString QOpcUaAddReferenceItem::targetServerUri() const |
| 80 | { |
| 81 | return data->targetServerUri; |
| 82 | } |
| 83 | |
| 84 | /*! |
| 85 | Sets the URI of the target server to \a targetServerUri. |
| 86 | If this value is set, it will override the server URI from \l setTargetNodeId(). |
| 87 | */ |
| 88 | void QOpcUaAddReferenceItem::setTargetServerUri(const QString &targetServerUri) |
| 89 | { |
| 90 | data->targetServerUri = targetServerUri; |
| 91 | } |
| 92 | |
| 93 | /*! |
| 94 | Returns the target node id. |
| 95 | */ |
| 96 | QOpcUaExpandedNodeId QOpcUaAddReferenceItem::targetNodeId() const |
| 97 | { |
| 98 | return data->targetNodeId; |
| 99 | } |
| 100 | |
| 101 | /*! |
| 102 | Sets the node id of the target node to \a targetNodeId. |
| 103 | */ |
| 104 | void QOpcUaAddReferenceItem::setTargetNodeId(const QOpcUaExpandedNodeId &targetNodeId) |
| 105 | { |
| 106 | data->targetNodeId = targetNodeId; |
| 107 | } |
| 108 | |
| 109 | /*! |
| 110 | Returns the isForwardReference flag. |
| 111 | */ |
| 112 | bool QOpcUaAddReferenceItem::isForwardReference() const |
| 113 | { |
| 114 | return data->isForwardReference; |
| 115 | } |
| 116 | |
| 117 | /*! |
| 118 | Sets the isForwardReference flag to \a isForwardReference. |
| 119 | If the flag is set, a forward reference is created. |
| 120 | Otherwise, an inverse reference is created. |
| 121 | */ |
| 122 | void QOpcUaAddReferenceItem::setIsForwardReference(bool isForwardReference) |
| 123 | { |
| 124 | data->isForwardReference = isForwardReference; |
| 125 | } |
| 126 | |
| 127 | /*! |
| 128 | Returns the reference type id. |
| 129 | */ |
| 130 | QString QOpcUaAddReferenceItem::referenceTypeId() const |
| 131 | { |
| 132 | return data->referenceTypeId; |
| 133 | } |
| 134 | |
| 135 | /*! |
| 136 | Sets the reference type id to \a referenceTypeId. |
| 137 | A reference of this type will be created on the server. |
| 138 | */ |
| 139 | void QOpcUaAddReferenceItem::setReferenceTypeId(const QString &referenceTypeId) |
| 140 | { |
| 141 | data->referenceTypeId = referenceTypeId; |
| 142 | } |
| 143 | |
| 144 | /*! |
| 145 | Returns the source node id. |
| 146 | */ |
| 147 | QString QOpcUaAddReferenceItem::sourceNodeId() const |
| 148 | { |
| 149 | return data->sourceNodeId; |
| 150 | } |
| 151 | |
| 152 | /*! |
| 153 | Sets the node id of the source node to \a sourceNodeId. |
| 154 | */ |
| 155 | void QOpcUaAddReferenceItem::setSourceNodeId(const QString &sourceNodeId) |
| 156 | { |
| 157 | data->sourceNodeId = sourceNodeId; |
| 158 | } |
| 159 | |
| 160 | QT_END_NAMESPACE |
| 161 |
