Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:17

0001 // Copyright (C) 2021 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QBINDINGSTORAGE_H
0005 #define QBINDINGSTORAGE_H
0006 
0007 #include <QtCore/qglobal.h>
0008 #include <QtCore/qnamespace.h>
0009 
0010 QT_BEGIN_NAMESPACE
0011 
0012 template <typename Class, typename T, auto Offset, auto Setter, auto Signal, auto Getter>
0013 class QObjectCompatProperty;
0014 struct QPropertyDelayedNotifications;
0015 class QUntypedPropertyData;
0016 
0017 namespace QtPrivate {
0018 
0019 class QPropertyBindingData;
0020 struct BindingEvaluationState;
0021 struct CompatPropertySafePoint;
0022 }
0023 
0024 struct QBindingStatus
0025 {
0026     QtPrivate::BindingEvaluationState *currentlyEvaluatingBinding = nullptr;
0027     QtPrivate::CompatPropertySafePoint *currentCompatProperty = nullptr;
0028     Qt::HANDLE threadId = nullptr;
0029     QPropertyDelayedNotifications *groupUpdateData = nullptr;
0030 };
0031 
0032 namespace QtPrivate {
0033 struct QBindingStatusAccessToken;
0034 Q_AUTOTEST_EXPORT QBindingStatus *getBindingStatus(QBindingStatusAccessToken);
0035 }
0036 
0037 
0038 struct QBindingStorageData;
0039 class Q_CORE_EXPORT QBindingStorage
0040 {
0041     mutable QBindingStorageData *d = nullptr;
0042     QBindingStatus *bindingStatus = nullptr;
0043 
0044     template<typename Class, typename T, auto Offset, auto Setter, auto Signal, auto Getter>
0045     friend class QObjectCompatProperty;
0046     friend class QObjectPrivate;
0047     friend class QtPrivate::QPropertyBindingData;
0048 public:
0049     QBindingStorage();
0050     ~QBindingStorage();
0051 
0052     bool isEmpty() { return !d; }
0053     bool isValid() const noexcept { return bindingStatus; }
0054 
0055     const QBindingStatus *status(QtPrivate::QBindingStatusAccessToken) const;
0056 
0057     void registerDependency(const QUntypedPropertyData *data) const
0058     {
0059         if (!bindingStatus || !bindingStatus->currentlyEvaluatingBinding)
0060             return;
0061         registerDependency_helper(data);
0062     }
0063     QtPrivate::QPropertyBindingData *bindingData(const QUntypedPropertyData *data) const
0064     {
0065         if (!d)
0066             return nullptr;
0067         return bindingData_helper(data);
0068     }
0069 
0070 #if QT_CORE_REMOVED_SINCE(6, 2)
0071     void maybeUpdateBindingAndRegister(const QUntypedPropertyData *data) const { registerDependency(data); }
0072 #endif
0073 
0074     QtPrivate::QPropertyBindingData *bindingData(QUntypedPropertyData *data, bool create)
0075     {
0076         if (!d && !create)
0077             return nullptr;
0078         return bindingData_helper(data, create);
0079     }
0080 private:
0081     void reinitAfterThreadMove();
0082     void clear();
0083     void registerDependency_helper(const QUntypedPropertyData *data) const;
0084 #if QT_CORE_REMOVED_SINCE(6, 2)
0085     // ### Unused, but keep for BC
0086     void maybeUpdateBindingAndRegister_helper(const QUntypedPropertyData *data) const;
0087 #endif
0088     QtPrivate::QPropertyBindingData *bindingData_helper(const QUntypedPropertyData *data) const;
0089     QtPrivate::QPropertyBindingData *bindingData_helper(QUntypedPropertyData *data, bool create);
0090 };
0091 
0092 QT_END_NAMESPACE
0093 
0094 #endif // QBINDINGSTORAGE_H