-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeGraphModule.cpp
More file actions
107 lines (91 loc) · 3.51 KB
/
Copy pathNodeGraphModule.cpp
File metadata and controls
107 lines (91 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* @file NodeGraphModule.cpp
* @brief Module entry point for the deki-nodegraph DLL.
*
* deki-nodegraph owns the whole node-graph feature: the runtime container
* (NodeGraphData) and factory that every platform needs, plus the editor-side
* registries, document, undo commands and the generic Node Graph window.
*
* It declares no node types and no components of its own. Node types and graph
* domains come from the modules and project DLLs that consume it (deki-fsm's
* states and actions, a game's own nodes) via DEKI_NODE / the registration
* macros in DekiNode.h.
*/
#include "interop/DekiPlugin.h"
#include "deki-nodegraph/DekiNode.h"
#include "DekiLogSystem.h"
#ifdef DEKI_EDITOR
// Auto-generated registration helpers (no components, but the codegen always
// emits the trio so the plugin interface below has something to call).
extern void DekiNodeGraph_RegisterComponents();
extern int DekiNodeGraph_GetAutoComponentCount();
extern const DekiComponentMeta* DekiNodeGraph_GetAutoComponentMeta(int index);
#endif
static bool s_NodeGraphRegistered = false;
extern "C" {
DEKI_NODEGRAPH_API int DekiNodeGraph_EnsureRegistered(void)
{
#ifdef DEKI_EDITOR
if (s_NodeGraphRegistered) return DekiNodeGraph_GetAutoComponentCount();
s_NodeGraphRegistered = true;
DekiNodeGraph_RegisterComponents();
return DekiNodeGraph_GetAutoComponentCount();
#else
return 0;
#endif
}
DEKI_PLUGIN_API const char* DekiPlugin_GetName(void) { return "Deki Node Graph Module"; }
DEKI_PLUGIN_API const char* DekiPlugin_GetVersion(void)
{
#ifdef DEKI_MODULE_VERSION
return DEKI_MODULE_VERSION;
#else
return "0.0.0-dev";
#endif
}
DEKI_PLUGIN_API const char* DekiPlugin_GetReflectionJson(void) { return "{}"; }
DEKI_PLUGIN_API int DekiPlugin_Init(void) { return 0; }
DEKI_PLUGIN_API void DekiPlugin_Shutdown(void) { s_NodeGraphRegistered = false; }
#ifdef DEKI_EDITOR
DEKI_PLUGIN_API int DekiPlugin_GetComponentCount(void)
{
return DekiNodeGraph_GetAutoComponentCount();
}
DEKI_PLUGIN_API const DekiComponentMeta* DekiPlugin_GetComponentMeta(int index)
{
return DekiNodeGraph_GetAutoComponentMeta(index);
}
#else
DEKI_PLUGIN_API int DekiPlugin_GetComponentCount(void) { return 0; }
DEKI_PLUGIN_API const DekiComponentMeta* DekiPlugin_GetComponentMeta(int) { return nullptr; }
#endif
DEKI_PLUGIN_API void DekiPlugin_RegisterComponents(void)
{
DekiNodeGraph_EnsureRegistered();
}
#ifdef DEKI_EDITOR
/**
* @brief Drop every registered node type, factory thunk and graph domain.
*
* The editor calls this on each loaded module before it unloads plugin or
* module DLLs: the registries hold meta and thunk pointers INTO those DLLs,
* and reading them after FreeLibrary is a crash. Owning the wipe here is what
* keeps the editor free of node-graph knowledge — it just asks every module to
* clean up after itself.
*
* Consumers repopulate on the way back up: full reloads rerun their static
* registrars, plugin-only reloads go through DekiPlugin_RegisterComponents
* (see deki-fsm's DekiFsm_RegisterGraphTypes).
*/
DEKI_PLUGIN_API void DekiPlugin_ClearRegistries(void)
{
PrefabFormat::NodeFactory::Instance().Clear();
NodeTypeRegistry::Instance().Clear();
NodeGraphDomainRegistry::Instance().Clear();
}
#endif
DEKI_PLUGIN_API int DekiPlugin_GetFeatureCount(void) { return 0; }
DEKI_PLUGIN_API const struct DekiModuleFeatureInfo* DekiPlugin_GetFeature(int) { return nullptr; }
// Infrastructure module — no systems to install into the engine at load.
DEKI_PLUGIN_API void DekiPlugin_RegisterModules(void) {}
} // extern "C"