1// Copyright (C) 2015 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 "qopcuaargument.h"
5#include "qopcuatype.h"
6
7QT_BEGIN_NAMESPACE
8
9/*!
10 \class QOpcUaArgument
11 \inmodule QtOpcUa
12 \brief The OPC UA Argument type.
13
14 This is the Qt OPC UA representation for the Argument type defined in OPC-UA part 3, 8.6.
15
16 The Argument type is mainly used for the values of the InputArguments and OutputArguments properties
17 which describe the parameters and return values of method nodes.
18*/
19class QOpcUaArgumentData : public QSharedData
20{
21public:
22 QString name;
23 QString dataTypeId;
24 qint32 valueRank{-2};
25 QList<quint32> arrayDimensions;
26 QOpcUaLocalizedText description;
27};
28
29QOpcUaArgument::QOpcUaArgument()
30 : data(new QOpcUaArgumentData)
31{
32}
33
34QOpcUaArgument::QOpcUaArgument(const QOpcUaArgument &rhs)
35 : data(rhs.data)
36{
37}
38
39/*!
40 Constructs an argument with name \a name, data type id \a dataTypeId, value rank \a valueRank,
41 array dimensions \a arrayDimensions and description \a description.
42*/
43QOpcUaArgument::QOpcUaArgument(const QString &name, const QString &dataTypeId, qint32 valueRank,
44 const QList<quint32> &arrayDimensions, const QOpcUaLocalizedText &description)
45 : data(new QOpcUaArgumentData)
46{
47 setName(name);
48 setDataTypeId(dataTypeId);
49 setValueRank(valueRank);
50 setArrayDimensions(arrayDimensions);
51 setDescription(description);
52}
53
54/*!
55 Sets the values from \a rhs in this argument.
56*/
57QOpcUaArgument &QOpcUaArgument::operator=(const QOpcUaArgument &rhs)
58{
59 if (this != &rhs)
60 data.operator=(o: rhs.data);
61 return *this;
62}
63
64/*!
65 Returns true if this argument has the same value as \a other.
66*/
67bool QOpcUaArgument::operator==(const QOpcUaArgument &other) const
68{
69 return data->arrayDimensions == other.arrayDimensions() &&
70 QOpcUa::nodeIdEquals(first: data->dataTypeId, second: other.dataTypeId()) &&
71 data->description == other.description() &&
72 data->name == other.name() &&
73 data->valueRank == other.valueRank();
74}
75
76/*!
77 Converts this argument to \l QVariant.
78*/
79QOpcUaArgument::operator QVariant() const
80{
81 return QVariant::fromValue(value: *this);
82}
83
84QOpcUaArgument::~QOpcUaArgument()
85{
86}
87
88/*!
89 Returns the name of the argument.
90*/
91QString QOpcUaArgument::name() const
92{
93 return data->name;
94}
95
96/*!
97 Sets the name of the argument to \a name.
98*/
99void QOpcUaArgument::setName(const QString &name)
100{
101 data->name = name;
102}
103
104/*!
105 Returns the data type node id of the argument.
106*/
107QString QOpcUaArgument::dataTypeId() const
108{
109 return data->dataTypeId;
110}
111
112/*!
113 Sets the data type node id of the argument to \a dataTypeId.
114*/
115void QOpcUaArgument::setDataTypeId(const QString &dataTypeId)
116{
117 data->dataTypeId = dataTypeId;
118}
119
120/*!
121 Returns the value rank of the argument.
122 The value rank describes the structure of the value.
123 \table
124 \header
125 \li ValueRank
126 \li Meaning
127 \row
128 \li -3
129 \li Scalar or one dimensional array
130 \row
131 \li -2
132 \li Scalar or array with any number of dimensions
133 \row
134 \li -1
135 \li Not an array
136 \row
137 \li 0
138 \li Array with one or more dimensions
139 \row
140 \li 1
141 \li One dimensional array
142 \row
143 \li >1
144 \li Array with n dimensions
145 \endtable
146*/
147qint32 QOpcUaArgument::valueRank() const
148{
149 return data->valueRank;
150}
151
152/*!
153 Sets the value rank of the argument to \a valueRank.
154*/
155void QOpcUaArgument::setValueRank(qint32 valueRank)
156{
157 data->valueRank = valueRank;
158}
159
160/*!
161 Returns the array dimensions of the argument.
162
163 The array dimensions describe the length of each array dimension.
164*/
165QList<quint32> QOpcUaArgument::arrayDimensions() const
166{
167 return data->arrayDimensions;
168}
169
170/*!
171 Returns a reference to the array dimensions of the argument.
172*/
173QList<quint32> &QOpcUaArgument::arrayDimensionsRef()
174{
175 return data->arrayDimensions;
176}
177
178/*!
179 Sets the array dimensions of the argument to \a arrayDimensions.
180*/
181void QOpcUaArgument::setArrayDimensions(const QList<quint32> &arrayDimensions)
182{
183 data->arrayDimensions = arrayDimensions;
184}
185
186/*!
187 Returns the description of the argument.
188*/
189QOpcUaLocalizedText QOpcUaArgument::description() const
190{
191 return data->description;
192}
193
194/*!
195 Sets the description of the argument to \a description.
196*/
197void QOpcUaArgument::setDescription(const QOpcUaLocalizedText &description)
198{
199 data->description = description;
200}
201
202QT_END_NAMESPACE
203

source code of qtopcua/src/opcua/client/qopcuaargument.cpp