UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ContextObjectStore.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 "Templates/Casts.h"
7#include "UObject/Object.h"
9#include "UObject/ObjectPtr.h"
11
12#include "ContextObjectStore.generated.h"
13
14class UClass;
15
23UCLASS(Transient, MinimalAPI)
25{
27
28public:
33 template <typename TObjectType>
35 {
36 for (UObject* ContextObject : ContextObjects)
37 {
38 if (TObjectType* CastedObject = Cast<TObjectType>(ContextObject))
39 {
40 return CastedObject;
41 }
42 }
43
45 {
46 return ParentStore->FindContext<TObjectType>();
47 }
48
49 return nullptr;
50 }
51
56 INTERACTIVETOOLSFRAMEWORK_API UObject* FindContextByClass(UClass* InClass) const;
57
63
68 INTERACTIVETOOLSFRAMEWORK_API bool RemoveContextObject(UObject* InContextObject);
69
74 INTERACTIVETOOLSFRAMEWORK_API bool RemoveContextObjectsOfType(const UClass* InClass);
75
76 template <class TObjectType>
78 {
79 return RemoveContextObjectsOfType(TObjectType::StaticClass());
80 }
81
86
87protected:
88 UPROPERTY()
89 TArray<TObjectPtr<UObject>> ContextObjects;
90};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
Definition Array.h:670
Definition Class.h:3793
Definition ContextObjectStore.h:25
TObjectType * FindContext() const
Definition ContextObjectStore.h:34
bool RemoveContextObjectsOfType()
Definition ContextObjectStore.h:77
FORCEINLINE UObject * GetOuter() const
Definition UObjectBase.h:223
Definition Object.h:95
Definition ObjectPtr.h:488