summaryrefslogtreecommitdiffstats
path: root/src/core/nodes
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-10-10 09:22:46 +0200
committerPaul Lemire <paul.lemire@kdab.com>2014-10-17 15:12:56 +0200
commit35b667790a7c32850d9128a53c0c15b4aeb447ac (patch)
tree09efd4b46ab3a65a7e43dac4dd93a45b541dd4fe /src/core/nodes
parent117fbb51ea3f9fe610de02b95b043909dbc2f40e (diff)
QBackendNode
QBackendNodeCreatorFunctor added to provide a way to create a backend tree classes from a frontend one. Can be readonly / readwrite -> observer / observer + observable QAbstractAspect now has a registerBackendType to register a QBackendNodeCreatorFunctor against a frontend type. QBackendObservable is replaced by this class. Follow-up commits will add a QBackendNoceCreatorFunctor for each backend class of the RendererAspect. Change-Id: I0b4398ce77408b52ffa0ba3dfdd04903cfd6091d Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/nodes')
-rw-r--r--src/core/nodes/nodes.pri8
-rw-r--r--src/core/nodes/qbackendnode.cpp135
-rw-r--r--src/core/nodes/qbackendnode.h101
-rw-r--r--src/core/nodes/qbackendnode_p.h81
4 files changed, 323 insertions, 2 deletions
diff --git a/src/core/nodes/nodes.pri b/src/core/nodes/nodes.pri
index 849b987a1..09954b3c6 100644
--- a/src/core/nodes/nodes.pri
+++ b/src/core/nodes/nodes.pri
@@ -7,10 +7,14 @@ HEADERS += \
$$PWD/qcomponent.h \
$$PWD/qcomponent_p.h \
$$PWD/qentity.h \
- $$PWD/qentity_p.h
+ $$PWD/qentity_p.h \
+ $$PWD/qbackendnode_p.h \
+ $$PWD/qbackendnode.h
SOURCES += \
$$PWD/qnode.cpp \
$$PWD/nodevisitor.cpp \
$$PWD/qcomponent.cpp \
- $$PWD/qentity.cpp
+ $$PWD/qentity.cpp \
+ $$PWD/qbackendnode.cpp
+
diff --git a/src/core/nodes/qbackendnode.cpp b/src/core/nodes/qbackendnode.cpp
new file mode 100644
index 000000000..ecf7ea631
--- /dev/null
+++ b/src/core/nodes/qbackendnode.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbackendnode.h"
+#include "qbackendnode_p.h"
+#include "qaspectengine.h"
+#include "qchangearbiter_p.h"
+#include "qnode.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+QBackendNodePrivate::QBackendNodePrivate(QBackendNode *qq, QBackendNode::Mode mode)
+ : QObservable()
+ , q_ptr(qq)
+ , m_mode(mode)
+ , m_arbiter(Q_NULLPTR)
+{
+}
+
+void QBackendNodePrivate::registerObserver(QObserverInterface *observer)
+{
+ Q_ASSERT(m_mode == QBackendNode::ReadWrite);
+ m_arbiter = dynamic_cast<QChangeArbiter *>(observer);
+}
+
+void QBackendNodePrivate::unregisterObserver(QObserverInterface *observer)
+{
+ Q_ASSERT(m_mode == QBackendNode::ReadWrite);
+ if (dynamic_cast<QChangeArbiter *>(observer) == m_arbiter)
+ m_arbiter = Q_NULLPTR;
+}
+
+void QBackendNodePrivate::notifyObservers(const QSceneChangePtr &e)
+{
+ Q_ASSERT(m_mode == QBackendNode::ReadWrite);
+ if (m_arbiter != Q_NULLPTR)
+ m_arbiter->sceneChangeEventWithLock(e);
+}
+
+void QBackendNodePrivate::sceneChangeEvent(const QSceneChangePtr &e)
+{
+ q_ptr->sceneChangeEvent(e);
+}
+
+QBackendNodePrivate *QBackendNodePrivate::get(QBackendNode *n)
+{
+ return n->d_func();
+}
+
+QBackendNode::QBackendNode(QBackendNode::Mode mode)
+ : d_ptr(new QBackendNodePrivate(this, mode))
+{
+}
+
+QBackendNode::~QBackendNode()
+{
+ delete d_ptr;
+}
+
+void QBackendNode::setPeer(QNode *peer)
+{
+ Q_D(QBackendNode);
+ QUuid peerUuid;
+ if (peer != Q_NULLPTR)
+ peerUuid = peer->uuid();
+ d->m_peerUuid = peerUuid;
+ updateFromPeer(peer);
+}
+
+QUuid QBackendNode::peerUuid() const
+{
+ Q_D(const QBackendNode);
+ return d->m_peerUuid;
+}
+
+QBackendNode::Mode QBackendNode::mode() const
+{
+ Q_D(const QBackendNode);
+ return d->m_mode;
+}
+
+QBackendNode::QBackendNode(QBackendNodePrivate &dd)
+ : d_ptr(&dd)
+{
+}
+
+void QBackendNode::notifyObservers(const QSceneChangePtr &e)
+{
+ Q_D(QBackendNode);
+ d->notifyObservers(e);
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE
diff --git a/src/core/nodes/qbackendnode.h b/src/core/nodes/qbackendnode.h
new file mode 100644
index 000000000..823b005d9
--- /dev/null
+++ b/src/core/nodes/qbackendnode.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_QBACKENDNODE_H
+#define QT3D_QBACKENDNODE_H
+
+#include <Qt3DCore/qt3dcore_global.h>
+#include <Qt3DCore/qscenechange.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QBackendNodePrivate;
+class QBackendNode;
+class QAspectEngine;
+
+class QT3DCORESHARED_EXPORT QBackendNodeFunctor
+{
+public:
+ virtual ~QBackendNodeFunctor() {}
+ virtual QBackendNode *create(QNode *frontend) const = 0;
+ virtual QBackendNode *get(QNode *frontend) const = 0;
+ virtual void destroy(QNode *frontend) const = 0;
+};
+
+typedef QSharedPointer<QBackendNodeFunctor> QBackendNodeFunctorPtr;
+
+class QT3DCORESHARED_EXPORT QBackendNode
+{
+public:
+ enum Mode {
+ ReadOnly = 0,
+ ReadWrite
+ };
+
+ explicit QBackendNode(Mode mode = ReadOnly);
+ virtual ~QBackendNode();
+
+ void setPeer(QNode *peer);
+ QUuid peerUuid() const;
+
+ Mode mode() const;
+ virtual void updateFromPeer(QNode *peer) = 0;
+
+protected:
+ void notifyObservers(const QSceneChangePtr &e);
+ virtual void sceneChangeEvent(const QSceneChangePtr &e) = 0;
+
+ QBackendNode(QBackendNodePrivate &dd);
+
+private:
+ Q_DECLARE_PRIVATE(QBackendNode)
+ QBackendNodePrivate *d_ptr;
+ friend class QBackendScenePropertyChange;
+};
+
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_QBACKENDNODE_H
diff --git a/src/core/nodes/qbackendnode_p.h b/src/core/nodes/qbackendnode_p.h
new file mode 100644
index 000000000..995c2c68c
--- /dev/null
+++ b/src/core/nodes/qbackendnode_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_QBACKENDNODE_P_H
+#define QT3D_QBACKENDNODE_P_H
+
+#include <QUuid>
+#include <Qt3DCore/private/qobservable_p.h>
+#include <Qt3DCore/private/qobserverinterface_p.h>
+#include <Qt3DCore/qbackendnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QChangeArbiter;
+
+class QBackendNodePrivate
+ : public QObserverInterface
+ , public QObservable
+{
+public:
+ QBackendNodePrivate(QBackendNode *qq, QBackendNode::Mode mode);
+
+ void registerObserver(QObserverInterface *observer) Q_DECL_OVERRIDE;
+ void unregisterObserver(QObserverInterface *observer) Q_DECL_OVERRIDE;
+ void notifyObservers(const QSceneChangePtr &e) Q_DECL_OVERRIDE;
+ void sceneChangeEvent(const QSceneChangePtr &e) Q_DECL_OVERRIDE;
+
+ static QBackendNodePrivate *get(QBackendNode *n);
+
+ Q_DECLARE_PUBLIC(QBackendNode)
+ QBackendNode *q_ptr;
+ QBackendNode::Mode m_mode;
+ QChangeArbiter *m_arbiter;
+ QUuid m_peerUuid;
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_QBACKENDNODE_P_H