Apparatus Version 1.8
ECS data-oriented workflow for Unreal Engine.
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
UChunk Class Reference

The main containter of subjects' traits. More...

#include <Chunk.h>

Inheritance diagram for UChunk:
Inheritance graph
[legend]
Collaboration diagram for UChunk:
Collaboration graph
[legend]

Public Types

enum  {
  InvalidId = 0 , FirstId = 1 , InvalidLineIndex = -1 , InvalidSubjectIndex = FSubjectInfo::InvalidIndex ,
  InvalidSubjectId = FSubjectInfo::InvalidId
}
 

Public Member Functions

const FTraitmarkGetTraitmark () const
 Get the traitmark of the chunk. More...
 
UMechanismGetOwner () const
 Get the owning mechanism of the chunk. More...
 
UScriptStruct * GetLineType (const int32 LineIndex) const
 Get a trait type given a line index. More...
 
int32 GetLineTraitSize (const int32 LineIndex) const
 Get the size of a trait given its line index. More...
 
void * GetTraitPtrGivenSubjectAndLineIndices (const int32 SubjectIndex, const int32 LineIndex)
 Get the trait data pointer given subject's index and a line index. More...
 
const void * GetTraitPtrGivenSubjectAndLineIndices (const int32 SubjectIndex, const int32 LineIndex) const
 Get the trait data pointer given subject's index and a line index. More...
 
template<typename T >
T & GetTraitRefGivenSubjectAndLineIndices (const int32 SubjectIndex, const int32 LineIndex)
 Get the trait reference given subject's index and a line index. More...
 
template<typename T >
const T & GetTraitRefGivenSubjectAndLineIndices (const int32 SubjectIndex, const int32 LineIndex) const
 Get a trait reference given subject's index and a line index. More...
 
template<typename T >
GetTraitGivenSubjectAndLineIndices (const int32 SubjectIndex, const int32 LineIndex) const
 Get a copy of a trait given subject's index and a line index. More...
 
EApparatusStatus CopyTraitGivenSubjectAndLineIndices (const int32 SubjectIndex, const int32 LineIndex, void *const OutTraitData, bool bTraitDataInitialized=true) const
 Copy a trait's data given a subject and line indices. More...
 
int32 LinesNum () const
 The number of trait lines in the chunk. More...
 
void BeginDestroy () override
 Finalize the chunk, freeing all of its resources. More...
 
virtual EApparatusStatus DoLock (const FFilter &InFilter) const override
 Lock the chunk, increasing its current lock count. More...
 
virtual EApparatusStatus DoUnlock () const override
 Unlock the chunk, decreasing its current lock count. More...
 
bool IsSubjectLocked (const int32 SubjectIndex) const
 Check if the subject at specified place is locked. More...
 
void Reserve (const int32 InCapacity)
 Reserve a certain capacity. More...
 
template<typename ChunkItT >
EApparatusStatus Begin (const FFilter &Filter, const int32 Offset, ChunkItT &OutIterator) const
 Get the first iterator for the chunk. More...
 
template<typename ChunkItT >
EApparatusStatus Begin (const FFilter &Filter, ChunkItT &OutIterator) const
 Get the first iterator for the chunk. More...
 
template<typename ChunkItT >
ChunkItT Begin (const FFilter &Filter, const int32 Offset=0) const
 Get the first iterator for the chunk. More...
 
template<typename ChunkItT >
ChunkItT Begin (const FFilter &Filter, EApparatusStatus &OutStatus) const
 Get the first iterator for the chunk receiving a status via a second argument. More...
 
template<typename ChunkItT >
ChunkItT Begin (EApparatusStatus &OutStatus) const
 Get the first iterator for the chunk under the current locking filter receiving a status via an argument. More...
 
template<typename ChunkItT >
ChunkItT Begin (const int32 Offset, EApparatusStatus &OutStatus) const
 Get the first iterator for the chunk under the current locking filter while receiving a status via an argument. More...
 
template<typename ChunkItT >
ChunkItT Begin () const
 Get the first iterator for the chunk under the current locking filter. More...
 
template<typename ChunkItT >
EApparatusStatus Advance (ChunkItT &Iterator)
 Get the next iterator for the chunk. More...
 
template<typename ChunkItT >
bool IsEnd (const ChunkItT &Iterator) const
 Has the iterator reached a chunk's end. More...
 
void * GetSubjectTraitPtr (const int32 SubjectIndex, const UScriptStruct *const TraitType)
 Get the trait data pointer from the chunk's subject by its type identifier. More...
 
const void * GetSubjectTraitPtr (const int32 SubjectIndex, const UScriptStruct *const TraitType) const
 Get the read-only trait data pointer from the chunk's subject by its type identifier. More...
 
template<typename T >
T * GetSubjectTraitPtr (const int32 SubjectIndex)
 Get the trait data pointer from the chunk's subject by its type identifier. More...
 
template<typename T >
const T * GetSubjectTraitPtr (const int32 SubjectIndex) const
 Get the trait data pointer from the chunk's subject by its type identifier. More...
 
template<typename T >
T & GetSubjectTraitRef (const int32 SubjectIndex)
 Get a trait reference from the chunk's subject by its type identifier. More...
 
template<typename T >
const T & GetSubjectTraitRef (const int32 SubjectIndex) const
 Get a read-only trait reference from the chunk's subject by its type identifier. More...
 
EApparatusStatus GetSubjectTrait (const int32 SubjectIndex, const UScriptStruct *const TraitType, void *const OutTraitData, const bool bTraitDataInitialized=true) const
 Copy a trait from the chunk's subject by its type identifier. More...
 
template<typename T >
GetSubjectTrait (const int32 SubjectIndex) const
 Get a copy of a trait from the chunk's subject by its type identifier. More...
 
EApparatusStatus SetSubjectTrait (const int32 SubjectIndex, const UScriptStruct *const TraitType, const void *const InTraitData)
 Set the trait for the chunk's subject by its type identifier. More...
 
EApparatusStatus FetchTraitsPtrs (const int32 SubjectIndex, const TArray< int32 > &Mapping, void **OutTraits)
 Fetch the traits for a subject into a traits data array. More...
 
EApparatusStatus OverwriteTraits (const int32 SrcSubjectIndex, class UChunk *const DstChunk, const int32 DstSubjectIndex) const
 Copy the traits from this chunk to another one, given subject indices. More...
 
EApparatusStatus OverwriteTraits (const int32 SrcSubjectIndex, class UChunk *const DstChunk, const int32 DstSubjectIndex)
 Copy the traits from this chunk to another one, given subject indices. More...
 
EApparatusStatus OverwriteTraits (const int32 SrcSubjectIndex, const int32 DstSubjectIndex)
 Copy the traits within the chunk, given subject indices. More...
 
bool Matches (const FFilter &Filter) const override
 Check whether the chunk matches a filter. More...
 
bool Check () const
 Check the validity of the chunk. More...
 
- Public Member Functions inherited from IIterable
UMechanismGetOwner () const
 Get the owning mechanism of the iterable. More...
 
bool IsLocked () const
 Check if the sequence is currently locked. More...
 
bool IsSolid () const
 Check if the iterable is locked in a solid manner. More...
 
int32 Num () const
 Get the total number of slots currently in the iterable. More...
 
int32 IterableNum () const
 Get the current number of elements valid for iterating. More...
 
const FFilterGetLockingFilter () const
 Get the active locking filter of the sequence. More...
 

Static Public Member Functions

static UChunkNew (UMechanism *const Owner, const int32 Id, const FTraitmark &InTraitmark)
 Create a new chunk instance. More...
 

Friends

struct FSubjectInfo
 
struct FSubjectHandleBase
 
struct FMechanicInfo
 
struct FFingerprint
 
class UMechanism
 
class UMachine
 
template<typename SubjectHandleT >
struct TChunkIt
 
template<typename ChunkItT , typename BeltItT >
struct TChain
 

Additional Inherited Members

- Protected Member Functions inherited from IIterable
template<bool bInSolid>
EApparatusStatus Lock (const FFilter &InFilter) const
 Lock the iterable under a chosen filter. More...
 
template<bool bInSolid>
EApparatusStatus Lock () const
 Add locks to the iterable under the existing already locking filter. More...
 
template<bool bInSolid>
EApparatusStatus Unlock () const
 Unlock the iterable, applying the pending changes. More...
 
- Protected Attributes inherited from IIterable
TArray< int32 > LockedMapping
 A mapping from the locked traitmark/detailmark to the sequence's own traitmark/detailmark. More...
 
int32 Count = 0
 The logical (un-buffered) number of slots in the belt that are actually candidates for being iterated once the iterable is locked. More...
 
int32 IterableCount = -1
 A number of currently iterable slots, excluding those, that were added before the unlocking. More...
 
TArray< int32 > Removed
 The indices of the slots queued to be removed once the belt becomes unlocked. More...
 

Detailed Description

The main containter of subjects' traits.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
InvalidId 

Invalid chunk identifier.

FirstId 

First valid chunk identifier.

InvalidLineIndex 

Invalid trait line index.

InvalidSubjectIndex 

Invalid subject index.

InvalidSubjectId 

Invalid subject identifier.

Member Function Documentation

◆ Advance()

template<typename ChunkItT >
EApparatusStatus UChunk::Advance ( ChunkItT &  Iterator)
inline

Get the next iterator for the chunk.

Parameters
IteratorAn iterator to advance. Must belong to this chunk and have iterating already started.
Returns
If the iterator is viable and not at the end of the chunk returns true. Otherwise, returns false.

◆ Begin() [1/7]

template<typename ChunkItT >
ChunkItT UChunk::Begin ( ) const
inline

Get the first iterator for the chunk under the current locking filter.

Returns
The iterator pointing at the first subject or an invalid iterator pointing to an end, if the iteration is not possible.

◆ Begin() [2/7]

template<typename ChunkItT >
EApparatusStatus UChunk::Begin ( const FFilter Filter,
ChunkItT &  OutIterator 
) const
inline

Get the first iterator for the chunk.

Template Parameters
ChunkItTThe type of the iterator to use.
Parameters
FilterA filter to iterate under.
OutIteratorThe iterator receiver.
Returns
The status of the operation.

◆ Begin() [3/7]

template<typename ChunkItT >
EApparatusStatus UChunk::Begin ( const FFilter Filter,
const int32  Offset,
ChunkItT &  OutIterator 
) const
inline

Get the first iterator for the chunk.

Template Parameters
ChunkItTThe type of the iterator to use.
Parameters
FilterA filter to iterate under.
OffsetA slot offset to begin with.
OutIteratorAn iterator to receive the result.
Returns
The status of the operation.

◆ Begin() [4/7]

template<typename ChunkItT >
ChunkItT UChunk::Begin ( const FFilter Filter,
const int32  Offset = 0 
) const
inline

Get the first iterator for the chunk.

Template Parameters
ChunkItTThe type of the iterator to use.
Parameters
FilterA filter to iterate under.
OffsetA slot offset to begin with.
Returns
The iterator pointing at the first subject or an invalid iterator pointing to an end, if the iteration is not possible.

◆ Begin() [5/7]

template<typename ChunkItT >
ChunkItT UChunk::Begin ( const FFilter Filter,
EApparatusStatus OutStatus 
) const
inline

Get the first iterator for the chunk receiving a status via a second argument.

Template Parameters
ChunkItTThe type of the iterator to use.
Parameters
FilterA filter to iterate under.
OutStatusThe operation status receiver.
Returns
The iterator pointing at the first subject or an invalid iterator pointing to an end, if the iteration is not possible.

◆ Begin() [6/7]

template<typename ChunkItT >
ChunkItT UChunk::Begin ( const int32  Offset,
EApparatusStatus OutStatus 
) const
inline

Get the first iterator for the chunk under the current locking filter while receiving a status via an argument.

Template Parameters
ChunkItTThe type of the iterator to use.
Parameters
OffsetA slot offset to begin with.
OutStatusThe operation status receiver.
Returns
The iterator pointing at the first subject or an invalid iterator pointing to an end, if the iteration is not possible.

◆ Begin() [7/7]

template<typename ChunkItT >
ChunkItT UChunk::Begin ( EApparatusStatus OutStatus) const
inline

Get the first iterator for the chunk under the current locking filter receiving a status via an argument.

Template Parameters
ChunkItTThe type of the iterator to use.
Parameters
OutStatusThe operation status receiver.
Returns
The iterator pointing at the first subject or an invalid iterator pointing to an end, if the iteration is not possible.

◆ BeginDestroy()

void UChunk::BeginDestroy ( )
inlineoverride

Finalize the chunk, freeing all of its resources.

◆ Check()

bool UChunk::Check ( ) const
inline

Check the validity of the chunk.

◆ CopyTraitGivenSubjectAndLineIndices()

EApparatusStatus UChunk::CopyTraitGivenSubjectAndLineIndices ( const int32  SubjectIndex,
const int32  LineIndex,
void *const  OutTraitData,
bool  bTraitDataInitialized = true 
) const
inline

Copy a trait's data given a subject and line indices.

Parameters
SubjectIndexThe index of the subject which trait to copy.
LineIndexThe index of the trait line.
OutTraitDataThe output buffer to copy to.
bTraitDataInitializedIs the trait data initialized or a raw buffer?
Returns
The status of the operation.

◆ DoLock()

EApparatusStatus UChunk::DoLock ( const FFilter InFilter) const
inlineoverridevirtual

Lock the chunk, increasing its current lock count.

A chunk always has to be locked while iterating on it. The number of locks has to be matched by the respective number of unlocks, in order for chunk to be unlocked again.

Returns
The status of the operation.

Reimplemented from IIterable.

◆ DoUnlock()

EApparatusStatus UChunk::DoUnlock ( ) const
inlineoverridevirtual

Unlock the chunk, decreasing its current lock count.

Returns
The status of the operation.

Reimplemented from IIterable.

◆ FetchTraitsPtrs()

EApparatusStatus UChunk::FetchTraitsPtrs ( const int32  SubjectIndex,
const TArray< int32 > &  Mapping,
void **  OutTraits 
)
inline

Fetch the traits for a subject into a traits data array.

Parameters
SubjectIndexThe index of the subject within the belt.
MappingThe mapping to use while fetching.
OutTraitsInitialized traits data to fill.
Returns
The status of the operation.

◆ GetLineTraitSize()

int32 UChunk::GetLineTraitSize ( const int32  LineIndex) const
inline

Get the size of a trait given its line index.

Parameters
LineIndexThe index of the line.
Returns
The size of the trait structure corresponding to the line.

◆ GetLineType()

UScriptStruct* UChunk::GetLineType ( const int32  LineIndex) const
inline

Get a trait type given a line index.

Parameters
LineIndexAn index of the line.
Returns
The trait type of the line.

◆ GetOwner()

UMechanism * UChunk::GetOwner ( ) const
inline

Get the owning mechanism of the chunk.

◆ GetSubjectTrait() [1/2]

template<typename T >
T UChunk::GetSubjectTrait ( const int32  SubjectIndex) const
inline

Get a copy of a trait from the chunk's subject by its type identifier.

Template Parameters
TThe type of the trait to copy.
Returns
The copy of the trait.

◆ GetSubjectTrait() [2/2]

EApparatusStatus UChunk::GetSubjectTrait ( const int32  SubjectIndex,
const UScriptStruct *const  TraitType,
void *const  OutTraitData,
const bool  bTraitDataInitialized = true 
) const
inline

Copy a trait from the chunk's subject by its type identifier.

Parameters
SubjectIndexThe index of the subject within the chunk.
TraitTypeThe trait type identifier.
OutTraitDataThe trait data receiver.
bTraitDataInitializedIs the OutTraitData actually initialized?
Returns
The status of the operation.

◆ GetSubjectTraitPtr() [1/4]

template<typename T >
T* UChunk::GetSubjectTraitPtr ( const int32  SubjectIndex)
inline

Get the trait data pointer from the chunk's subject by its type identifier.

Templated version.

Template Parameters
TThe trait type identifier.
Parameters
SubjectIndexThe index of the subject within the chunk.
Returns
A pointer to the trait data.

◆ GetSubjectTraitPtr() [2/4]

template<typename T >
const T* UChunk::GetSubjectTraitPtr ( const int32  SubjectIndex) const
inline

Get the trait data pointer from the chunk's subject by its type identifier.

Templated constant version.

Template Parameters
TThe trait type identifier.
Parameters
SubjectIndexThe index of the subject within the chunk.
Returns
A pointer to the trait data.

◆ GetSubjectTraitPtr() [3/4]

void* UChunk::GetSubjectTraitPtr ( const int32  SubjectIndex,
const UScriptStruct *const  TraitType 
)
inline

Get the trait data pointer from the chunk's subject by its type identifier.

Parameters
SubjectIndexThe index of the subject within the chunk.
TraitTypeThe trait type identifier.
Returns
A pointer to the trait data.

◆ GetSubjectTraitPtr() [4/4]

const void* UChunk::GetSubjectTraitPtr ( const int32  SubjectIndex,
const UScriptStruct *const  TraitType 
) const
inline

Get the read-only trait data pointer from the chunk's subject by its type identifier.

Constant version.

Parameters
SubjectIndexThe index of the subject within the chunk.
TraitTypeThe trait type identifier.
Returns
A pointer to the read-only trait data.

◆ GetSubjectTraitRef() [1/2]

template<typename T >
T& UChunk::GetSubjectTraitRef ( const int32  SubjectIndex)
inline

Get a trait reference from the chunk's subject by its type identifier.

Template Parameters
TThe type of the trait to get.
Parameters
SubjectIndexThe index of the subject within the chunk.
Returns
A reference for the trait.

◆ GetSubjectTraitRef() [2/2]

template<typename T >
const T& UChunk::GetSubjectTraitRef ( const int32  SubjectIndex) const
inline

Get a read-only trait reference from the chunk's subject by its type identifier.

Template Parameters
TThe type of the trait to get.
Parameters
SubjectIndexThe index of the subject within the chunk.
Returns
A reference for the read-only trait.

◆ GetTraitGivenSubjectAndLineIndices()

template<typename T >
T UChunk::GetTraitGivenSubjectAndLineIndices ( const int32  SubjectIndex,
const int32  LineIndex 
) const
inline

Get a copy of a trait given subject's index and a line index.

Template Parameters
TThe type of the trait to get.
Parameters
SubjectIndexAn index of the subject.
LineIndexAn index of the line.
Returns
The copy of the trait.

◆ GetTraitmark()

const FTraitmark& UChunk::GetTraitmark ( ) const
inline

Get the traitmark of the chunk.

◆ GetTraitPtrGivenSubjectAndLineIndices() [1/2]

void* UChunk::GetTraitPtrGivenSubjectAndLineIndices ( const int32  SubjectIndex,
const int32  LineIndex 
)
inline

Get the trait data pointer given subject's index and a line index.

Parameters
SubjectIndexAn index of the subject.
LineIndexAn index of the line.
Returns
The data of the trait.

◆ GetTraitPtrGivenSubjectAndLineIndices() [2/2]

const void* UChunk::GetTraitPtrGivenSubjectAndLineIndices ( const int32  SubjectIndex,
const int32  LineIndex 
) const
inline

Get the trait data pointer given subject's index and a line index.

Constant version.

Parameters
SubjectIndexAn index of the subject.
LineIndexAn index of the line.
Returns
A read-only data of the trait.

◆ GetTraitRefGivenSubjectAndLineIndices() [1/2]

template<typename T >
T& UChunk::GetTraitRefGivenSubjectAndLineIndices ( const int32  SubjectIndex,
const int32  LineIndex 
)
inline

Get the trait reference given subject's index and a line index.

Template Parameters
TThe type of the trait to get.
Parameters
SubjectIndexAn index of the subject.
LineIndexAn index of the line.
Returns
The reference for the trait.

◆ GetTraitRefGivenSubjectAndLineIndices() [2/2]

template<typename T >
const T& UChunk::GetTraitRefGivenSubjectAndLineIndices ( const int32  SubjectIndex,
const int32  LineIndex 
) const
inline

Get a trait reference given subject's index and a line index.

Constant version.

Template Parameters
TThe type of the trait to get.
Parameters
SubjectIndexAn index of the subject.
LineIndexAn index of the line.
Returns
The reference for the read-only trait.

◆ IsEnd()

template<typename ChunkItT >
bool UChunk::IsEnd ( const ChunkItT &  Iterator) const
inline

Has the iterator reached a chunk's end.

Parameters
IteratorThe iterator to examine.
Returns
Returns true, if the iterator has reached a chunk's end, false otherwise.

◆ IsSubjectLocked()

bool UChunk::IsSubjectLocked ( const int32  SubjectIndex) const
inline

Check if the subject at specified place is locked.

◆ LinesNum()

int32 UChunk::LinesNum ( ) const
inline

The number of trait lines in the chunk.

Returns
The total number of trait lines in the chunk.

◆ Matches()

bool UChunk::Matches ( const FFilter Filter) const
inlineoverridevirtual

Check whether the chunk matches a filter.

Parameters
FilterA filter to match.
Returns
The state of matching.

Reimplemented from IIterable.

◆ New()

UChunk * UChunk::New ( UMechanism *const  Owner,
const int32  Id,
const FTraitmark InTraitmark 
)
inlinestatic

Create a new chunk instance.

◆ OverwriteTraits() [1/3]

EApparatusStatus UChunk::OverwriteTraits ( const int32  SrcSubjectIndex,
class UChunk *const  DstChunk,
const int32  DstSubjectIndex 
)
inline

Copy the traits from this chunk to another one, given subject indices.

If the trait is missing within the destination chunk it is safely skipped.

Parameters
SrcSubjectIndexThe subject's index within the source chunk.
DstChunkThe destination chunk to copy to. May the same as the source (this).
DstSubjectIndexThe subject's index within the destination chunk.
Returns
The status of the operation.

◆ OverwriteTraits() [2/3]

EApparatusStatus UChunk::OverwriteTraits ( const int32  SrcSubjectIndex,
class UChunk *const  DstChunk,
const int32  DstSubjectIndex 
) const
inline

Copy the traits from this chunk to another one, given subject indices.

Constant version.

If the trait is missing within the destination chunk it is safely skipped.

Note
The constant version doesn't support copying to itself.
Parameters
SrcSubjectIndexThe subject's index within the source chunk.
DstChunkThe destination chunk to copy to.
DstSubjectIndexThe subject's index within the destination chunk.
Returns
The status of the operation.

◆ OverwriteTraits() [3/3]

EApparatusStatus UChunk::OverwriteTraits ( const int32  SrcSubjectIndex,
const int32  DstSubjectIndex 
)
inline

Copy the traits within the chunk, given subject indices.

Parameters
SrcSubjectIndexThe subject's index to copy from.
DstSubjectIndexThe subject's index to copy to.
Returns
The status of the operation.

◆ Reserve()

void UChunk::Reserve ( const int32  InCapacity)
inline

Reserve a certain capacity.

◆ SetSubjectTrait()

EApparatusStatus UChunk::SetSubjectTrait ( const int32  SubjectIndex,
const UScriptStruct *const  TraitType,
const void *const  InTraitData 
)
inline

Set the trait for the chunk's subject by its type identifier.

Parameters
SubjectIndexThe index of the subject within the chunk.
TraitTypeThe type of the trait to set.
InTraitDataThe trait data to set.
Returns
The status of the operation.

Friends And Related Function Documentation

◆ FFingerprint

friend struct FFingerprint
friend

◆ FMechanicInfo

friend struct FMechanicInfo
friend

◆ FSubjectHandleBase

friend struct FSubjectHandleBase
friend

◆ FSubjectInfo

FSubjectInfo
friend

◆ TChain

template<typename ChunkItT , typename BeltItT >
friend struct TChain
friend

◆ TChunkIt

template<typename SubjectHandleT >
friend struct TChunkIt
friend

◆ UMachine

friend class UMachine
friend

◆ UMechanism

friend class UMechanism
friend

The documentation for this class was generated from the following files: