1// Copyright (C) 2015 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 "handler_p.h"
5
6#include <Qt3DCore/qnode.h>
7
8#include <Qt3DLogic/private/manager_p.h>
9#include <Qt3DLogic/private/managers_p.h>
10
11QT_BEGIN_NAMESPACE
12
13namespace Qt3DLogic {
14namespace Logic {
15
16Handler::Handler()
17 : m_logicManager(nullptr)
18{
19}
20
21void Handler::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
22{
23 Q_UNUSED(frontEnd);
24 if (firstTime)
25 m_logicManager->appendHandler(handler: this);
26}
27
28HandlerFunctor::HandlerFunctor(Manager *manager)
29 : m_manager(manager)
30{
31}
32
33Qt3DCore::QBackendNode *HandlerFunctor::create(Qt3DCore::QNodeId id) const
34{
35 Handler *handler = m_manager->logicHandlerManager()->getOrCreateResource(id);
36 handler->setManager(m_manager);
37 return handler;
38}
39
40Qt3DCore::QBackendNode *HandlerFunctor::get(Qt3DCore::QNodeId id) const
41{
42 return m_manager->logicHandlerManager()->lookupResource(id);
43}
44
45void HandlerFunctor::destroy(Qt3DCore::QNodeId id) const
46{
47 m_manager->removeHandler(id);
48}
49
50} // namespace Logic
51} // namespace Qt3DLogic
52
53QT_END_NAMESPACE
54

source code of qt3d/src/logic/handler.cpp