Files
UnrealEngineUWP/Engine/Source/Runtime/Experimental/InteractiveToolsFramework/Private/ContextObjectStore.cpp
brooke hubert 94cf8c06ec Interactive tools context now has a store for arbitrary context objects, which can be accessed via tools for shared data or operations, like typed element actions.
#Jira none
#preflight 6092b7858b751d0001be9bed
#rb semion.piskarev
#fyi ryan.schmidt

[CL 16209160 by brooke hubert in ue5-main branch]
2021-05-05 12:42:29 -04:00

45 lines
894 B
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;
}
}
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();
}