summaryrefslogtreecommitdiffstats
path: root/src/render/io
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@theqtcompany.com>2015-11-03 18:21:58 +0100
committerAndy Nichols <andy.nichols@theqtcompany.com>2015-11-04 16:03:09 +0000
commit03d2259029cafe89c87d49c142131bd16d837c69 (patch)
treebdd7a21bbab058bb496a56a5528d5a6cc4abc56a /src/render/io
parent6806287f41efdaacb1efb006c3cec0a760f64b68 (diff)
Create proper plugin infrastructure for sceneloaders
Now Qt3D sceneloaders plugins follow the same pattern as the rest of Qt. This also makes the loading much more standard and less error prone. Change-Id: Ibb5aae0a16d9d197a9c34fe2885dd5435e68d7eb Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/io')
-rw-r--r--src/render/io/io.pri12
-rw-r--r--src/render/io/qabstractsceneloader.cpp2
-rw-r--r--src/render/io/qabstractsceneloader_p.h2
-rw-r--r--src/render/io/qabstractsceneparser.cpp (renamed from src/render/io/abstractsceneparser.cpp)16
-rw-r--r--src/render/io/qabstractsceneparser.h (renamed from src/render/io/abstractsceneparser_p.h)17
-rw-r--r--src/render/io/qsceneparserfactory.cpp93
-rw-r--r--src/render/io/qsceneparserfactory_p.h71
-rw-r--r--src/render/io/qsceneparserplugin.cpp63
-rw-r--r--src/render/io/qsceneparserplugin.h68
9 files changed, 316 insertions, 28 deletions
diff --git a/src/render/io/io.pri b/src/render/io/io.pri
index 70f00ab9a..bba72c4c2 100644
--- a/src/render/io/io.pri
+++ b/src/render/io/io.pri
@@ -1,20 +1,24 @@
INCLUDEPATH += $$PWD
HEADERS += \
- $$PWD/abstractsceneparser_p.h \
$$PWD/objloader_p.h \
$$PWD/qabstractsceneloader.h \
$$PWD/qabstractsceneloader_p.h \
$$PWD/qsceneloader.h \
$$PWD/scene_p.h \
$$PWD/scenemanager_p.h \
- $$PWD/uniformbuffer_p.h
+ $$PWD/uniformbuffer_p.h \
+ $$PWD/qsceneparserfactory_p.h \
+ $$PWD/qabstractsceneparser.h \
+ $$PWD/qsceneparserplugin.h
SOURCES += \
- $$PWD/abstractsceneparser.cpp \
$$PWD/objloader.cpp \
$$PWD/qabstractsceneloader.cpp \
$$PWD/qsceneloader.cpp \
$$PWD/scene.cpp \
$$PWD/scenemanager.cpp \
- $$PWD/uniformbuffer.cpp
+ $$PWD/uniformbuffer.cpp \
+ $$PWD/qabstractsceneparser.cpp \
+ $$PWD/qsceneparserplugin.cpp \
+ $$PWD/qsceneparserfactory.cpp
diff --git a/src/render/io/qabstractsceneloader.cpp b/src/render/io/qabstractsceneloader.cpp
index e8b0119d7..debae5c89 100644
--- a/src/render/io/qabstractsceneloader.cpp
+++ b/src/render/io/qabstractsceneloader.cpp
@@ -36,8 +36,8 @@
#include "qabstractsceneloader.h"
#include "qabstractsceneloader_p.h"
+#include "qabstractsceneparser.h"
#include <Qt3DRender/private/renderlogging_p.h>
-#include <Qt3DRender/private/abstractsceneparser_p.h>
#include <Qt3DCore/qscenepropertychange.h>
QT_BEGIN_NAMESPACE
diff --git a/src/render/io/qabstractsceneloader_p.h b/src/render/io/qabstractsceneloader_p.h
index 1d4e646a4..80e1429a2 100644
--- a/src/render/io/qabstractsceneloader_p.h
+++ b/src/render/io/qabstractsceneloader_p.h
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class AbstractSceneParser;
+class QAbstractSceneParser;
class QAbstractSceneLoaderPrivate : public Qt3DCore::QComponentPrivate
{
diff --git a/src/render/io/abstractsceneparser.cpp b/src/render/io/qabstractsceneparser.cpp
index 1237dcffa..0a5378541 100644
--- a/src/render/io/abstractsceneparser.cpp
+++ b/src/render/io/qabstractsceneparser.cpp
@@ -34,7 +34,7 @@
**
****************************************************************************/
-#include "abstractsceneparser_p.h"
+#include "qabstractsceneparser.h"
#include <Qt3DRender/private/renderlogging_p.h>
#include <QStringList>
@@ -42,26 +42,26 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-AbstractSceneParser::AbstractSceneParser() : QObject(),
+QAbstractSceneParser::QAbstractSceneParser() : QObject(),
m_parserStatus(Empty)
{
}
-AbstractSceneParser::~AbstractSceneParser()
+QAbstractSceneParser::~QAbstractSceneParser()
{
}
-AbstractSceneParser::ParserStatus AbstractSceneParser::parserStatus() const
+QAbstractSceneParser::ParserStatus QAbstractSceneParser::parserStatus() const
{
return m_parserStatus;
}
-QStringList AbstractSceneParser::errors() const
+QStringList QAbstractSceneParser::errors() const
{
return m_errors;
}
-void AbstractSceneParser::setParserStatus(ParserStatus parserStatus)
+void QAbstractSceneParser::setParserStatus(ParserStatus parserStatus)
{
if (parserStatus != m_parserStatus) {
m_parserStatus = parserStatus;
@@ -69,13 +69,13 @@ void AbstractSceneParser::setParserStatus(ParserStatus parserStatus)
}
}
-void AbstractSceneParser::logError(const QString &error)
+void QAbstractSceneParser::logError(const QString &error)
{
m_errors.append(error);
emit errorsChanged();
}
-void AbstractSceneParser::logInfo(const QString &info)
+void QAbstractSceneParser::logInfo(const QString &info)
{
qCDebug(Render::Io) << info;
}
diff --git a/src/render/io/abstractsceneparser_p.h b/src/render/io/qabstractsceneparser.h
index eebb2e7f3..3f1681e3a 100644
--- a/src/render/io/abstractsceneparser_p.h
+++ b/src/render/io/qabstractsceneparser.h
@@ -37,17 +37,6 @@
#ifndef ABSTRACTSCENEPARSER_H
#define ABSTRACTSCENEPARSER_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
#include <QObject>
#include <QStringList>
#include <QLoggingCategory>
@@ -64,7 +53,7 @@ namespace Qt3DRender {
Q_DECLARE_LOGGING_CATEGORY(SceneParsers)
-class QT3DRENDERSHARED_EXPORT AbstractSceneParser : public QObject
+class QT3DRENDERSHARED_EXPORT QAbstractSceneParser : public QObject
{
Q_OBJECT
Q_PROPERTY(ParserStatus parserStatus READ parserStatus NOTIFY parserStatusChanged)
@@ -79,8 +68,8 @@ public:
};
Q_ENUM(ParserStatus)
- AbstractSceneParser();
- virtual ~AbstractSceneParser();
+ QAbstractSceneParser();
+ virtual ~QAbstractSceneParser();
virtual void setSource(const QUrl &source) = 0;
virtual bool isExtensionSupported(const QUrl &source) const = 0;
diff --git a/src/render/io/qsceneparserfactory.cpp b/src/render/io/qsceneparserfactory.cpp
new file mode 100644
index 000000000..8fba44db9
--- /dev/null
+++ b/src/render/io/qsceneparserfactory.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** 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$
+**
+****************************************************************************/
+
+#include "qsceneparserfactory_p.h"
+#include "qsceneparserplugin.h"
+#include "qabstractsceneparser.h"
+
+#include <QtCore/private/qfactoryloader_p.h>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+#ifndef QT_NO_LIBRARY
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QSceneParserFactoryInterface_iid, QLatin1String("/sceneparsers"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QSceneParserFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+#endif
+
+QStringList QSceneParserFactory::keys(const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ QStringList list;
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ list = directLoader()->keyMap().values();
+ if (!list.isEmpty()) {
+ const QString postFix = QStringLiteral(" (from ")
+ + QDir::toNativeSeparators(pluginPath)
+ + QLatin1Char(')');
+ const QStringList::iterator end = list.end();
+ for (QStringList::iterator it = list.begin(); it != end; ++it)
+ (*it).append(postFix);
+ }
+ }
+ list.append(loader()->keyMap().values());
+ return list;
+#else
+ return QStringList();
+#endif
+}
+
+QAbstractSceneParser *QSceneParserFactory::create(const QString &name, const QStringList &args, const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ if (QAbstractSceneParser *ret = qLoadPlugin1<QAbstractSceneParser, QSceneParserPlugin>(directLoader(), name, args))
+ return ret;
+ }
+ if (QAbstractSceneParser *ret = qLoadPlugin1<QAbstractSceneParser, QSceneParserPlugin>(loader(), name, args))
+ return ret;
+#endif
+ return Q_NULLPTR;
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/io/qsceneparserfactory_p.h b/src/render/io/qsceneparserfactory_p.h
new file mode 100644
index 000000000..b511b9169
--- /dev/null
+++ b/src/render/io/qsceneparserfactory_p.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** 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 QSCENEPARSERFACTORY_H
+#define QSCENEPARSERFACTORY_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qt3drender_global_p.h>
+#include <QtCore/QStringList>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QAbstractSceneParser;
+
+class QT3DRENDERSHARED_PRIVATE_EXPORT QSceneParserFactory
+{
+public:
+ static QStringList keys(const QString &pluginPath = QString());
+ static QAbstractSceneParser *create(const QString &name, const QStringList &args, const QString &pluginPath = QString());
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QSCENEPARSERFACTORY_H
diff --git a/src/render/io/qsceneparserplugin.cpp b/src/render/io/qsceneparserplugin.cpp
new file mode 100644
index 000000000..5581162e0
--- /dev/null
+++ b/src/render/io/qsceneparserplugin.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** 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$
+**
+****************************************************************************/
+
+#include "qsceneparserplugin.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+QSceneParserPlugin::QSceneParserPlugin(QObject *parent) : QObject(parent)
+{
+
+}
+
+QSceneParserPlugin::~QSceneParserPlugin()
+{
+
+}
+
+QAbstractSceneParser *QSceneParserPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key)
+ Q_UNUSED(paramList)
+ return Q_NULLPTR;
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
diff --git a/src/render/io/qsceneparserplugin.h b/src/render/io/qsceneparserplugin.h
new file mode 100644
index 000000000..0f47f670c
--- /dev/null
+++ b/src/render/io/qsceneparserplugin.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** 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 QSCENEPARSERPLUGIN_H
+#define QSCENEPARSERPLUGIN_H
+
+#include <QtCore/QObject>
+#include <QtCore/QtPlugin>
+#include <QtCore/QFactoryInterface>
+
+#include <qt3drender_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+#define QSceneParserFactoryInterface_iid "org.qt-project.Qt3DRender.QSceneParserFactoryInterface 5.6"
+
+class QAbstractSceneParser;
+
+class QT3DRENDERSHARED_EXPORT QSceneParserPlugin : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QSceneParserPlugin(QObject *parent = 0);
+ ~QSceneParserPlugin();
+
+ virtual QAbstractSceneParser *create(const QString &key, const QStringList &paramList);
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QSCENEPARSERPLUGIN_H