Files
UnrealEngineUWP/Engine/Source/Runtime/InteractiveToolsFramework/Private/ContextObjectStore.cpp
zach rammell 650a416c54 ITF Context Object Stores search through parent stores in all Find implementations
#jira none
#rb ryan.schmidt brooke.hubert
#preflight 62bb2b47112bbc898ad479b2

[CL 20861054 by zach rammell in ue5-main branch]
2022-06-28 12:43:51 -04:00

50 lines
1.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ContextObjectStore.h"
UObject* UContextObjectStore::FindContextByClass(UClass* InClass) const
{
for (UObject* ContextObject : ContextObjects)
{
if (ContextObject && ContextObject->IsA(InClass))
{
return ContextObject;
}
}
if (UContextObjectStore* ParentStore = Cast<UContextObjectStore>(GetOuter()))
{
return ParentStore->FindContextByClass(InClass);
}
return nullptr;
}
bool UContextObjectStore::AddContextObject(UObject* InContextObject)
{
if (InContextObject)
{
return ContextObjects.AddUnique(InContextObject) != INDEX_NONE;
}
return false;
}
bool UContextObjectStore::RemoveContextObject(UObject* InContextObject)
{
return ContextObjects.RemoveSingle(InContextObject) != 0;
}
bool UContextObjectStore::RemoveContextObjectsOfType(const UClass* InClass)
{
return (ContextObjects.RemoveAll([InClass](UObject* InObject)
{
return InObject->IsA(InClass);
}) > 0);
}
void UContextObjectStore::Shutdown()
{
ContextObjects.Empty();
}