1/****************************************************************************
2**
3** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qscenechange.h"
41
42#include "qscenechange_p.h"
43
44QT_BEGIN_NAMESPACE
45
46namespace Qt3DCore {
47
48/*!
49 * \enum Qt3DCore::ChangeFlag
50 * \relates Qt3DCore::QSceneChange
51 *
52 * The types of change that can be sent and received by Qt3D's change notification system.
53 *
54 * \value NodeCreated A new instance of a QNode subclass has been created.
55 * \value NodeDeleted A QNode has been deleted.
56 * \value PropertyUpdated A QNode property has been updated.
57 * \value PropertyValueAdded A QNode has been added to the scene.
58 * \value PropertyValueRemoved A QNode has been removed from the scene.
59 * \value CommandRequested A QNodeCommand has been sent between a node and its backend.
60 * \value ComponentAdded A QComponent has been added to a QEntity.
61 * \value ComponentRemoved A QComponent has been removed from a QEntity.
62 * \value CallbackTriggered A QNode triggered a callback.
63 * \value AllChanges Allows an observer to monitor for any of the above changes.
64 */
65
66QSceneChangePrivate::QSceneChangePrivate()
67 : q_ptr(nullptr)
68 , m_subjectId()
69 , m_deliveryFlags(QSceneChange::BackendNodes)
70 , m_type(AllChanges)
71{
72}
73
74QSceneChangePrivate::~QSceneChangePrivate()
75{
76}
77
78/*!
79 * \class Qt3DCore::QSceneChange
80 * \inheaderfile Qt3DCore/QSceneChange
81 * \inmodule Qt3DCore
82 * \brief The base class for changes that can be sent and received by Qt3D's change notification system.
83 */
84
85/*!
86 * \typedef Qt3DCore::QSceneChangePtr
87 * \relates Qt3DCore::QSceneChange
88 *
89 * A shared pointer for QSceneChange.
90 */
91
92/*!
93 * \enum QSceneChange::DeliveryFlag
94 *
95 * The types of change that can be sent and received by Qt3D's change notification system.
96 *
97 * \value BackendNodes
98 * \value Nodes
99 * \value DeliverToAll
100 */
101
102/*!
103 * Constructs a new QSceneChange with \a type and \a subjectId.
104 */
105QSceneChange::QSceneChange(ChangeFlag type, QNodeId subjectId)
106 : d_ptr(new QSceneChangePrivate)
107{
108 d_ptr->q_ptr = this;
109 Q_D(QSceneChange);
110 d->m_type = type;
111 d->m_subjectId = subjectId;
112}
113
114/*! \internal */
115QSceneChange::QSceneChange(QSceneChangePrivate &dd,
116 ChangeFlag type, QNodeId subjectId)
117 : d_ptr(&dd)
118{
119 d_ptr->q_ptr = this;
120 Q_D(QSceneChange);
121 d->m_type = type;
122 d->m_subjectId = subjectId;
123}
124
125QSceneChange::~QSceneChange()
126{
127 delete d_ptr;
128}
129
130/*!
131 * Returns the scene change type.
132 */
133ChangeFlag QSceneChange::type() const Q_DECL_NOTHROW
134{
135 Q_D(const QSceneChange);
136 return d->m_type;
137}
138
139/*!
140 Sets the delivery flags of the change to \a flags.
141 */
142void QSceneChange::setDeliveryFlags(DeliveryFlags flags) Q_DECL_NOTHROW
143{
144 Q_D(QSceneChange);
145 d->m_deliveryFlags = flags;
146}
147
148/*!
149 Returns the set delivery flags.
150 */
151QSceneChange::DeliveryFlags QSceneChange::deliveryFlags() const Q_DECL_NOTHROW
152{
153 Q_D(const QSceneChange);
154 return d->m_deliveryFlags;
155}
156
157/*!
158 * \return scene change subject id.
159 */
160QNodeId QSceneChange::subjectId() const Q_DECL_NOTHROW
161{
162 Q_D(const QSceneChange);
163 return d->m_subjectId;
164}
165
166} // Qt3D
167
168QT_END_NAMESPACE
169