1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
4 | ** Contact: http://www.qt-project.org/legal |
5 | ** |
6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
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 http://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free |
28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
29 | ** the packaging of this file. Please review the following information to |
30 | ** ensure the GNU General Public License version 2.0 requirements will be |
31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
32 | ** |
33 | ** $QT_END_LICENSE$ |
34 | ** |
35 | ****************************************************************************/ |
36 | |
37 | #include "qnodecommand.h" |
38 | #include "qnodecommand_p.h" |
39 | #include <Qt3DCore/qnode.h> |
40 | #include <Qt3DCore/private/qnode_p.h> |
41 | |
42 | QT_BEGIN_NAMESPACE |
43 | |
44 | namespace Qt3DCore { |
45 | |
46 | QNodeCommandPrivate::QNodeCommandPrivate() |
47 | : QSceneChangePrivate() |
48 | , m_commandId(createId()) |
49 | , m_replyToCommandId() |
50 | { |
51 | } |
52 | |
53 | QNodeCommandPrivate::~QNodeCommandPrivate() |
54 | { |
55 | } |
56 | |
57 | QNodeCommand::CommandId QNodeCommandPrivate::createId() |
58 | { |
59 | static QBasicAtomicInteger<QNodeCommand::CommandId> next = Q_BASIC_ATOMIC_INITIALIZER(0); |
60 | return next.fetchAndAddRelaxed(valueToAdd: 1) + 1; |
61 | } |
62 | |
63 | /*! |
64 | * \class Qt3DCore::QNodeCommand |
65 | * \inheaderfile Qt3DCore/QNodeCommand |
66 | * \inherits Qt3DCore::QSceneChange |
67 | * \inmodule Qt3DCore |
68 | * \since 5.10 |
69 | * \brief The QNodeCommand class is the base class for all CommandRequested QSceneChange events. |
70 | * |
71 | * The QNodeCommand class is the base class for all QSceneChange events that |
72 | * have the changeType() CommandRequested. |
73 | * |
74 | * You can subclass this to create your own node update types for communication between |
75 | * your QNode and QBackendNode subclasses when writing your own aspects. |
76 | */ |
77 | |
78 | /*! |
79 | * \typedef Qt3DCore::QNodeCommandPtr |
80 | * \relates Qt3DCore::QNodeCommand |
81 | * |
82 | * A shared pointer for QNodeCommand. |
83 | */ |
84 | |
85 | /*! |
86 | * \typedef QNodeCommand::CommandId |
87 | * |
88 | * Type of the command id, defined either as quint64 or quint32 |
89 | * depending on the platform support. |
90 | */ |
91 | |
92 | /*! |
93 | * Constructs a new QNodeCommand with \a id. |
94 | */ |
95 | QNodeCommand::QNodeCommand(QNodeId id) |
96 | : QSceneChange(*new QNodeCommandPrivate(), CommandRequested, id) |
97 | { |
98 | } |
99 | |
100 | QNodeCommand::QNodeCommand(QNodeCommandPrivate &dd, QNodeId id) |
101 | : QSceneChange(dd, CommandRequested, id) |
102 | { |
103 | } |
104 | |
105 | QNodeCommand::~QNodeCommand() |
106 | { |
107 | } |
108 | |
109 | /*! |
110 | * \return commandId. |
111 | */ |
112 | QNodeCommand::CommandId QNodeCommand::commandId() const |
113 | { |
114 | Q_D(const QNodeCommand); |
115 | return d->m_commandId; |
116 | } |
117 | |
118 | /*! |
119 | * \return name. |
120 | */ |
121 | QString QNodeCommand::name() const |
122 | { |
123 | Q_D(const QNodeCommand); |
124 | return d->m_name; |
125 | } |
126 | |
127 | void QNodeCommand::setName(const QString &name) |
128 | { |
129 | Q_D(QNodeCommand); |
130 | d->m_name = name; |
131 | } |
132 | |
133 | /*! |
134 | * \return data. |
135 | */ |
136 | QVariant QNodeCommand::data() const |
137 | { |
138 | Q_D(const QNodeCommand); |
139 | return d->m_data; |
140 | } |
141 | |
142 | void QNodeCommand::setData(const QVariant &data) |
143 | { |
144 | Q_D(QNodeCommand); |
145 | d->m_data = data; |
146 | } |
147 | |
148 | QNodeCommand::CommandId QNodeCommand::inReplyTo() const |
149 | { |
150 | Q_D(const QNodeCommand); |
151 | return d->m_replyToCommandId; |
152 | } |
153 | |
154 | void QNodeCommand::setReplyToCommandId(QNodeCommand::CommandId id) |
155 | { |
156 | Q_D(QNodeCommand); |
157 | d->m_replyToCommandId = id; |
158 | } |
159 | |
160 | } // namespace Qt3DCore |
161 | |
162 | QT_END_NAMESPACE |
163 | |