Apparatus Version 1.2.1
ECS data-driven 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 }
 

Public Member Functions

const FTraitmarkGetTraitmark () const
 Get the traitmark of the chunk. More...
 
const FFilterGetLockingFilter () const
 Get the active locking filter. More...
 
UScriptStruct * GetTraitType (int32 LineIndex) const
 Get a trait type given line index. More...
 
int32 GetTraitSize (int32 LineIndex) const
 Get the size of a trait given its line index. More...
 
void * GetTraitDataGivenSubjectAndLineIndices (const int32 SubjectIndex, const int32 LineIndex) const
 Get the trait data pointer 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...
 
UScriptStruct * GetLineType (const int32 LineIndex) const
 Get the type of the line at a specific index. More...
 
 ~UChunk ()
 Finalize the chunk, freeing all of its resources. More...
 
EApparatusStatus Lock (const FFilter &InFilter) const
 Lock the chunk, increasing its current lock count. More...
 
EApparatusStatus Lock () const
 Lock the chunk using the currently locking filter. More...
 
EApparatusStatus Unlock () const
 Unlock the chunk, decreasing its current lock count. More...
 
bool IsLocked () const
 Is the chunk currently locked. More...
 
bool IsSubjectLocked (const int32 SubjectIndex) const
 Check if the subject at specified place is locked. More...
 
int32 Num () const
 Get the total number of subjects, currently in the chunk. More...
 
void Reserve (const int32 InCapacity)
 Reserve a certain capacity. More...
 
EApparatusStatus Begin (struct FChunkIt &Iterator, const FFilter &Filter) const
 Get the first iterator for the chunk. More...
 
FChunkIt Begin (const FFilter &Filter) const
 Get the first iterator for the chunk. More...
 
FChunkIt Begin () const
 Get the first iterator for the chunk under the current locking filter. More...
 
EApparatusStatus Advance (struct FChunkIt &Iterator)
 Get the next iterator for the chunk. More...
 
bool IsEnd (struct FChunkIt &Iterator)
 Has the iterator reached a chunk's end. 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...
 
EApparatusStatus SetSubjectTrait (const int32 SubjectIndex, const UScriptStruct *const Trait, 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 CopyTraitsGivenSubjectIndices (const int32 SrcSubjectIndex, class UChunk *const DstChunk, const int32 DstSubjectIndex) const
 Copy the traits from this chunk to another one, given subject indices. More...
 
bool Matches (const FFilter &Filter) const
 Check whether the chunk matches a filter. More...
 

Static Public Member Functions

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

Friends

struct FSubjectHandle
 
struct FMechanicInfo
 
struct FChunkIt
 
struct FChunkChain
 
struct FFingerprint
 
class UMachine
 

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.

Constructor & Destructor Documentation

◆ ~UChunk()

UChunk::~UChunk ( )
inline

Finalize the chunk, freeing all of its resources.

Member Function Documentation

◆ Advance()

EApparatusStatus UChunk::Advance ( struct FChunkIt Iterator)
inline

Get the next iterator for the chunk.

Returns
If the iterator is viable and not at the end of the chunk returns true. Otherwise, returns false.

◆ Begin() [1/3]

FChunkIt 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/3]

FChunkIt UChunk::Begin ( const FFilter Filter) const
inline

Get the first iterator for the chunk.

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

◆ Begin() [3/3]

EApparatusStatus UChunk::Begin ( struct FChunkIt Iterator,
const FFilter Filter 
) const
inline

Get the first iterator for the chunk.

Returns
The status of the operation.

◆ 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.

◆ CopyTraitsGivenSubjectIndices()

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

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

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

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.

◆ 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.

◆ GetLineType()

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

Get the type of the line at a specific index.

◆ GetLockingFilter()

const FFilter& UChunk::GetLockingFilter ( ) const
inline

Get the active locking filter.

◆ GetSubjectTrait()

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.

◆ GetTraitDataGivenSubjectAndLineIndices()

void* UChunk::GetTraitDataGivenSubjectAndLineIndices ( const int32  SubjectIndex,
const int32  LineIndex 
) const
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.

◆ GetTraitmark()

const FTraitmark& UChunk::GetTraitmark ( ) const
inline

Get the traitmark of the chunk.

◆ GetTraitSize()

int32 UChunk::GetTraitSize ( 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 structure.

◆ GetTraitType()

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

Get a trait type given line index.

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

◆ IsEnd()

bool UChunk::IsEnd ( struct FChunkIt Iterator)
inline

Has the iterator reached a chunk's end.

Returns
Returns true, if the iterator has reached a chunk's end.

◆ IsLocked()

bool UChunk::IsLocked ( ) const
inline

Is the chunk currently locked.

Returns
The lock state.

◆ 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.

Parameters
chunkA chunk to examine. Must not be a nullptr
Returns
The number of detail lines in the chunk.

◆ Lock() [1/2]

EApparatusStatus UChunk::Lock ( ) const
inline

Lock the chunk using the currently locking filter.

Returns
The status of the operation.

◆ Lock() [2/2]

EApparatusStatus UChunk::Lock ( const FFilter InFilter) const
inline

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.

◆ Matches()

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

Check whether the chunk matches a filter.

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

◆ New()

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

Create a new chunk instance.

◆ Num()

int32 UChunk::Num ( ) const
inline

Get the total number of subjects, currently in the chunk.

Returns
The current number of subjects.

◆ Reserve()

void UChunk::Reserve ( const int32  InCapacity)
inline

Reserve a certain capacity.

◆ SetSubjectTrait()

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

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

Parameters
SubjectThe index of the subject within the chunk.
TraitThe trait type identifier.
InTraitDataThe trait data to set.
Returns
The status of the operation.

◆ Unlock()

EApparatusStatus UChunk::Unlock ( ) const
inline

Unlock the chunk, decreasing its current lock count.

Returns
The status of the operation.

Friends And Related Function Documentation

◆ FChunkChain

friend struct FChunkChain
friend

◆ FChunkIt

friend struct FChunkIt
friend

◆ FFingerprint

friend struct FFingerprint
friend

◆ FMechanicInfo

friend struct FMechanicInfo
friend

◆ FSubjectHandle

friend struct FSubjectHandle
friend

◆ UMachine

friend class UMachine
friend

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