summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2015-12-02 17:18:03 +0100
committerKevin Ottens <kevin.ottens@kdab.com>2015-12-03 13:49:19 +0000
commitec471e983146dbaf52191c01e7ad737900e9459c (patch)
treeae26f82464425652059159f71dd0808c91338802 /src
parent8a49e06fbbeff56993fe74868400b33709b24ac8 (diff)
Make QNodeVisitor private
Change-Id: Ie36f6f170b5b627d0ed371bcd1a8dc292e7226b3 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/aspects/qabstractaspect.cpp2
-rw-r--r--src/core/aspects/qaspectengine.cpp2
-rw-r--r--src/core/nodes/nodes.pri1
-rw-r--r--src/core/nodes/qnode.cpp2
-rw-r--r--src/core/nodes/qnodevisitor.cpp20
-rw-r--r--src/core/nodes/qnodevisitor.h260
-rw-r--r--src/core/nodes/qnodevisitor_p.h207
7 files changed, 213 insertions, 281 deletions
diff --git a/src/core/aspects/qabstractaspect.cpp b/src/core/aspects/qabstractaspect.cpp
index 3db95d315..94b3b6ca5 100644
--- a/src/core/aspects/qabstractaspect.cpp
+++ b/src/core/aspects/qabstractaspect.cpp
@@ -41,7 +41,7 @@
#include <Qt3DCore/private/qaspectjobmanager_p.h>
#include <private/qchangearbiter_p.h>
#include <Qt3DCore/private/qscene_p.h>
-#include <Qt3DCore/qnodevisitor.h>
+#include <Qt3DCore/private/qnodevisitor_p.h>
#include <Qt3DCore/qscenepropertychange.h>
QT_BEGIN_NAMESPACE
diff --git a/src/core/aspects/qaspectengine.cpp b/src/core/aspects/qaspectengine.cpp
index 21b90090d..100f51b17 100644
--- a/src/core/aspects/qaspectengine.cpp
+++ b/src/core/aspects/qaspectengine.cpp
@@ -48,10 +48,10 @@
#include <private/qscene_p.h>
#include <private/qaspectengine_p.h>
#include <private/qnode_p.h>
+#include <private/qnodevisitor_p.h>
#include <private/qscene_p.h>
#include "qentity.h"
#include "qcomponent.h"
-#include "qnodevisitor.h"
#include <Qt3DCore/qeventfilterservice.h>
#include <Qt3DCore/qservicelocator.h>
diff --git a/src/core/nodes/nodes.pri b/src/core/nodes/nodes.pri
index 0d3d68052..64823813e 100644
--- a/src/core/nodes/nodes.pri
+++ b/src/core/nodes/nodes.pri
@@ -10,7 +10,6 @@ HEADERS += \
$$PWD/qbackendnode_p.h \
$$PWD/qbackendnode.h \
$$PWD/qnodeid.h \
- $$PWD/qnodevisitor.h \
$$PWD/qnodevisitor_p.h \
$$PWD/qabstractnodefactory.h \
$$PWD/propertychangehandler_p.h
diff --git a/src/core/nodes/qnode.cpp b/src/core/nodes/qnode.cpp
index d93bab672..cad9e501b 100644
--- a/src/core/nodes/qnode.cpp
+++ b/src/core/nodes/qnode.cpp
@@ -48,7 +48,7 @@
#include <QMetaProperty>
#include <Qt3DCore/QComponent>
#include <Qt3DCore/private/corelogging_p.h>
-#include <Qt3DCore/qnodevisitor.h>
+#include <Qt3DCore/private/qnodevisitor_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/core/nodes/qnodevisitor.cpp b/src/core/nodes/qnodevisitor.cpp
index 21192d926..541c6654b 100644
--- a/src/core/nodes/qnodevisitor.cpp
+++ b/src/core/nodes/qnodevisitor.cpp
@@ -40,48 +40,42 @@ QT_BEGIN_NAMESPACE
namespace Qt3DCore {
-QNodeVisitorPrivate::QNodeVisitorPrivate()
-{
-}
-
-QNodeVisitor::QNodeVisitor() :
- d_ptr(new QNodeVisitorPrivate)
+QNodeVisitor::QNodeVisitor()
{
}
QNodeVisitor::~QNodeVisitor()
{
- delete d_ptr;
}
QNode* QNodeVisitor::rootNode() const
{
- return d_ptr->m_path.front();
+ return m_path.front();
}
QNode* QNodeVisitor::currentNode() const
{
- return d_ptr->m_path.back();
+ return m_path.back();
}
void QNodeVisitor::setPath(QNodeList path)
{
- d_ptr->m_path = path;
+ m_path = path;
}
QNodeList QNodeVisitor::path() const
{
- return d_ptr->m_path;
+ return m_path;
}
void QNodeVisitor::append(QNode *n)
{
- d_ptr->m_path.append(n);
+ m_path.append(n);
}
void QNodeVisitor::pop_back()
{
- d_ptr->m_path.pop_back();
+ m_path.pop_back();
}
} // namespace Qt3DCore
diff --git a/src/core/nodes/qnodevisitor.h b/src/core/nodes/qnodevisitor.h
deleted file mode 100644
index 69a452a83..000000000
--- a/src/core/nodes/qnodevisitor.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/****************************************************************************
-**
-** 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: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_QNODEVISITOR_H
-#define QT3DCORE_QNODEVISITOR_H
-
-#include <Qt3DCore/qt3dcore_global.h>
-#include <Qt3DCore/qnode.h>
-#include <Qt3DCore/qentity.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DCore
-{
-
-class QNodeVisitorPrivate;
-
-class QT3DCORESHARED_EXPORT QNodeVisitor
-{
-public:
- QNodeVisitor();
- virtual ~QNodeVisitor();
-
- template<typename NodeVisitorFunc>
- void traverse(QNode *rootNode_, NodeVisitorFunc fN)
- {
- startTraversing(rootNode_, createFunctor(fN));
- }
-
- template<typename Obj, typename NodeVisitorFunc>
- void traverse(QNode *rootNode_, Obj *instance, NodeVisitorFunc fN)
- {
- startTraversing(rootNode_, createFunctor(instance, fN));
- }
-
- template<typename NodeVisitorFunc, typename EntityVisitorFunc>
- void traverse(QNode *rootNode_, NodeVisitorFunc fN, EntityVisitorFunc fE)
- {
- startTraversing(rootNode_, createFunctor(fN), createFunctor(fE));
- }
-
- template<typename Obj, typename NodeVisitorFunc, typename EntityVisitorFunc>
- void traverse(QNode *rootNode_, Obj *instance, NodeVisitorFunc fN, EntityVisitorFunc fE)
- {
- startTraversing(rootNode_, createFunctor(instance, fN), createFunctor(instance, fE));
- }
-
- QNode *rootNode() const;
- QNode *currentNode() const;
- void setPath(QNodeList path);
- QNodeList path() const;
- void append(QNode *n);
- void pop_back();
-
-private:
- QNodeVisitorPrivate *d_ptr;
-
- template<typename NodeVisitorFunctor>
- void startTraversing(QNode *rootNode_, NodeVisitorFunctor fN)
- {
- setPath(QNodeList() << rootNode_);
- if (rootNode_)
- visitNode(rootNode_, fN);
- }
-
- template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
- void startTraversing(QNode *rootNode_, NodeVisitorFunctor fN, EntityVisitorFunctor fE)
- {
- setPath(QNodeList() << rootNode_);
- QEntity* rootEntity = qobject_cast<QEntity *>(rootNode_);
-
- if (rootEntity)
- visitEntity(rootEntity, fN, fE);
- else if (rootNode_)
- visitNode(rootNode_, fN, fE);
- }
-
- template<typename NodeVisitorFunctor>
- void visitNode(QNode *nd, NodeVisitorFunctor &fN)
- {
- fN(nd);
- traverseChildren(fN);
- }
-
- template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
- void visitNode(QNode *nd, NodeVisitorFunctor &fN, EntityVisitorFunctor &fE)
- {
- fN(nd);
- traverseChildren(fN, fE);
- }
-
- template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
- void visitEntity(QEntity *ent, NodeVisitorFunctor &fN, EntityVisitorFunctor &fE)
- {
- fE(ent);
- visitNode(ent, fN, fE);
- }
-
- template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
- void traverseChildren(NodeVisitorFunctor &fN, EntityVisitorFunctor &fE)
- {
- Q_FOREACH (QObject *n, currentNode()->children()) {
- QNode *node = qobject_cast<QNode *>(n);
- if (node != Q_NULLPTR)
- outerVisitNode(node, fN, fE);
- } // of children iteration
- }
-
- template<typename NodeVisitorFunctor>
- void traverseChildren(NodeVisitorFunctor &fN)
- {
- Q_FOREACH (QObject *n, currentNode()->children()) {
- QNode *node = qobject_cast<QNode *>(n);
- if (node != Q_NULLPTR)
- outerVisitNode(node, fN);
- } // of children iteration
- }
-
- template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
- void outerVisitNode(QNode *n, NodeVisitorFunctor &fN, EntityVisitorFunctor &fE)
- {
- append(n);
- QEntity* e = qobject_cast<QEntity *>(n);
- if (e) {
- visitEntity(e, fN, fE);
- } else {
- visitNode(n, fN, fE);
- }
- pop_back();
- }
-
- template<typename NodeVisitorFunctor>
- void outerVisitNode(QNode *n, NodeVisitorFunctor &fN)
- {
- append(n);
- visitNode(n, fN);
- pop_back();
- }
-
- template <typename NodeType>
- class FunctionFunctor {
- public:
- typedef void (*functionPtr)(NodeType);
-
- FunctionFunctor(functionPtr fPtr)
- : m_functionPointer(fPtr)
- {}
-
- void operator()(NodeType node)
- {
- (*m_functionPointer)(node);
- }
-
- private:
- functionPtr m_functionPointer;
- };
-
- template <typename C, typename NodeType>
- class MemberFunctionFunctor {
- public:
- typedef void (C::*functionPtr)(NodeType);
-
- MemberFunctionFunctor(C* instance, functionPtr fPtr)
- : m_instance(instance)
- , m_functionPointer(fPtr)
- {}
-
- void operator()(NodeType node)
- {
- (*m_instance.*m_functionPointer)(node);
- }
-
- private:
- C *m_instance;
- functionPtr m_functionPointer;
- };
-
- template <typename C, typename NodeType>
- class ConstMemberFunctionFunctor {
- public:
- typedef void (C::*functionPtr)(NodeType) const;
-
- ConstMemberFunctionFunctor(C* instance, functionPtr fPtr)
- : m_instance(instance)
- , m_functionPointer(fPtr)
- {}
-
- void operator()(NodeType node) const
- {
- (*m_instance.*m_functionPointer)(node);
- }
-
- private:
- C *m_instance;
- functionPtr m_functionPointer;
- };
-
- template <typename T>
- const T& createFunctor(const T& t)
- {
- return t;
- }
-
- template <typename NodeType>
- FunctionFunctor<NodeType> createFunctor(void (*fPtr)(NodeType))
- {
- return FunctionFunctor<NodeType>(fPtr);
- }
-
- template <typename C, typename NodeType>
- MemberFunctionFunctor<C, NodeType> createFunctor(C *instance, void (C::*fPtr)(NodeType))
- {
- return MemberFunctionFunctor<C, NodeType>(instance, fPtr);
- }
-
- template <typename C, typename NodeType>
- ConstMemberFunctionFunctor<C, NodeType> createFunctor(C *instance, void (C::*fPtr)(NodeType) const)
- {
- return ConstMemberFunctionFunctor<C, NodeType>(instance, fPtr);
- }
-};
-
-} // namespace Qt3DCore
-
-QT_END_NAMESPACE
-
-#endif // QT3DCORE_QNODEVISITOR_H
diff --git a/src/core/nodes/qnodevisitor_p.h b/src/core/nodes/qnodevisitor_p.h
index 316a3a713..dfe513774 100644
--- a/src/core/nodes/qnodevisitor_p.h
+++ b/src/core/nodes/qnodevisitor_p.h
@@ -48,23 +48,222 @@
// We mean it.
//
-#include <Qt3DCore/qnodevisitor.h>
+#include <Qt3DCore/qt3dcore_global.h>
+#include <Qt3DCore/qnode.h>
+#include <Qt3DCore/qentity.h>
QT_BEGIN_NAMESPACE
namespace Qt3DCore
{
-class QNodeVisitorPrivate
+class QT3DCORESHARED_EXPORT QNodeVisitor
{
public:
- QNodeVisitorPrivate();
+ QNodeVisitor();
+ virtual ~QNodeVisitor();
+ template<typename NodeVisitorFunc>
+ void traverse(QNode *rootNode_, NodeVisitorFunc fN)
+ {
+ startTraversing(rootNode_, createFunctor(fN));
+ }
+
+ template<typename Obj, typename NodeVisitorFunc>
+ void traverse(QNode *rootNode_, Obj *instance, NodeVisitorFunc fN)
+ {
+ startTraversing(rootNode_, createFunctor(instance, fN));
+ }
+
+ template<typename NodeVisitorFunc, typename EntityVisitorFunc>
+ void traverse(QNode *rootNode_, NodeVisitorFunc fN, EntityVisitorFunc fE)
+ {
+ startTraversing(rootNode_, createFunctor(fN), createFunctor(fE));
+ }
+
+ template<typename Obj, typename NodeVisitorFunc, typename EntityVisitorFunc>
+ void traverse(QNode *rootNode_, Obj *instance, NodeVisitorFunc fN, EntityVisitorFunc fE)
+ {
+ startTraversing(rootNode_, createFunctor(instance, fN), createFunctor(instance, fE));
+ }
+
+ QNode *rootNode() const;
+ QNode *currentNode() const;
+ void setPath(QNodeList path);
+ QNodeList path() const;
+ void append(QNode *n);
+ void pop_back();
+
+private:
QNodeList m_path;
+
+ template<typename NodeVisitorFunctor>
+ void startTraversing(QNode *rootNode_, NodeVisitorFunctor fN)
+ {
+ setPath(QNodeList() << rootNode_);
+ if (rootNode_)
+ visitNode(rootNode_, fN);
+ }
+
+ template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
+ void startTraversing(QNode *rootNode_, NodeVisitorFunctor fN, EntityVisitorFunctor fE)
+ {
+ setPath(QNodeList() << rootNode_);
+ QEntity* rootEntity = qobject_cast<QEntity *>(rootNode_);
+
+ if (rootEntity)
+ visitEntity(rootEntity, fN, fE);
+ else if (rootNode_)
+ visitNode(rootNode_, fN, fE);
+ }
+
+ template<typename NodeVisitorFunctor>
+ void visitNode(QNode *nd, NodeVisitorFunctor &fN)
+ {
+ fN(nd);
+ traverseChildren(fN);
+ }
+
+ template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
+ void visitNode(QNode *nd, NodeVisitorFunctor &fN, EntityVisitorFunctor &fE)
+ {
+ fN(nd);
+ traverseChildren(fN, fE);
+ }
+
+ template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
+ void visitEntity(QEntity *ent, NodeVisitorFunctor &fN, EntityVisitorFunctor &fE)
+ {
+ fE(ent);
+ visitNode(ent, fN, fE);
+ }
+
+ template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
+ void traverseChildren(NodeVisitorFunctor &fN, EntityVisitorFunctor &fE)
+ {
+ Q_FOREACH (QObject *n, currentNode()->children()) {
+ QNode *node = qobject_cast<QNode *>(n);
+ if (node != Q_NULLPTR)
+ outerVisitNode(node, fN, fE);
+ } // of children iteration
+ }
+
+ template<typename NodeVisitorFunctor>
+ void traverseChildren(NodeVisitorFunctor &fN)
+ {
+ Q_FOREACH (QObject *n, currentNode()->children()) {
+ QNode *node = qobject_cast<QNode *>(n);
+ if (node != Q_NULLPTR)
+ outerVisitNode(node, fN);
+ } // of children iteration
+ }
+
+ template<typename NodeVisitorFunctor, typename EntityVisitorFunctor>
+ void outerVisitNode(QNode *n, NodeVisitorFunctor &fN, EntityVisitorFunctor &fE)
+ {
+ append(n);
+ QEntity* e = qobject_cast<QEntity *>(n);
+ if (e) {
+ visitEntity(e, fN, fE);
+ } else {
+ visitNode(n, fN, fE);
+ }
+ pop_back();
+ }
+
+ template<typename NodeVisitorFunctor>
+ void outerVisitNode(QNode *n, NodeVisitorFunctor &fN)
+ {
+ append(n);
+ visitNode(n, fN);
+ pop_back();
+ }
+
+ template <typename NodeType>
+ class FunctionFunctor {
+ public:
+ typedef void (*functionPtr)(NodeType);
+
+ FunctionFunctor(functionPtr fPtr)
+ : m_functionPointer(fPtr)
+ {}
+
+ void operator()(NodeType node)
+ {
+ (*m_functionPointer)(node);
+ }
+
+ private:
+ functionPtr m_functionPointer;
+ };
+
+ template <typename C, typename NodeType>
+ class MemberFunctionFunctor {
+ public:
+ typedef void (C::*functionPtr)(NodeType);
+
+ MemberFunctionFunctor(C* instance, functionPtr fPtr)
+ : m_instance(instance)
+ , m_functionPointer(fPtr)
+ {}
+
+ void operator()(NodeType node)
+ {
+ (*m_instance.*m_functionPointer)(node);
+ }
+
+ private:
+ C *m_instance;
+ functionPtr m_functionPointer;
+ };
+
+ template <typename C, typename NodeType>
+ class ConstMemberFunctionFunctor {
+ public:
+ typedef void (C::*functionPtr)(NodeType) const;
+
+ ConstMemberFunctionFunctor(C* instance, functionPtr fPtr)
+ : m_instance(instance)
+ , m_functionPointer(fPtr)
+ {}
+
+ void operator()(NodeType node) const
+ {
+ (*m_instance.*m_functionPointer)(node);
+ }
+
+ private:
+ C *m_instance;
+ functionPtr m_functionPointer;
+ };
+
+ template <typename T>
+ const T& createFunctor(const T& t)
+ {
+ return t;
+ }
+
+ template <typename NodeType>
+ FunctionFunctor<NodeType> createFunctor(void (*fPtr)(NodeType))
+ {
+ return FunctionFunctor<NodeType>(fPtr);
+ }
+
+ template <typename C, typename NodeType>
+ MemberFunctionFunctor<C, NodeType> createFunctor(C *instance, void (C::*fPtr)(NodeType))
+ {
+ return MemberFunctionFunctor<C, NodeType>(instance, fPtr);
+ }
+
+ template <typename C, typename NodeType>
+ ConstMemberFunctionFunctor<C, NodeType> createFunctor(C *instance, void (C::*fPtr)(NodeType) const)
+ {
+ return ConstMemberFunctionFunctor<C, NodeType>(instance, fPtr);
+ }
};
} // namespace Qt3DCore
QT_END_NAMESPACE
-#endif // QT3DCORE_QNODEVISITOR_H
+#endif // QT3DCORE_QNODEVISITOR_P_H