summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2024-02-27 15:15:51 +0100
committerMarc Mutz <marc.mutz@qt.io>2024-02-29 18:48:37 +0000
commit7324c5f18e59a6c561d84062c1ae599a60d2ccdc (patch)
tree7ea83ca1122a1de3e2bfeb8131ae1380f8941a99
parentd30c542fb90b502683a1920cfb020d7885af07e4 (diff)
Use QT_OPCUA_REMOVED_SINCE to get rid of the member operator==()
And replace them with hidden friends instead. Rather than replacing with a hidden friend operator==(), that would need to be exported as the class (hence its prior operator==() member) is, export a hidden friend comparesEqual() and use this to implement the old member operator. This also simplifies the future migration to using comparison helper macros. As a drive-by: move the friend operators into the private section. Found in 6.7 API review Pick-to: 6.7 Change-Id: Idb0cc0f9b3a240f33e6a6c5844a09386c590276e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r--src/opcua/CMakeLists.txt4
-rw-r--r--src/opcua/client/qopcuacontentfilterelement.cpp11
-rw-r--r--src/opcua/client/qopcuacontentfilterelement.h17
-rw-r--r--src/opcua/client/qopcuarelativepathelement.cpp16
-rw-r--r--src/opcua/client/qopcuarelativepathelement.h16
-rw-r--r--src/opcua/client/qopcuasimpleattributeoperand.cpp12
-rw-r--r--src/opcua/client/qopcuasimpleattributeoperand.h16
-rw-r--r--src/opcua/compat/removed_api.cpp31
8 files changed, 94 insertions, 29 deletions
diff --git a/src/opcua/CMakeLists.txt b/src/opcua/CMakeLists.txt
index d78195c..406c236 100644
--- a/src/opcua/CMakeLists.txt
+++ b/src/opcua/CMakeLists.txt
@@ -76,10 +76,12 @@ qt_internal_add_module(OpcUa
client/qopcuaxvalue.cpp client/qopcuaxvalue.h
client/qopcuadiagnosticinfo.cpp client/qopcuadiagnosticinfo.h
client/qopcuavariant.cpp client/qopcuavariant.h
+ compat/removed_api.cpp
core/qopcuaplugin.cpp core/qopcuaplugin.h
core/qopcuaprovider.cpp core/qopcuaprovider.h
qopcuaglobal.h
-
+ NO_PCH_SOURCES
+ compat/removed_api.cpp
LIBRARIES
Qt::CorePrivate
Qt::NetworkPrivate
diff --git a/src/opcua/client/qopcuacontentfilterelement.cpp b/src/opcua/client/qopcuacontentfilterelement.cpp
index ef4dda0..ff60b20 100644
--- a/src/opcua/client/qopcuacontentfilterelement.cpp
+++ b/src/opcua/client/qopcuacontentfilterelement.cpp
@@ -86,11 +86,16 @@ QOpcUaContentFilterElement &QOpcUaContentFilterElement::operator=(const QOpcUaCo
}
/*!
- Returns \c true if this content filter element has the same value as \a rhs.
+ \fn bool QOpcUaContentFilterElement::operator==(const QOpcUaContentFilterElement &lhs,
+ const QOpcUaContentFilterElement &rhs)
+
+ Returns \c true if \a lhs has the same value as \a rhs.
*/
-bool QOpcUaContentFilterElement::operator==(const QOpcUaContentFilterElement &rhs) const
+bool comparesEqual(const QOpcUaContentFilterElement &lhs,
+ const QOpcUaContentFilterElement &rhs) noexcept
{
- return filterOperator() == rhs.filterOperator() && filterOperands() == rhs.filterOperands();
+ return lhs.filterOperator() == rhs.filterOperator()
+ && lhs.filterOperands() == rhs.filterOperands();
}
/*!
diff --git a/src/opcua/client/qopcuacontentfilterelement.h b/src/opcua/client/qopcuacontentfilterelement.h
index a0856fb..c7a5748 100644
--- a/src/opcua/client/qopcuacontentfilterelement.h
+++ b/src/opcua/client/qopcuacontentfilterelement.h
@@ -24,7 +24,9 @@ public:
QOpcUaContentFilterElement();
QOpcUaContentFilterElement(const QOpcUaContentFilterElement &);
QOpcUaContentFilterElement &operator=(const QOpcUaContentFilterElement &);
+#if QT_OPCUA_REMOVED_SINCE(6, 7)
bool operator==(const QOpcUaContentFilterElement &rhs) const;
+#endif
operator QVariant() const;
~QOpcUaContentFilterElement();
@@ -64,13 +66,18 @@ public:
QList<QVariant> &filterOperandsRef();
void setFilterOperands(const QList<QVariant> &filterOperands);
- friend inline bool operator!=(const QOpcUaContentFilterElement &lhs, const QOpcUaContentFilterElement &rhs) noexcept
- {
- return !(lhs == rhs);
- }
-
private:
QSharedDataPointer<QOpcUaContentFilterElementData> data;
+
+ friend Q_OPCUA_EXPORT bool comparesEqual(const QOpcUaContentFilterElement &lhs,
+ const QOpcUaContentFilterElement &rhs) noexcept;
+
+ friend bool operator==(const QOpcUaContentFilterElement &lhs,
+ const QOpcUaContentFilterElement &rhs) noexcept
+ { return comparesEqual(lhs, rhs); }
+ friend bool operator!=(const QOpcUaContentFilterElement &lhs,
+ const QOpcUaContentFilterElement &rhs) noexcept
+ { return !comparesEqual(lhs, rhs); }
};
QT_END_NAMESPACE
diff --git a/src/opcua/client/qopcuarelativepathelement.cpp b/src/opcua/client/qopcuarelativepathelement.cpp
index f2cb224..ce05830 100644
--- a/src/opcua/client/qopcuarelativepathelement.cpp
+++ b/src/opcua/client/qopcuarelativepathelement.cpp
@@ -71,14 +71,18 @@ QOpcUaRelativePathElement &QOpcUaRelativePathElement::operator=(const QOpcUaRela
}
/*!
- Returns \c true if this relative path element has the same value as \a rhs.
+ \fn bool QOpcUaRelativePathElement::operator==(const QOpcUaRelativePathElement &lhs,
+ const QOpcUaRelativePathElement &rhs)
+
+ Returns \c true if \a lhs has the same value as \a rhs.
*/
-bool QOpcUaRelativePathElement::operator==(const QOpcUaRelativePathElement &rhs) const
+bool comparesEqual(const QOpcUaRelativePathElement &lhs,
+ const QOpcUaRelativePathElement &rhs) noexcept
{
- return data->includeSubtypes == rhs.includeSubtypes() &&
- data->isInverse == rhs.isInverse() &&
- data->referenceTypeId == rhs.referenceTypeId() &&
- data->targetName == rhs.targetName();
+ return lhs.includeSubtypes() == rhs.includeSubtypes() &&
+ lhs.isInverse() == rhs.isInverse() &&
+ lhs.referenceTypeId() == rhs.referenceTypeId() &&
+ lhs.targetName() == rhs.targetName();
}
QOpcUaRelativePathElement::~QOpcUaRelativePathElement()
diff --git a/src/opcua/client/qopcuarelativepathelement.h b/src/opcua/client/qopcuarelativepathelement.h
index 9f978c8..f6507a2 100644
--- a/src/opcua/client/qopcuarelativepathelement.h
+++ b/src/opcua/client/qopcuarelativepathelement.h
@@ -21,7 +21,9 @@ public:
QOpcUaRelativePathElement(const QOpcUaQualifiedName &target, QOpcUa::ReferenceTypeId refType);
QOpcUaRelativePathElement(const QOpcUaRelativePathElement &);
QOpcUaRelativePathElement &operator=(const QOpcUaRelativePathElement &);
+#if QT_OPCUA_REMOVED_SINCE(6, 7)
bool operator==(const QOpcUaRelativePathElement &rhs) const;
+#endif
~QOpcUaRelativePathElement();
QString referenceTypeId() const;
@@ -39,13 +41,17 @@ public:
QOpcUaQualifiedName targetName() const;
void setTargetName(const QOpcUaQualifiedName &targetName);
- friend inline bool operator!=(const QOpcUaRelativePathElement &lhs, const QOpcUaRelativePathElement &rhs) noexcept
- {
- return !(lhs == rhs);
- }
-
private:
QSharedDataPointer<QOpcUaRelativePathElementData> data;
+
+ friend Q_OPCUA_EXPORT bool comparesEqual(const QOpcUaRelativePathElement &lhs,
+ const QOpcUaRelativePathElement &rhs) noexcept;
+ friend bool operator==(const QOpcUaRelativePathElement &lhs,
+ const QOpcUaRelativePathElement &rhs) noexcept
+ { return comparesEqual(lhs, rhs); }
+ friend inline bool operator!=(const QOpcUaRelativePathElement &lhs,
+ const QOpcUaRelativePathElement &rhs) noexcept
+ { return !comparesEqual(lhs, rhs); }
};
QT_END_NAMESPACE
diff --git a/src/opcua/client/qopcuasimpleattributeoperand.cpp b/src/opcua/client/qopcuasimpleattributeoperand.cpp
index bbffded..ea8193a 100644
--- a/src/opcua/client/qopcuasimpleattributeoperand.cpp
+++ b/src/opcua/client/qopcuasimpleattributeoperand.cpp
@@ -80,12 +80,16 @@ QOpcUaSimpleAttributeOperand &QOpcUaSimpleAttributeOperand::operator=(const QOpc
}
/*!
- Returns \c true if this simple attribute operand has the same value as \a rhs.
+ \fn bool QOpcUaSimpleAttributeOperand::operator==(const QOpcUaSimpleAttributeOperand &lhs,
+ const QOpcUaSimpleAttributeOperand &rhs)
+
+ Returns \c true if \a lhs has the same value as \a rhs.
*/
-bool QOpcUaSimpleAttributeOperand::operator==(const QOpcUaSimpleAttributeOperand &rhs) const
+bool comparesEqual(const QOpcUaSimpleAttributeOperand &lhs,
+ const QOpcUaSimpleAttributeOperand &rhs) noexcept
{
- return attributeId() == rhs.attributeId() && browsePath() == rhs.browsePath() &&
- indexRange() == rhs.indexRange() && typeId() == rhs.typeId();
+ return lhs.attributeId() == rhs.attributeId() && rhs.browsePath() == rhs.browsePath() &&
+ lhs.indexRange() == rhs.indexRange() && lhs.typeId() == rhs.typeId();
}
/*!
diff --git a/src/opcua/client/qopcuasimpleattributeoperand.h b/src/opcua/client/qopcuasimpleattributeoperand.h
index 87d46ab..7e8e72b 100644
--- a/src/opcua/client/qopcuasimpleattributeoperand.h
+++ b/src/opcua/client/qopcuasimpleattributeoperand.h
@@ -26,7 +26,9 @@ public:
QOpcUaSimpleAttributeOperand(QOpcUa::NodeAttribute attributeId,
const QString &typeId = QStringLiteral("ns=0;i=2041")); // BaseEventType
QOpcUaSimpleAttributeOperand &operator=(const QOpcUaSimpleAttributeOperand &);
+#if QT_OPCUA_REMOVED_SINCE(6, 7)
bool operator==(const QOpcUaSimpleAttributeOperand &rhs) const;
+#endif
operator QVariant() const;
~QOpcUaSimpleAttributeOperand();
@@ -43,13 +45,17 @@ public:
QString indexRange() const;
void setIndexRange(const QString &indexRange);
- friend inline bool operator!=(const QOpcUaSimpleAttributeOperand &lhs, const QOpcUaSimpleAttributeOperand &rhs) noexcept
- {
- return !(lhs == rhs);
- }
-
private:
QSharedDataPointer<QOpcUaSimpleAttributeOperandData> data;
+
+ friend Q_OPCUA_EXPORT bool comparesEqual(const QOpcUaSimpleAttributeOperand &lhs,
+ const QOpcUaSimpleAttributeOperand &rhs) noexcept;
+ friend bool operator==(const QOpcUaSimpleAttributeOperand &lhs,
+ const QOpcUaSimpleAttributeOperand &rhs) noexcept
+ { return comparesEqual(lhs, rhs); }
+ friend bool operator!=(const QOpcUaSimpleAttributeOperand &lhs,
+ const QOpcUaSimpleAttributeOperand &rhs) noexcept
+ { return !comparesEqual(lhs, rhs); }
};
QT_END_NAMESPACE
diff --git a/src/opcua/compat/removed_api.cpp b/src/opcua/compat/removed_api.cpp
new file mode 100644
index 0000000..5cd236c
--- /dev/null
+++ b/src/opcua/compat/removed_api.cpp
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 basysKom GmbH, opensource@basyskom.com
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#define QT_OPCUA_BUILD_REMOVED_API
+
+#include "qopcuaglobal.h"
+
+QT_USE_NAMESPACE
+
+#if QT_OPCUA_REMOVED_SINCE(6, 7)
+
+#include "qopcuacontentfilterelement.h"
+
+bool QOpcUaContentFilterElement::operator==(const QOpcUaContentFilterElement &rhs) const
+{ return comparesEqual(*this, rhs); }
+
+#include "qopcuarelativepathelement.h"
+
+bool QOpcUaRelativePathElement::operator==(const QOpcUaRelativePathElement &rhs) const
+{ return comparesEqual(*this, rhs); }
+
+#include "qopcuasimpleattributeoperand.h"
+
+bool QOpcUaSimpleAttributeOperand::operator==(const QOpcUaSimpleAttributeOperand &rhs) const
+{ return comparesEqual(*this, rhs); }
+
+// #include "qotherheader.h"
+// // implement removed functions from qotherheader.h
+// order sections alphabetically to reduce chances of merge conflicts
+
+#endif // QT_OPCUA_REMOVED_SINCE(6, 7)