UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InterchangeBaseNodeContainer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "Containers/Map.h"
8#include "CoreMinimal.h"
9#include "HAL/Platform.h"
10#include "Misc/FileHelper.h"
12#include "Templates/Casts.h"
13#include "Templates/Function.h"
14#include "Templates/UniquePtr.h"
15#include "UObject/Class.h"
16#include "UObject/Object.h"
19
20#include "InterchangeBaseNodeContainer.generated.h"
21
22class FArchive;
23class UClass;
26struct FFrame;
27template <typename T> struct TObjectPtr;
28
29
37 UCLASS(BlueprintType, MinimalAPI)
39{
41public:
43
47 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
49 {
50 Nodes.Reset();
51 ChildrenCache.Reset();
52 }
53
57 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
58 void RemoveNode(const FString& NodeUniqueID)
59 {
60 Nodes.Remove(NodeUniqueID);
61 }
62
70 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
71 INTERCHANGECORE_API FString AddNode(UInterchangeBaseNode* Node);
72
73 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
74 INTERCHANGECORE_API void ReplaceNode(const FString& NodeUniqueID, UInterchangeFactoryBaseNode* NewNode);
75
77 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
78 INTERCHANGECORE_API bool IsNodeUidValid(const FString& NodeUniqueID) const;
79
91 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
92 INTERCHANGECORE_API void SetNamespace(const FString& Namespace, UClass* TargetClass);
93
95 INTERCHANGECORE_API void IterateNodes(TFunctionRef<void(const FString&, UInterchangeBaseNode*)> IterationLambda) const;
96
98 void IterateNodesOfType(TFunctionRef<void(const FString&, T*)> IterationLambda) const
99 {
100 for (const TPair<FString, TObjectPtr<UInterchangeBaseNode>>& NodeKeyValue : Nodes)
101 {
102 if (T* Node = Cast<T>(NodeKeyValue.Value))
103 {
104 IterationLambda(NodeKeyValue.Key, Node);
105 }
106 }
107 }
108
109 template <typename T>
111 {
112 for (const TPair<FString, TObjectPtr<UInterchangeBaseNode>>& NodeKeyValue : Nodes)
113 {
114 if (T* Node = Cast<T>(NodeKeyValue.Value))
115 {
116 OutNodeUIDs.Add(NodeKeyValue.Key);
117 }
118 }
119 }
120
125 void IterateNodeChildren(const FString& NodeUniqueID, TFunctionRef<void(const UInterchangeBaseNode*)> IterationLambda) const
126 {
127
128 if (const UInterchangeBaseNode* Node = GetNode(NodeUniqueID))
129 {
130 IterationLambda(Node);
131 const TArray<FString> ChildrenIds = GetNodeChildrenUids(NodeUniqueID);
132 for (int32 ChildIndex = 0; ChildIndex < ChildrenIds.Num(); ++ChildIndex)
133 {
134 IterateNodeChildren(ChildrenIds[ChildIndex], IterationLambda);
135 }
136 }
137 }
138
145 bool BreakableIterateNodeChildren(const FString& NodeUniqueID, TFunctionRef<bool(const UInterchangeBaseNode*)> IterationLambda) const
146 {
147 if (const UInterchangeBaseNode* Node = GetNode(NodeUniqueID))
148 {
149 if (IterationLambda(Node))
150 {
151 return true;
152 }
153 const TArray<FString> ChildrenIds = GetNodeChildrenUids(NodeUniqueID);
154 for (int32 ChildIndex = 0; ChildIndex < ChildrenIds.Num(); ++ChildIndex)
155 {
156 if (BreakableIterateNodeChildren(ChildrenIds[ChildIndex], IterationLambda))
157 {
158 return true;
159 }
160 }
161 }
162 return false;
163 }
164
166 INTERCHANGECORE_API void BreakableIterateNodes(TFunctionRef<bool(const FString&, UInterchangeBaseNode*)> IterationLambda) const;
167
168 template <typename T>
169 void BreakableIterateNodesOfType(TFunctionRef<bool(const FString&, T*)> IterationLambda) const
170 {
171 for (const TPair<FString, TObjectPtr<UInterchangeBaseNode>>& NodeKeyValue : Nodes)
172 {
173 if (T* Node = Cast<T>(NodeKeyValue.Value))
174 {
175 if (IterationLambda(NodeKeyValue.Key, Node))
176 {
177 break;
178 }
179 }
180 }
181 }
182
184 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
185 INTERCHANGECORE_API void GetRoots(TArray<FString>& RootNodes) const;
186
188 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
189 INTERCHANGECORE_API void GetNodes(const UClass* ClassNode, TArray<FString>& OutNodes) const;
190
192 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
193 INTERCHANGECORE_API const UInterchangeBaseNode* GetNode(const FString& NodeUniqueID) const;
194
196 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
197 INTERCHANGECORE_API UInterchangeFactoryBaseNode* GetFactoryNode(const FString& NodeUniqueID) const;
198
200 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
201 INTERCHANGECORE_API bool SetNodeParentUid(const FString& NodeUniqueID, const FString& NewParentNodeUid);
202
203 /* Remove the node's ParentUid, making it into a top-level node */
204 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
205 INTERCHANGECORE_API bool ClearNodeParentUid(const FString& NodeUniqueID);
206
208 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
209 INTERCHANGECORE_API bool SetNodeDesiredChildIndex(const FString& NodeUniqueID, const int32& NewNodeDesiredChildIndex);
210
212 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
213 INTERCHANGECORE_API int32 GetNodeChildrenCount(const FString& NodeUniqueID) const;
214
216 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
217 INTERCHANGECORE_API TArray<FString> GetNodeChildrenUids(const FString& NodeUniqueID) const;
218
219 INTERCHANGECORE_API TArray<FString>* GetCachedNodeChildrenUids(const FString& NodeUniqueID) const;
220
222 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
223 INTERCHANGECORE_API UInterchangeBaseNode* GetNodeChildren(const FString& NodeUniqueID, int32 ChildIndex);
224
226 INTERCHANGECORE_API const UInterchangeBaseNode* GetNodeChildren(const FString& NodeUniqueID, int32 ChildIndex) const;
227
233 INTERCHANGECORE_API void SerializeNodeContainerData(FArchive& Ar);
234
235 /* Serialize the node container into the specified file. */
236 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
237 INTERCHANGECORE_API void SaveToFile(const FString& Filename);
238
239 /* Serialize the node container from the specified file. */
240 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
241 INTERCHANGECORE_API void LoadFromFile(const FString& Filename);
242
243 /* Fill the cache of children UIDs to optimize the GetNodeChildrenUids call. */
244 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
245 INTERCHANGECORE_API void ComputeChildrenCache();
246
247 /* Sets the children cache from an incoming data set. */
248 INTERCHANGECORE_API void SetChildrenCache(const TMap<FString, TArray<FString>>& InChildrenCache);
249
250 /* Gets the children cache. */
251 INTERCHANGECORE_API TMap<FString, TArray<FString>>& GetChildrenCache();
252
253 /* Reset the cache of children UIDs. */
254 UFUNCTION(BlueprintCallable, Category = "Interchange | Node Container")
255 void ResetChildrenCache()
256 {
257 ChildrenCache.Reset();
258 }
259
263 UFUNCTION(BlueprintCallable, Category = "Interchange | Node")
264 INTERCHANGECORE_API bool GetIsAncestor(const FString& NodeUniqueID, const FString& AncestorUID) const;
265
266 INTERCHANGECORE_API void SetupNode(UInterchangeBaseNode* Node, const FString& NodeUID,
267 const FString& DisplayLabel, EInterchangeNodeContainerType ContainerType,
268 const FString& ParentNodeUID = TEXT(""));
269
270 INTERCHANGECORE_API void SetupAndReplaceFactoryNode(UInterchangeFactoryBaseNode* Node, const FString& NodeUID,
271 const FString& DisplayLabel, EInterchangeNodeContainerType ContainerType,
272 const FString& OldNodeUID,
273 const FString& ParentNodeUID = TEXT(""));
274
275private:
276
277 void InternalReorderChildren(TArray<FString>& Children) const;
278
279 UInterchangeBaseNode* GetNodeChildrenInternal(const FString& NodeUniqueID, int32 ChildIndex);
280
282 UPROPERTY(VisibleAnywhere, Category = "Interchange | Node Container")
283 TMap<FString, TObjectPtr<UInterchangeBaseNode> > Nodes;
284
285 mutable TMap<FString, TArray<FString> > ChildrenCache;
286};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EInterchangeNodeContainerType
Definition InterchangeBaseNode.h:174
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UCLASS(...)
Definition ObjectMacros.h:776
Definition Archive.h:1208
Definition Array.h:670
void Reset(SizeType NewSize=0)
Definition Array.h:2246
Definition AssetRegistryState.h:50
Definition UnrealString.h.inl:34
Definition Class.h:3793
Definition InterchangeBaseNodeContainer.h:39
void IterateNodeChildren(const FString &NodeUniqueID, TFunctionRef< void(const UInterchangeBaseNode *)> IterationLambda) const
Definition InterchangeBaseNodeContainer.h:125
void BreakableIterateNodesOfType(TFunctionRef< bool(const FString &, T *)> IterationLambda) const
Definition InterchangeBaseNodeContainer.h:169
bool BreakableIterateNodeChildren(const FString &NodeUniqueID, TFunctionRef< bool(const UInterchangeBaseNode *)> IterationLambda) const
Definition InterchangeBaseNodeContainer.h:145
void GetNodeUIDsOfType(TArray< FString > &OutNodeUIDs) const
Definition InterchangeBaseNodeContainer.h:110
Definition InterchangeBaseNode.h:195
Definition InterchangeFactoryBaseNode.h:188
Definition Object.h:95
Definition Stack.h:114
Definition ObjectPtr.h:488
Definition Tuple.h:652