| 1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QT3DCORE_QASPECTFACTORY_P_H |
| 5 | #define QT3DCORE_QASPECTFACTORY_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of other Qt classes. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtCore/QHash> |
| 19 | #include <QtCore/QStringList> |
| 20 | |
| 21 | #include <Qt3DCore/private/qt3dcore_global_p.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | struct QMetaObject; |
| 26 | class QObject; |
| 27 | |
| 28 | namespace Qt3DCore { |
| 29 | |
| 30 | class QAbstractAspect; |
| 31 | |
| 32 | class Q_3DCORE_PRIVATE_EXPORT QAspectFactory |
| 33 | { |
| 34 | public: |
| 35 | typedef QAbstractAspect *(*CreateFunction)(QObject *); |
| 36 | |
| 37 | QAspectFactory(); |
| 38 | QAspectFactory(const QAspectFactory &other); |
| 39 | ~QAspectFactory(); |
| 40 | QAspectFactory &operator=(const QAspectFactory &other); |
| 41 | #ifdef Q_COMPILER_RVALUE_REFS |
| 42 | QAspectFactory &operator=(QAspectFactory &&other) noexcept |
| 43 | { |
| 44 | m_factories.swap(other&: other.m_factories); |
| 45 | m_aspectNames.swap(other&: other.m_aspectNames); |
| 46 | return *this; |
| 47 | } |
| 48 | #endif |
| 49 | |
| 50 | inline void swap(QAspectFactory &other) noexcept |
| 51 | { |
| 52 | m_factories.swap(other&: other.m_factories); |
| 53 | m_aspectNames.swap(other&: other.m_aspectNames); |
| 54 | } |
| 55 | |
| 56 | QList<QLatin1String> availableFactories() const; |
| 57 | QAbstractAspect *createAspect(const QLatin1String &aspect, QObject *parent = 0) const; |
| 58 | QLatin1String aspectName(QAbstractAspect *aspect) const; |
| 59 | |
| 60 | private: |
| 61 | QHash<QLatin1String, QAspectFactory::CreateFunction> m_factories; |
| 62 | QHash<const QMetaObject*, QLatin1String> m_aspectNames; |
| 63 | }; |
| 64 | |
| 65 | } // namespace Qt3DCore |
| 66 | |
| 67 | QT_END_NAMESPACE |
| 68 | |
| 69 | #endif // QT3DCORE_QASPECTFACTORY_P_H |
| 70 |
