| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #ifndef CLASSNODE_H |
| 5 | #define CLASSNODE_H |
| 6 | |
| 7 | #include "aggregate.h" |
| 8 | #include "relatedclass.h" |
| 9 | |
| 10 | #include <QtCore/qglobal.h> |
| 11 | #include <QtCore/qlist.h> |
| 12 | #include <QtCore/qstring.h> |
| 13 | |
| 14 | QT_BEGIN_NAMESPACE |
| 15 | |
| 16 | class FunctionNode; |
| 17 | class PropertyNode; |
| 18 | class QmlTypeNode; |
| 19 | |
| 20 | class ClassNode : public Aggregate |
| 21 | { |
| 22 | public: |
| 23 | ClassNode(NodeType type, Aggregate *parent, const QString &name) : Aggregate(type, parent, name) |
| 24 | { |
| 25 | } |
| 26 | [[nodiscard]] bool isFirstClassAggregate() const override { return true; } |
| 27 | [[nodiscard]] bool isClassNode() const override { return true; } |
| 28 | [[nodiscard]] bool isRelatableType() const override { return true; } |
| 29 | [[nodiscard]] bool isWrapper() const override { return m_wrapper; } |
| 30 | void setWrapper() override { m_wrapper = true; } |
| 31 | |
| 32 | void addResolvedBaseClass(Access access, ClassNode *node); |
| 33 | void addDerivedClass(Access access, ClassNode *node); |
| 34 | void addUnresolvedBaseClass(Access access, const QStringList &path); |
| 35 | void removePrivateAndInternalBases(); |
| 36 | void resolvePropertyOverriddenFromPtrs(PropertyNode *pn); |
| 37 | |
| 38 | QList<RelatedClass> &baseClasses() { return m_bases; } |
| 39 | QList<RelatedClass> &derivedClasses() { return m_derived; } |
| 40 | QList<RelatedClass> &ignoredBaseClasses() { return m_ignoredBases; } |
| 41 | |
| 42 | [[nodiscard]] const QList<RelatedClass> &baseClasses() const { return m_bases; } |
| 43 | |
| 44 | [[nodiscard]] bool isAbstract() const override { return m_abstract; } |
| 45 | void setAbstract(bool b) override { m_abstract = b; } |
| 46 | PropertyNode *findPropertyNode(const QString &name); |
| 47 | FunctionNode *findOverriddenFunction(const FunctionNode *fn); |
| 48 | PropertyNode *findOverriddenProperty(const FunctionNode *fn); |
| 49 | [[nodiscard]] bool docMustBeGenerated() const override; |
| 50 | |
| 51 | void insertQmlNativeType(QmlTypeNode *qmlTypeNode) { m_nativeTypeForQml << qmlTypeNode; } |
| 52 | bool isQmlNativeType() { return !m_nativeTypeForQml.empty(); } |
| 53 | const QSet<QmlTypeNode *> &qmlNativeTypes() { return m_nativeTypeForQml; } |
| 54 | |
| 55 | private: |
| 56 | void promotePublicBases(const QList<RelatedClass> &bases); |
| 57 | |
| 58 | private: |
| 59 | QList<RelatedClass> m_bases {}; |
| 60 | QList<RelatedClass> m_derived {}; |
| 61 | QList<RelatedClass> m_ignoredBases {}; |
| 62 | bool m_abstract { false }; |
| 63 | bool m_wrapper { false }; |
| 64 | QSet<QmlTypeNode *> m_nativeTypeForQml; |
| 65 | }; |
| 66 | |
| 67 | QT_END_NAMESPACE |
| 68 | |
| 69 | #endif // CLASSNODE_H |
| 70 |
