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

DataShardObject is the core container class for data in the DataShard system.
This class provides a flexible data storage mechanism that can hold any Unreal property type.
It uses a type-erased byte buffer approach with a property reference to correctly interpret the stored data.
The system maintains these objects in a pool (DataShardPool) for efficient reuse.

Key capabilities: More...

#include <DataShardObject.h>

Inherits UObject.

Public Member Functions

void InitializeShard (const FProperty *InDataType, const int32 &InShardIndex)
 
void Reset ()
 
template<typename T>
const T * GetData () const
 
template<typename T>
TSharedPtr< const T > GetDataCopy () const
 
void SetData (const void *InData, const FProperty *InProperty)
 
const FFieldClass * GetFieldClass () const
 
const FProperty * GetProperty () const
 
int32 GetDataSize () const
 
int32 GetID () const
 
bool HasData () const
 
FString ToString () const
 

Public Attributes

FOnDataChange OnDataChange
 

Detailed Description

DataShardObject is the core container class for data in the DataShard system.
This class provides a flexible data storage mechanism that can hold any Unreal property type.
It uses a type-erased byte buffer approach with a property reference to correctly interpret the stored data.
The system maintains these objects in a pool (DataShardPool) for efficient reuse.

Key capabilities:

  • Store and retrieve any Property data type
  • Maintain type safety through property system
  • Support change notifications
  • Efficiently manage memory through the pool system

Member Function Documentation

◆ GetData()

template<typename T>
const T * DataShardObject::GetData ( ) const
inline

Gets a typed pointer to the data stored in this shard

Template Parameters
T- The expected data type
Returns
Pointer to the typed data
Note
The caller must ensure the type T matches the shard's actual type
Warning
Will trigger a check() failure if the property is null or buffer is empty

◆ GetDataCopy()

template<typename T>
TSharedPtr< const T > DataShardObject::GetDataCopy ( ) const
inline

Creates and returns a copy of the data stored in this shard

Template Parameters
T- The expected data type
Returns
Shared pointer to a copy of the data
Note
The returned copy will not be updated when the shard data changes
Warning
Will trigger a check() failure if the property is null or buffer is empty

◆ GetDataSize()

int32 DataShardObject::GetDataSize ( ) const
inline

Returns the size in bytes of the data stored in this shard

◆ GetFieldClass()

const FFieldClass * DataShardObject::GetFieldClass ( ) const
inline

Returns the field class of the property used by this shard

◆ GetID()

int32 DataShardObject::GetID ( ) const
inline

Returns the unique identifier for this shard

◆ GetProperty()

const FProperty * DataShardObject::GetProperty ( ) const
inline

Returns the property used to interpret the data in this shard

◆ HasData()

bool DataShardObject::HasData ( ) const
inline

Returns true if this shard contains valid data

◆ InitializeShard()

void DataShardObject::InitializeShard ( const FProperty * InDataType,
const int32 & InShardIndex )

Initializes the shard with a specific property type and ID

Parameters
InDataType- The property type that defines the data structure
InShardIndex- The unique identifier for this shard

◆ Reset()

void DataShardObject::Reset ( )

Resets the shard to its initial state Clears the data buffer and property reference

◆ SetData()

void DataShardObject::SetData ( const void * InData,
const FProperty * InProperty )

Sets the data in this shard Copies the provided data into the internal buffer using the property system

Parameters
InData- Pointer to the source data to copy
InProperty- The property describing the data type (must match the shard's existing type)

◆ ToString()

FString DataShardObject::ToString ( ) const
inline

Returns a string representation of this shard for debugging

Member Data Documentation

◆ OnDataChange

FOnDataChange DataShardObject::OnDataChange

Delegate that is broadcast when the shard's data changes