1 | // Copyright (C) 2023 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 "qopcuaenumdefinition.h" |
5 | |
6 | #include <QtCore/qlist.h> |
7 | #include <QtCore/qvariant.h> |
8 | |
9 | #include <QtOpcUa/qopcuaenumfield.h> |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | /*! |
14 | \class QOpcUaEnumDefinition |
15 | \inmodule QtOpcUa |
16 | \since 6.7 |
17 | \brief The OPC UA EnumDefinition type. |
18 | |
19 | This is the Qt OPC UA representation for the OPC UA EnumDefinition type defined in OPC UA part 3. |
20 | It describes an enumerated type. |
21 | */ |
22 | |
23 | class QOpcUaEnumDefinitionData : public QSharedData |
24 | { |
25 | public: |
26 | QList<QOpcUaEnumField> fields; |
27 | }; |
28 | |
29 | QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QOpcUaEnumDefinitionData); |
30 | |
31 | /*! |
32 | Default constructs an enum definition with no parameters set. |
33 | */ |
34 | QOpcUaEnumDefinition::QOpcUaEnumDefinition() |
35 | : data(new QOpcUaEnumDefinitionData) |
36 | { |
37 | } |
38 | |
39 | /*! |
40 | Constructs an enum definition from \a other. |
41 | */ |
42 | QOpcUaEnumDefinition::QOpcUaEnumDefinition(const QOpcUaEnumDefinition &other) |
43 | : data(other.data) |
44 | { |
45 | } |
46 | |
47 | /*! |
48 | Sets the values from \a rhs in this enum definition. |
49 | */ |
50 | QOpcUaEnumDefinition &QOpcUaEnumDefinition::operator=(const QOpcUaEnumDefinition &rhs) |
51 | { |
52 | if (this != &rhs) |
53 | data.operator=(o: rhs.data); |
54 | return *this; |
55 | } |
56 | |
57 | /*! |
58 | \fn QOpcUaEnumDefinition::QOpcUaEnumDefinition(QOpcUaEnumDefinition &&other) |
59 | |
60 | Move-constructs a new enum definition from \a other. |
61 | |
62 | \note The moved-from object \a other is placed in a |
63 | partially-formed state, in which the only valid operations are |
64 | destruction and assignment of a new value. |
65 | */ |
66 | |
67 | /*! |
68 | \fn QOpcUaEnumDefinition &QOpcUaEnumDefinition::operator=(QOpcUaEnumDefinition &&other) |
69 | |
70 | Move-assigns \a other to this QOpcUaEnumDefinition instance. |
71 | |
72 | \note The moved-from object \a other is placed in a |
73 | partially-formed state, in which the only valid operations are |
74 | destruction and assignment of a new value. |
75 | */ |
76 | |
77 | /*! |
78 | \fn void QOpcUaEnumDefinition::swap(QOpcUaEnumDefinition &other) |
79 | |
80 | Swaps enum definition object \a other with this enum definition |
81 | object. This operation is very fast and never fails. |
82 | */ |
83 | |
84 | /*! |
85 | \fn bool QOpcUaEnumDefinition::operator!=(const QOpcUaEnumDefinition &lhs, const QOpcUaEnumDefinition &rhs) noexcept |
86 | |
87 | Returns \c true if \a lhs is not equal to \a rhs. |
88 | */ |
89 | |
90 | /*! |
91 | \fn bool QOpcUaEnumDefinition::operator==(const QOpcUaEnumDefinition &lhs, const QOpcUaEnumDefinition &rhs) noexcept |
92 | |
93 | Returns \c true if \a lhs is equal to \a rhs. |
94 | */ |
95 | bool comparesEqual(const QOpcUaEnumDefinition &lhs, const QOpcUaEnumDefinition &rhs) noexcept |
96 | { |
97 | return lhs.data->fields == rhs.fields(); |
98 | } |
99 | |
100 | /*! |
101 | Converts this enum definition to \l QVariant. |
102 | */ |
103 | QOpcUaEnumDefinition::operator QVariant() const |
104 | { |
105 | return QVariant::fromValue(value: *this); |
106 | } |
107 | |
108 | /*! |
109 | Destroys this enum definition object. |
110 | */ |
111 | QOpcUaEnumDefinition::~QOpcUaEnumDefinition() |
112 | { |
113 | } |
114 | |
115 | /*! |
116 | Returns the fields of the enum type. |
117 | */ |
118 | QList<QOpcUaEnumField> QOpcUaEnumDefinition::fields() const |
119 | { |
120 | return data->fields; |
121 | } |
122 | |
123 | /*! |
124 | Sets the fields of the enum type to \a fields. |
125 | */ |
126 | void QOpcUaEnumDefinition::setFields(const QList<QOpcUaEnumField> &fields) |
127 | { |
128 | if (fields != data->fields) { |
129 | data.detach(); |
130 | data->fields = fields; |
131 | } |
132 | } |
133 | |
134 | QT_END_NAMESPACE |
135 | |