1 | // Copyright (C) 2019 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 | #ifndef QT3DINPUT_INPUT_INPUTBACKENDNODEFUNCTOR_P_H |
4 | #define QT3DINPUT_INPUT_INPUTBACKENDNODEFUNCTOR_P_H |
5 | |
6 | // |
7 | // W A R N I N G |
8 | // ------------- |
9 | // |
10 | // This file is not part of the Qt API. It exists for the convenience |
11 | // of other Qt classes. This header file may change from version to |
12 | // version without notice, or even be removed. |
13 | // |
14 | // We mean it. |
15 | // |
16 | |
17 | #include <Qt3DCore/qbackendnode.h> |
18 | #include <Qt3DCore/qnode.h> |
19 | #include <private/qglobal_p.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | namespace Qt3DInput { |
24 | |
25 | namespace Input { |
26 | |
27 | template<class Backend, class Manager> |
28 | class InputNodeFunctor : public Qt3DCore::QBackendNodeMapper |
29 | { |
30 | public: |
31 | explicit InputNodeFunctor(Manager *manager) |
32 | : m_manager(manager) |
33 | { |
34 | } |
35 | |
36 | Qt3DCore::QBackendNode *create(Qt3DCore::QNodeId id) const final |
37 | { |
38 | Backend *backend = m_manager->getOrCreateResource(id); |
39 | return backend; |
40 | } |
41 | |
42 | Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const final |
43 | { |
44 | return m_manager->lookupResource(id); |
45 | } |
46 | |
47 | void destroy(Qt3DCore::QNodeId id) const final |
48 | { |
49 | m_manager->releaseResource(id); |
50 | } |
51 | |
52 | private: |
53 | Manager *m_manager; |
54 | }; |
55 | |
56 | } // Input |
57 | |
58 | } // Qt3DInput |
59 | |
60 | QT_END_NAMESPACE |
61 | |
62 | #endif // QT3DINPUT_INPUT_INPUTBACKENDNODEFUNCTOR_P_H |
63 | |
64 | |