Data Shard Plugin
Loading...
Searching...
No Matches
DataShardSubsystem Class Reference

DataShardSubsystem manages the creation, access, and lifecycle of DataShards.
DataShards are a flexible data-sharing system that allows game objects to store and access type-safe data throughout the game. More...

#include <DataShardSubsystem.h>

Inherits UGameInstanceSubsystem.

Public Member Functions

virtual void Initialize (FSubsystemCollectionBase &Collection) override
 
virtual void Deinitialize () override
 
bool CreateShard (const FDataShardKey &Key, const FProperty *InProperty, const void *InData=nullptr)
 
bool CreateShard (const FDataShardKey &Key, const UObject *Container, const FName &PropertyName)
 
bool GetShardData (const FDataShardKey &Key, const void *&OutData) const
 
template<typename T>
const T * GetShardData (const FDataShardKey &Key, const bool bCheck=false) const
 
template<typename T>
const T * GetShardData (const int32 &ID, const bool bCheck=false) const
 
template<typename T>
TSharedPtr< const T > GetShardDataCopy (const FDataShardKey &Key, const bool bCheck=false) const
 
template<typename T>
TSharedPtr< const T > GetShardDataCopy (const int32 &ID, const bool bCheck=false) const
 
bool SetShardData (const FDataShardKey &Key, const void *InData, const FProperty *InProperty) const
 
bool SetShardData (const FDataShardKey &Key, const UObject *Container, const FName &PropertyName) const
 
bool RemoveKey (const FDataShardKey &Key)
 
bool CreateBoundKey (const FDataShardKey &Parent, const FDataShardKey &KeyInfo, FDataShardKey &OutKey)
 
FDataShardKey CreateBoundKey (const FDataShardKey &Parent, const FDataShardKey &KeyInfo)
 
bool IsKeyValid (const FDataShardKey &Key) const
 
void BindEventOnKeyAdded (const FOnKeyChange &Delegate)
 
void UnbindEventOnKeyAdded (const FOnKeyChange &Delegate)
 
void UnbindAllEventsOnKeyAdded (const UObject *Object)
 
void BindEventOnKeyRemoved (const FOnKeyChange &Delegate)
 
void UnbindEventOnKeyRemoved (const FOnKeyChange &Delegate)
 
void UnbindAllEventsOnKeyRemoved (const UObject *Object)
 
void BindEventOnShardAdded (const FOnShardChange &Delegate)
 
void UnbindEventOnShardAdded (const FOnShardChange &Delegate)
 
void UnbindAllEventsOnShardAdded (const UObject *Object)
 
void BindEventOnShardRemoved (const FOnShardChange &Delegate)
 
void UnbindEventOnShardRemoved (const FOnShardChange &Delegate)
 
void UnbindAllEventsOnShardRemoved (const UObject *Object)
 
void BindEventOnDataChange (const FDataShardKey &Key, const FOnShardDataChange &Delegate)
 
void BindEventOnDataChange (const int32 &ID, const FOnShardDataChange_internal &Delegate)
 
void UnbindEventOnDataChange (const FDataShardKey &Key, const FOnShardDataChange &Delegate)
 
void UnbindEventOnDataChange (const int32 &ID, const FOnShardDataChange_internal &Delegate)
 
void UnbindAllEventsOnDataChange (const FDataShardKey &Key)
 
void UnbindAllEventsOnDataChange (const int32 &ID)
 
void UnbindAllEventsOnDataChange (const UObject *Object)
 
const FFieldClass * GetFieldClassFromShard (const FDataShardKey &Key) const
 
FString GetObjectPropertyClassNameFromShard (const FDataShardKey &Key) const
 
bool IsDataShardSameType (const FDataShardKey &Key, const FProperty *InProperty) const
 
bool IsShardTypeOf (const FDataShardKey &Key, const FFieldClass *InClass) const
 
bool IsShardTypeChildOf (const FDataShardKey &Key, const FFieldClass *InClass) const
 
void GetShardDump (FString &Out) const
 
void GetShardStringDump (FString &Out) const
 
void GetKeyDump (FString &Out) const
 
void GetRefDump (FString &Out) const
 
void GetShardIDsForObject (const UObject *InObject, TArray< int32 > &OutArray) const
 
int32 GetPoolSize () const
 
int32 GetActiveShardCount () const
 
int32 GetAvailableShardCount () const
 
FString GetDebugDataForShard (const int32 &InID) const
 
FString GetDebugDataForShard (const FDataShardKey &InKey) const
 
FString GetDebugDataForObject (const UObject *InObject) const
 

Detailed Description

DataShardSubsystem manages the creation, access, and lifecycle of DataShards.
DataShards are a flexible data-sharing system that allows game objects to store and access type-safe data throughout the game.

The subsystem provides:

  • Creation and management of typed data containers (DataShardObject)
  • Key-based access to data with owner object association
  • Reference counting for automatic cleanup
  • Event notification when data changes
  • Type safety and validation

    This subsystem acts as the central manager for all DataShard operations and should be accessed through the DataShardUtils_BP utility functions in most cases, rather than directly.

Member Function Documentation

◆ Deinitialize()

virtual void DataShardSubsystem::Deinitialize ( )
overridevirtual

◆ GetFieldClassFromShard()

const FFieldClass * DataShardSubsystem::GetFieldClassFromShard ( const FDataShardKey & Key) const

Retrieves the FFieldClass of the property stored in a shard Useful for runtime type checking and reflection

Parameters
Key- The key of the shard to query
Returns
The FFieldClass of the property, or nullptr if the key is invalid

◆ GetObjectPropertyClassNameFromShard()

FString DataShardSubsystem::GetObjectPropertyClassNameFromShard ( const FDataShardKey & Key) const

Retrieves the ObjectProperty class name if the shard is a FObjectProperty

Parameters
KeyThe key of the shard to query
Returns
The PropertyClass name, if the property inside the shard is a FObjectProperty

◆ Initialize()

virtual void DataShardSubsystem::Initialize ( FSubsystemCollectionBase & Collection)
overridevirtual

◆ IsDataShardSameType()

bool DataShardSubsystem::IsDataShardSameType ( const FDataShardKey & Key,
const FProperty * InProperty ) const

Checks if a shard's property is the same type of the specified property

Parameters
Key- The key of the shard to query
InPropertyThe property to compare against
Returns
true if the shard's property is the same type

◆ IsKeyValid()

bool DataShardSubsystem::IsKeyValid ( const FDataShardKey & Key) const

Checks if a key exists in the subsystem and points to a valid shard

Parameters
Key- The key to check
Returns
true if the key exists and points to a valid shard, false otherwise

◆ IsShardTypeChildOf()

bool DataShardSubsystem::IsShardTypeChildOf ( const FDataShardKey & Key,
const FFieldClass * InClass ) const

Checks if a shard's property is of a type derived from the specified field class

Parameters
Key- The key of the shard to check
InClass- The field class to check inheritance from
Returns
true if the shard's property class is a child of the specified class, false otherwise

◆ IsShardTypeOf()

bool DataShardSubsystem::IsShardTypeOf ( const FDataShardKey & Key,
const FFieldClass * InClass ) const

Checks if a shard's property is exactly of the specified field class type

Parameters
Key- The key of the shard to check
InClass- The field class to compare against
Returns
true if the shard's property class matches the specified class exactly, false otherwise