summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2015-12-01 12:21:17 +0100
committerKevin Ottens <kevin.ottens@kdab.com>2015-12-01 14:23:56 +0000
commit0e2bb7e307d3f75b903998af1813a0f590e144bc (patch)
tree4c94f863a39e9d64600317dd065ebe1fe4acd6cd
parentc509c85b63cb062aaf7b1a3044dcbb6d80610c89 (diff)
Make QAspectFactory private
Change-Id: I1301887b4572310eebc3086699447ff574e1345b Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/core/aspects/aspects.pri1
-rw-r--r--src/core/aspects/qaspectengine.cpp12
-rw-r--r--src/core/aspects/qaspectengine.h6
-rw-r--r--src/core/aspects/qaspectengine_p.h2
-rw-r--r--src/core/aspects/qaspectfactory.cpp24
-rw-r--r--src/core/aspects/qaspectfactory.h92
-rw-r--r--src/core/aspects/qaspectfactory_p.h41
-rw-r--r--tests/auto/core/qaspectfactory/qaspectfactory.pro2
-rw-r--r--tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp2
9 files changed, 46 insertions, 136 deletions
diff --git a/src/core/aspects/aspects.pri b/src/core/aspects/aspects.pri
index 72cbd43c1..4bc8bad44 100644
--- a/src/core/aspects/aspects.pri
+++ b/src/core/aspects/aspects.pri
@@ -9,7 +9,6 @@ SOURCES += \
HEADERS += \
$$PWD/qabstractaspect.h \
$$PWD/qaspectengine.h \
- $$PWD/qaspectfactory.h \
$$PWD/qabstractaspect_p.h \
$$PWD/qaspectengine_p.h \
$$PWD/qaspectfactory_p.h \
diff --git a/src/core/aspects/qaspectengine.cpp b/src/core/aspects/qaspectengine.cpp
index 38b3aefac..f044ef359 100644
--- a/src/core/aspects/qaspectengine.cpp
+++ b/src/core/aspects/qaspectengine.cpp
@@ -281,18 +281,6 @@ QSharedPointer<QEntity> QAspectEngine::rootEntity() const
return d->m_root;
}
-QAspectFactory QAspectEngine::aspectFactory() const
-{
- Q_D(const QAspectEngine);
- return d->m_factory;
-}
-
-void QAspectEngine::setAspectFactory(const QAspectFactory &factory)
-{
- Q_D(QAspectEngine);
- d->m_factory = factory;
-}
-
} // namespace Qt3DCore
QT_END_NAMESPACE
diff --git a/src/core/aspects/qaspectengine.h b/src/core/aspects/qaspectengine.h
index e9e768add..fca3256f2 100644
--- a/src/core/aspects/qaspectengine.h
+++ b/src/core/aspects/qaspectengine.h
@@ -38,9 +38,10 @@
#define QT3DCORE_QASPECTENGINE_H
#include <QObject>
-#include <Qt3DCore/QAspectFactory>
#include <QList>
+#include <Qt3DCore/qt3dcore_global.h>
+
QT_BEGIN_NAMESPACE
namespace Qt3DCore {
@@ -64,9 +65,6 @@ public:
void setRootEntity(QEntity *root);
QSharedPointer<QEntity> rootEntity() const;
- QAspectFactory aspectFactory() const;
- void setAspectFactory(const QAspectFactory &factory);
-
void setData(const QVariantMap &data);
void registerAspect(QAbstractAspect *aspect);
void registerAspect(const QString &name);
diff --git a/src/core/aspects/qaspectengine_p.h b/src/core/aspects/qaspectengine_p.h
index 0439058d1..be5b842a7 100644
--- a/src/core/aspects/qaspectengine_p.h
+++ b/src/core/aspects/qaspectengine_p.h
@@ -49,7 +49,7 @@
//
#include <private/qobject_p.h>
-#include <Qt3DCore/qaspectengine.h>
+#include <Qt3DCore/private/qaspectfactory_p.h>
#include <QtCore/qsharedpointer.h>
QT_BEGIN_NAMESPACE
diff --git a/src/core/aspects/qaspectfactory.cpp b/src/core/aspects/qaspectfactory.cpp
index ff1bc7d2b..416aa2563 100644
--- a/src/core/aspects/qaspectfactory.cpp
+++ b/src/core/aspects/qaspectfactory.cpp
@@ -34,7 +34,6 @@
**
****************************************************************************/
-#include "qaspectfactory.h"
#include "qaspectfactory_p.h"
#include <QtGlobal>
@@ -54,22 +53,13 @@ QT3DCORESHARED_EXPORT void qt3d_QAspectFactory_addDefaultFactory(const QString &
defaultFactories->insert(name, factory);
}
-/*!
- \class Qt3DCore::QAspectFactoryPrivate
- \internal
-*/
-QAspectFactoryPrivate::QAspectFactoryPrivate()
- : m_factories(*defaultFactories)
-{
-}
-
QAspectFactory::QAspectFactory()
- : d(new QAspectFactoryPrivate)
+ : m_factories(*defaultFactories)
{
}
QAspectFactory::QAspectFactory(const QAspectFactory &other)
- : d(other.d)
+ : m_factories(other.m_factories)
{
}
@@ -79,24 +69,24 @@ QAspectFactory::~QAspectFactory()
QAspectFactory &QAspectFactory::operator=(const QAspectFactory &other)
{
- d = other.d;
+ m_factories = other.m_factories;
return *this;
}
void QAspectFactory::addFactory(const QString &name, QAspectFactory::CreateFunction factory)
{
- d->m_factories.insert(name, factory);
+ m_factories.insert(name, factory);
}
QStringList QAspectFactory::availableFactories() const
{
- return d->m_factories.keys();
+ return m_factories.keys();
}
QAbstractAspect *QAspectFactory::createAspect(const QString &aspect, QObject *parent) const
{
- if (d->m_factories.contains(aspect)) {
- return d->m_factories.value(aspect)(parent);
+ if (m_factories.contains(aspect)) {
+ return m_factories.value(aspect)(parent);
} else {
qWarning() << "Unsupported aspect name:" << aspect << "please check registrations";
return Q_NULLPTR;
diff --git a/src/core/aspects/qaspectfactory.h b/src/core/aspects/qaspectfactory.h
deleted file mode 100644
index d0f867f6e..000000000
--- a/src/core/aspects/qaspectfactory.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT3DCORE_QASPECTFACTORY_H
-#define QT3DCORE_QASPECTFACTORY_H
-
-#include <QSharedDataPointer>
-#include <QStringList>
-
-#include <Qt3DCore/qt3dcore_global.h>
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-
-namespace Qt3DCore {
-
-class QAbstractAspect;
-class QAspectFactoryPrivate;
-
-class QT3DCORESHARED_EXPORT QAspectFactory
-{
-public:
- typedef QAbstractAspect *(*CreateFunction)(QObject *);
-
- template<class AspectType>
- static QAbstractAspect *functionHelper(QObject *parent)
- {
- return new AspectType(parent);
- }
-
- QAspectFactory();
- QAspectFactory(const QAspectFactory &other);
- ~QAspectFactory();
- QAspectFactory &operator=(const QAspectFactory &other);
-#ifdef Q_COMPILER_RVALUE_REFS
- QAspectFactory &operator=(QAspectFactory &&other) Q_DECL_NOTHROW
- {
- d.swap(other.d);
- return *this;
- }
-#endif
-
- inline void swap(QAspectFactory &other) Q_DECL_NOTHROW { d.swap(other.d); }
-
- void addFactory(const QString &name, CreateFunction factory);
- QStringList availableFactories() const;
-
- QAbstractAspect *createAspect(const QString &aspect, QObject *parent = 0) const;
-
-private:
- QSharedDataPointer<QAspectFactoryPrivate> d;
-};
-
-} // namespace Qt3DCore
-
-QT_END_NAMESPACE
-
-#endif // QT3DCORE_QASPECTFACTORY_H
diff --git a/src/core/aspects/qaspectfactory_p.h b/src/core/aspects/qaspectfactory_p.h
index dfe7ccd9e..6bbdc3dbe 100644
--- a/src/core/aspects/qaspectfactory_p.h
+++ b/src/core/aspects/qaspectfactory_p.h
@@ -49,26 +49,53 @@
//
#include <QHash>
-#include <QSharedData>
-#include <QString>
+#include <QStringList>
-#include "qaspectfactory.h"
+#include <Qt3DCore/private/qt3dcore_global_p.h>
QT_BEGIN_NAMESPACE
+class QObject;
+
namespace Qt3DCore {
-class QAspectFactory;
+class QAbstractAspect;
-class QAspectFactoryPrivate : public QSharedData
+class QT3DCORE_PRIVATE_EXPORT QAspectFactory
{
public:
- QAspectFactoryPrivate();
+ typedef QAbstractAspect *(*CreateFunction)(QObject *);
+
+ template<class AspectType>
+ static QAbstractAspect *functionHelper(QObject *parent)
+ {
+ return new AspectType(parent);
+ }
+
+ QAspectFactory();
+ QAspectFactory(const QAspectFactory &other);
+ ~QAspectFactory();
+ QAspectFactory &operator=(const QAspectFactory &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QAspectFactory &operator=(QAspectFactory &&other) Q_DECL_NOTHROW
+ {
+ m_factories.swap(other.m_factories);
+ return *this;
+ }
+#endif
+
+ inline void swap(QAspectFactory &other) Q_DECL_NOTHROW { m_factories.swap(other.m_factories); }
+
+ void addFactory(const QString &name, CreateFunction factory);
+ QStringList availableFactories() const;
+
+ QAbstractAspect *createAspect(const QString &aspect, QObject *parent = 0) const;
+private:
QHash<QString, QAspectFactory::CreateFunction> m_factories;
};
-} // Qt3D
+} // namespace Qt3DCore
QT_END_NAMESPACE
diff --git a/tests/auto/core/qaspectfactory/qaspectfactory.pro b/tests/auto/core/qaspectfactory/qaspectfactory.pro
index d1ec63d3d..b5b5dd5fe 100644
--- a/tests/auto/core/qaspectfactory/qaspectfactory.pro
+++ b/tests/auto/core/qaspectfactory/qaspectfactory.pro
@@ -4,4 +4,4 @@ TEMPLATE = app
SOURCES += tst_qaspectfactory.cpp
-QT += testlib 3dcore
+QT += testlib 3dcore 3dcore-private
diff --git a/tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp b/tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp
index 4a1016bc2..371c54e41 100644
--- a/tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp
+++ b/tests/auto/core/qaspectfactory/tst_qaspectfactory.cpp
@@ -35,7 +35,7 @@
****************************************************************************/
#include <QtTest/QTest>
-#include <Qt3DCore/QAspectFactory>
+#include <Qt3DCore/private/qaspectfactory_p.h>
#include <Qt3DCore/QAbstractAspect>
using namespace QT_PREPEND_NAMESPACE(Qt3DCore);