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 <Qt3DCore/qnodeid.h>
5
6QT_BEGIN_NAMESPACE
7
8namespace Qt3DCore {
9
10/*!
11 * \class Qt3DCore::QNodeId
12 * \inheaderfile Qt3DCore/QNodeId
13 * \inmodule Qt3DCore
14 * \brief Uniquely identifies a QNode.
15 */
16
17/*!
18 * \typedef Qt3DCore::QNodeIdVector
19 * \relates Qt3DCore::QNodeId
20 *
21 * A vector of \l {QNodeId}s.
22 */
23
24/*!
25 * \fn bool Qt3DCore::QNodeId::isNull() const
26 * \return \TODO
27 */
28
29/*!
30 * \fn bool Qt3DCore::QNodeId::operator ==(QNodeId other) const
31 * \return \c true if \c this == \a other.
32 */
33
34/*!
35 * \fn bool Qt3DCore::QNodeId::operator !=(QNodeId other) const
36 * \return \c true if \c this != \a other.
37 */
38
39/*!
40 * \fn bool Qt3DCore::QNodeId::operator <(QNodeId other) const
41 * \return \c true if \c this < \a other.
42 */
43
44/*!
45 * \fn bool Qt3DCore::QNodeId::operator >(QNodeId other) const
46 * \return \c true if \c this > \a other.
47 */
48
49/*!
50 * \fn quint64 Qt3DCore::QNodeId::id() const
51 * \return \TODO
52 */
53
54/*!
55 * \fn Qt3DCore::QNodeId::operator bool() const
56 * Returns \TODO
57 */
58
59/*!
60 * \fn [nodeid-qhash] constexpr size_t Qt3DCore::qHash(QNodeId id, uint seed)
61 * \relates Qt3DCore::QNodeId
62 * \return hash of node with \a id and optional \a seed.
63 */
64
65/*!
66 * \return node id.
67 */
68QNodeId QNodeId::createId() noexcept
69{
70 typedef
71#if defined(Q_ATOMIC_INT64_IS_SUPPORTED)
72 quint64
73#else
74 quint32
75#endif
76 UIntType;
77 static QBasicAtomicInteger<UIntType> next = Q_BASIC_ATOMIC_INITIALIZER(0);
78 return QNodeId(next.fetchAndAddRelaxed(valueToAdd: 1) + 1);
79}
80
81#ifndef QT_NO_DEBUG_STREAM
82/*!
83 * << with \a d and \a id.
84 * \return QDebug.
85 */
86QDebug operator<<(QDebug d, QNodeId id)
87{
88 d << id.id();
89 return d;
90}
91#endif
92
93}
94
95QT_END_NAMESPACE
96

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