1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qbackendnode.h"
5#include "qbackendnode_p.h"
6
7#include <Qt3DCore/qaspectengine.h>
8#include <Qt3DCore/qnode.h>
9
10#include <Qt3DCore/private/corelogging_p.h>
11
12QT_BEGIN_NAMESPACE
13
14namespace Qt3DCore {
15
16/*! \internal */
17QBackendNodeMapper::~QBackendNodeMapper()
18{
19}
20
21QBackendNodePrivate::QBackendNodePrivate(QBackendNode::Mode mode)
22 : q_ptr(nullptr)
23 , m_mode(mode)
24 , m_enabled(false)
25{
26}
27
28QBackendNodePrivate::~QBackendNodePrivate() = default;
29
30void QBackendNodePrivate::setEnabled(bool enabled)
31{
32 m_enabled = enabled;
33}
34
35QBackendNodePrivate *QBackendNodePrivate::get(QBackendNode *n)
36{
37 return n->d_func();
38}
39
40void QBackendNodePrivate::addedToEntity(QNode *frontend)
41{
42 Q_UNUSED(frontend);
43}
44
45void QBackendNodePrivate::removedFromEntity(QNode *frontend)
46{
47 Q_UNUSED(frontend);
48}
49
50void QBackendNodePrivate::componentAdded(QNode *frontend)
51{
52 Q_UNUSED(frontend);
53}
54
55void QBackendNodePrivate::componentRemoved(QNode *frontend)
56{
57 Q_UNUSED(frontend);
58}
59
60/*!
61 * \class Qt3DCore::QBackendNodeMapper
62 * \inheaderfile Qt3DCore/QBackendNodeMapper
63 * \inmodule Qt3DCore
64 *
65 * \brief Creates and maps backend nodes to their respective frontend nodes.
66 */
67
68/*!
69 * \fn Qt3DCore::QBackendNode *Qt3DCore::QBackendNodeMapper::create(Qt3DCore::QNodeId id) const
70 *
71 * \TODO
72 *
73 * \a id
74 *
75 * \return created node.
76 */
77
78/*!
79 * \fn Qt3DCore::QBackendNode * Qt3DCore::QBackendNodeMapper::get(Qt3DCore::QNodeId id) const
80 *
81 * \return backend node for the given node \a id.
82 */
83
84/*!
85 * \fn void Qt3DCore::QBackendNodeMapper::destroy(Qt3DCore::QNodeId id) const
86 *
87 * Destroys the backend node for the given node \a id.
88 */
89
90/*!
91 * \class Qt3DCore::QBackendNode
92 * \inheaderfile Qt3DCore/QBackendNode
93 * \inmodule Qt3DCore
94 *
95 * \brief The base class for all Qt3D backend nodes.
96 */
97
98/*!
99 * \enum Qt3DCore::QBackendNode::Mode
100 *
101 * The mode for the backend node.
102 *
103 * \value ReadOnly
104 * \value ReadWrite
105 */
106
107QBackendNode::QBackendNode(QBackendNode::Mode mode)
108 : d_ptr(new QBackendNodePrivate(mode))
109{
110 d_ptr->q_ptr = this;
111}
112
113QBackendNode::~QBackendNode()
114{
115 delete d_ptr;
116}
117
118/*!
119 * Sets the peer \a id.
120 */
121void QBackendNode::setPeerId(QNodeId id) noexcept
122{
123 Q_D(QBackendNode);
124 d->m_peerId = id;
125}
126
127/*!
128 * \return the peer id of the backend node.
129 */
130QNodeId QBackendNode::peerId() const noexcept
131{
132 Q_D(const QBackendNode);
133 return d->m_peerId;
134}
135
136/*!
137 * \return \c true if the backend node is enabled.
138 */
139bool QBackendNode::isEnabled() const noexcept
140{
141 Q_D(const QBackendNode);
142 return d->m_enabled;
143}
144
145/*!
146 * \return the mode of the backend mode.
147 */
148QBackendNode::Mode QBackendNode::mode() const noexcept
149{
150 Q_D(const QBackendNode);
151 return d->m_mode;
152}
153
154/*!
155 * \brief QBackendNode::syncFromFrontEnd
156 * \param frontEnd
157 * \param firstTime
158 *
159 * This is called by the aspect when a \a frontEnd node needs to synchronize it's changes
160 * with the backend (normally due to property changes).
161 *
162 * \a firstTime will be true if the backend node was just created
163 */
164void QBackendNode::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
165{
166 Q_UNUSED(frontEnd);
167 Q_UNUSED(firstTime);
168}
169
170/*!
171 * \internal
172 */
173QBackendNode::QBackendNode(QBackendNodePrivate &dd)
174 : d_ptr(&dd)
175{
176 d_ptr->q_ptr = this;
177}
178
179/*!
180 * Enables or disables the backend node by \a enabled.
181 */
182void QBackendNode::setEnabled(bool enabled) noexcept
183{
184 Q_D(QBackendNode);
185 d->m_enabled = enabled;
186}
187
188} // Qt3D
189
190QT_END_NAMESPACE
191

source code of qt3d/src/core/nodes/qbackendnode.cpp