Files
UnrealEngineUWP/Engine/Source/Runtime/MovieScene/Private/EntitySystem/MovieSceneComponentAccessors.cpp
Andrew Rodham e48f8100c8 Sequencer: Tidied up component locking and access patterns
- Client code ultilizing ForEachAllocation task callbacks no longer need to call Resolve to access component data - this is already done in the task internals and the lock is maintained correctly for the duration of the task
  - Added Read/WriteComponent methods to FEntityAllocation to make custom component access more robust - these functions now return a scope-locked wrapper around the component data

#rb Max.Chen, Ludovic.Chabant

[CL 15144976 by Andrew Rodham in ue5-main branch]
2021-01-20 11:40:24 -04:00

58 lines
2.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "EntitySystem/MovieSceneComponentAccessors.h"
#include "EntitySystem/MovieSceneComponentRegistry.h"
#include "EntitySystem/MovieSceneEntityManager.h"
namespace UE
{
namespace MovieScene
{
#if UE_MOVIESCENE_ENTITY_DEBUG
void AccessorToString(const FReadAccess* In, FEntityManager* EntityManager, FString& OutString)
{
const FComponentTypeInfo& ComponentTypeInfo = EntityManager->GetComponents()->GetComponentTypeChecked(In->ComponentType);
OutString += FString::Printf(TEXT("\n\tRead: %s %s"), *ComponentTypeInfo.DebugInfo->DebugName, ComponentTypeInfo.DebugInfo->DebugTypeName);
}
void AccessorToString(const FWriteAccess* In, FEntityManager* EntityManager, FString& OutString)
{
const FComponentTypeInfo& ComponentTypeInfo = EntityManager->GetComponents()->GetComponentTypeChecked(In->ComponentType);
OutString += FString::Printf(TEXT("\n\tWrite: %s %s"), *ComponentTypeInfo.DebugInfo->DebugName, ComponentTypeInfo.DebugInfo->DebugTypeName);
}
void AccessorToString(const FOptionalReadAccess* In, FEntityManager* EntityManager, FString& OutString)
{
if (In->ComponentType)
{
const FComponentTypeInfo& ComponentTypeInfo = EntityManager->GetComponents()->GetComponentTypeChecked(In->ComponentType);
OutString += FString::Printf(TEXT("\n\tRead (Optional): %s %s"), *ComponentTypeInfo.DebugInfo->DebugName, ComponentTypeInfo.DebugInfo->DebugTypeName);
}
}
void AccessorToString(const FOptionalWriteAccess* In, FEntityManager* EntityManager, FString& OutString)
{
if (In->ComponentType)
{
const FComponentTypeInfo& ComponentTypeInfo = EntityManager->GetComponents()->GetComponentTypeChecked(In->ComponentType);
OutString += FString::Printf(TEXT("\n\tWrite (Optional): %s %s"), *ComponentTypeInfo.DebugInfo->DebugName, ComponentTypeInfo.DebugInfo->DebugTypeName);
}
}
void AccessorToString(const FEntityIDAccess*, FEntityManager* EntityManager, FString& OutString)
{
OutString += TEXT("\n\tRead: Entity IDs");
}
void OneOfAccessorToString(const FOptionalReadAccess* In, FEntityManager* EntityManager, FString& OutString)
{
if (In->ComponentType)
{
const FComponentTypeInfo& ComponentTypeInfo = EntityManager->GetComponents()->GetComponentTypeChecked(In->ComponentType);
OutString = FString::Printf(TEXT("%s %s"), *ComponentTypeInfo.DebugInfo->DebugName, ComponentTypeInfo.DebugInfo->DebugTypeName);
}
}
#endif // UE_MOVIESCENE_ENTITY_DEBUG
} // namespace MovieScene
} // namespace UE