Apparatus Version 1.8
ECS data-oriented workflow for Unreal Engine.
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
FSubjectHandleBase Struct Reference

The main entity of the Apparatus, consisting of traits. More...

#include <SubjectHandleBase.h>

Inheritance diagram for FSubjectHandleBase:
Inheritance graph
[legend]

Public Types

enum  { InvalidId = FSubjectInfo::InvalidId , InvalidGeneration = FSubjectInfo::InvalidGeneration }
 

Public Member Functions

 FSubjectHandleBase ()
 Construct a new invalid base subject handle. More...
 
UMechanismGetMechanism () const
 Get the mechanism of the subject handle. More...
 
void ResetHandle ()
 Clear the subject handle, essentially making it invalid. More...
 
UObject * GetSubjectiveObject () const
 Get a subjective object this handle is associated with (if any). More...
 
FSubjectHandleBaseoperator= (TYPE_OF_NULLPTR)
 Clear the subject handle, essentially making it invalid. More...
 
uint32 CalcHash () const
 Calculate the hash-sum value for the handle. More...
 
const FFingerprintGetFingerprint () const
 Get the fingerprint of the subject. More...
 
bool Matches (const FFilter &InFilter) const
 Check if the subject matches a certain filter. More...
 
bool IsValid () const
 Check if the subject handle is valid and is pointing to an existent subject. More...
 
bool operator== (TYPE_OF_NULLPTR) const
 Check if the subject handle is invalid and is pointing to a non-existent subject. More...
 
bool operator!= (TYPE_OF_NULLPTR) const
 Check if the subject handle is valid and is pointing to an existent subject. More...
 
 operator bool () const
 Check if the subject handle is valid and is pointing to an existent subject. More...
 
bool HasTrait (UScriptStruct *const TraitType) const
 Check if the subject has a certain trait. More...
 
template<typename T >
bool HasTrait () const
 Check if the subject has a certain trait. More...
 
bool HasDetail (TSubclassOf< UDetail > DetailClass) const
 Check if the subject has a certain detail. More...
 
template<typename T >
bool HasDetail () const
 Check if the subject has a certain detail. More...
 
bool EqualsRaw (const FSubjectHandleBase &InSubject) const
 Check if two subject handles are equal byte-wise. More...
 
bool operator== (const FSubjectHandleBase &InSubject) const
 Check if the subject handle points to the same subject as the other one. More...
 
bool operator!= (const FSubjectHandleBase &InSubject) const
 Check if the subject handles point to different subjects. More...
 
EApparatusStatus GetTrait (UScriptStruct *const TraitType, void *const OutTraitData, const bool bTraitDataInitialized=true) const
 Get a trait from a subject by its type. More...
 
template<typename T >
EApparatusStatus GetTrait (T &OutTrait, const bool bTraitDataInitialized=true) const
 Get a trait from a subject by its type. More...
 
template<typename T >
GetTrait () const
 Get a trait copy from a subject by its type. More...
 
EApparatusStatus CopyTraitsTo (const FSubjectHandle &DestinationSubjectHandle) const
 Copy the traits to some other subject. More...
 

Protected Member Functions

FSubjectInfoFindInfo () const
 Get the valid subject info record (if any). More...
 
FSubjectInfoGetInfo () const
 Get the subject info record associated with it. More...
 
EApparatusStatus MarkBooted () const
 
EApparatusStatus Despawn () const
 Destroy the subject. More...
 
UChunkGetChunk () const
 Get the current chunk of the subject. More...
 
EApparatusStatus SetTrait (UScriptStruct *TraitType, const void *const TraitData) const
 Set a trait of the subject by its type. More...
 
template<typename T >
EApparatusStatus SetTrait (const T &Trait) const
 Set a trait of the subject. More...
 
void * GetTraitPtr (UScriptStruct *const TraitType) const
 Get a pointer to a trait of a certain type. More...
 
template<typename T >
T * GetTraitPtr () const
 Get a pointer to a trait of a certain type. More...
 
template<typename T >
T & GetTraitRef () const
 Get a trait from a subject by its type. More...
 
EApparatusStatus ObtainTrait (UScriptStruct *TraitType, void *const OutTraitData, const bool bTraitDataInitialized=true) const
 Obtain a trait from a subject by its type. More...
 
template<typename T >
EApparatusStatus ObtainTrait (T &OutTrait, const bool bTraitDataInitialized=true) const
 Obtain a trait from a subject. More...
 
template<typename T >
ObtainTrait () const
 Obtain a trait copy from a subject. More...
 
EApparatusStatus RemoveTrait (UScriptStruct *TraitType) const
 Remove a trait from the subject. More...
 
template<typename T >
EApparatusStatus RemoveTrait () const
 Remove a trait from the subject. More...
 
TScriptInterface< ISubjectiveGetSubjective () const
 Get a subjective this handle is associated with (if any). More...
 
 FSubjectHandleBase (const int32 InId, const int32 InGeneration)
 Construct by explicit id and generation specifications. More...
 
 FSubjectHandleBase (const FSubjectHandleBase &InHandle)
 Copy-construct a new subject handle. More...
 
 FSubjectHandleBase (const FSubjectHandle &InHandle)
 Copy-construct a new subject handle from a mutable subject handle. More...
 
 FSubjectHandleBase (const FSolidSubjectHandle &InHandle)
 Copy-construct a new subject handle from a homogenous subject handle. More...
 
 FSubjectHandleBase (const FConstSubjectHandle &InHandle)
 Copy-construct a new subject handle from an immutable subject handle. More...
 

Protected Attributes

int32 Id = InvalidId
 A unique identifier of the subject within the mechanism. More...
 
int32 Generation = InvalidGeneration
 A unique generation of the subject. More...
 

Friends

template<typename ChunkItT , typename BeltItT >
struct TChain
 
template<typename SubjectHandleT >
struct TChunkIt
 
template<typename SubjectHandleT >
struct TBeltIt
 
struct FSubjectInfo
 
struct FSolidSubjectHandle
 
struct FConstSubjectHandle
 
struct FChunkSlot
 
class UChunk
 
class UMechanism
 
class UMachine
 
class ISubjective
 

Detailed Description

The main entity of the Apparatus, consisting of traits.

This is a user-level handle structure, something like a pointer. The size of this structure is exactly 64-bit and may be passed by value.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
InvalidId 

Invalid subject identifier.

InvalidGeneration 

Invalid subject generation.

Constructor & Destructor Documentation

◆ FSubjectHandleBase() [1/6]

FSubjectHandleBase::FSubjectHandleBase ( )
inline

Construct a new invalid base subject handle.

◆ FSubjectHandleBase() [2/6]

FSubjectHandleBase::FSubjectHandleBase ( const int32  InId,
const int32  InGeneration 
)
inlineprotected

Construct by explicit id and generation specifications.

Parameters
InIdThe unique subject identifier.
InGenerationThe generation of the subject.

◆ FSubjectHandleBase() [3/6]

FSubjectHandleBase::FSubjectHandleBase ( const FSubjectHandleBase InHandle)
inlineprotected

Copy-construct a new subject handle.

◆ FSubjectHandleBase() [4/6]

FSubjectHandleBase::FSubjectHandleBase ( const FSubjectHandle InHandle)
inlineexplicitprotected

Copy-construct a new subject handle from a mutable subject handle.

◆ FSubjectHandleBase() [5/6]

FSubjectHandleBase::FSubjectHandleBase ( const FSolidSubjectHandle InHandle)
inlineexplicitprotected

Copy-construct a new subject handle from a homogenous subject handle.

◆ FSubjectHandleBase() [6/6]

FSubjectHandleBase::FSubjectHandleBase ( const FConstSubjectHandle InHandle)
inlineexplicitprotected

Copy-construct a new subject handle from an immutable subject handle.

Member Function Documentation

◆ CalcHash()

uint32 FSubjectHandleBase::CalcHash ( ) const
inline

Calculate the hash-sum value for the handle.

◆ CopyTraitsTo()

EApparatusStatus FSubjectHandleBase::CopyTraitsTo ( const FSubjectHandle DestinationSubjectHandle) const
inline

Copy the traits to some other subject.

The existing traits of the destination subject are not removed but the new ones are added and/or override the existing matching.

Parameters
DestinationSubjectHandleThe destination subject to copy to.
Returns
The status of the operation.

◆ Despawn()

EApparatusStatus FSubjectHandleBase::Despawn ( ) const
inlineprotected

Destroy the subject.

Returns
The status of the operation.

◆ EqualsRaw()

bool FSubjectHandleBase::EqualsRaw ( const FSubjectHandleBase InSubject) const
inline

Check if two subject handles are equal byte-wise.

◆ FindInfo()

FSubjectInfo * FSubjectHandleBase::FindInfo ( ) const
inlineprotected

Get the valid subject info record (if any).

The subject handle gets invalidated if the information is not found.

Returns
A valid subject registry information or nullptr, if the subject handle points to an invalid subject.

◆ GetChunk()

UChunk * FSubjectHandleBase::GetChunk ( ) const
inlineprotected

Get the current chunk of the subject.

Returns
A chunk, this subject is currently part of. Returns nullptr, if there is none.

◆ GetFingerprint()

const FFingerprint & FSubjectHandleBase::GetFingerprint ( ) const
inline

Get the fingerprint of the subject.

◆ GetInfo()

FSubjectInfo & FSubjectHandleBase::GetInfo ( ) const
inlineprotected

Get the subject info record associated with it.

◆ GetMechanism()

UMechanism* FSubjectHandleBase::GetMechanism ( ) const
inline

Get the mechanism of the subject handle.

◆ GetSubjective()

TScriptInterface<ISubjective> FSubjectHandleBase::GetSubjective ( ) const
inlineprotected

Get a subjective this handle is associated with (if any).

◆ GetSubjectiveObject()

UObject* FSubjectHandleBase::GetSubjectiveObject ( ) const
inline

Get a subjective object this handle is associated with (if any).

◆ GetTrait() [1/3]

template<typename T >
T FSubjectHandleBase::GetTrait ( ) const
inline

Get a trait copy from a subject by its type.

Template Parameters
TThe type of the trait to get.
Returns
A copy of the trait.

◆ GetTrait() [2/3]

template<typename T >
EApparatusStatus FSubjectHandleBase::GetTrait ( T &  OutTrait,
const bool  bTraitDataInitialized = true 
) const
inline

Get a trait from a subject by its type.

Templated version.

Template Parameters
TThe type of the trait to get.
Parameters
OutTraitThe trait receiver.
bTraitDataInitializedIs the OutTrait actually initialized?
Returns
The status of the operation.

◆ GetTrait() [3/3]

EApparatusStatus FSubjectHandleBase::GetTrait ( UScriptStruct *const  TraitType,
void *const  OutTraitData,
const bool  bTraitDataInitialized = true 
) const
inline

Get a trait from a subject by its type.

Parameters
TraitTypeThe type of the trait to get.
OutTraitDataThe trait data receiver.
bTraitDataInitializedIs the OutTraitData buffer actually initialized?
Returns
The status of the operation.

◆ GetTraitPtr() [1/2]

template<typename T >
T* FSubjectHandleBase::GetTraitPtr ( ) const
inlineprotected

Get a pointer to a trait of a certain type.

Templated version.

Template Parameters
TThe type of the trait to get.
Returns
A pointer to the trait data.

◆ GetTraitPtr() [2/2]

void * FSubjectHandleBase::GetTraitPtr ( UScriptStruct *const  TraitType) const
inlineprotected

Get a pointer to a trait of a certain type.

Parameters
TraitTypeThe type of the trait to get.
Returns
A pointer to the trait data.

◆ GetTraitRef()

template<typename T >
T& FSubjectHandleBase::GetTraitRef ( ) const
inlineprotected

Get a trait from a subject by its type.

Templated version.

Template Parameters
TThe type of the trait to get.
Returns
A reference to the trait data.

◆ HasDetail() [1/2]

template<typename T >
bool FSubjectHandleBase::HasDetail ( ) const
inline

Check if the subject has a certain detail.

Templated version.

◆ HasDetail() [2/2]

bool FSubjectHandleBase::HasDetail ( TSubclassOf< UDetail DetailClass) const
inline

Check if the subject has a certain detail.

◆ HasTrait() [1/2]

template<typename T >
bool FSubjectHandleBase::HasTrait ( ) const
inline

Check if the subject has a certain trait.

Templated version.

◆ HasTrait() [2/2]

bool FSubjectHandleBase::HasTrait ( UScriptStruct *const  TraitType) const
inline

Check if the subject has a certain trait.

◆ IsValid()

bool FSubjectHandleBase::IsValid ( ) const
inline

Check if the subject handle is valid and is pointing to an existent subject.

Returns
Returns true if the subject is valid. Otherwise, false is returned.

◆ MarkBooted()

EApparatusStatus FSubjectHandleBase::MarkBooted ( ) const
inlineprotected

◆ Matches()

bool FSubjectHandleBase::Matches ( const FFilter InFilter) const
inline

Check if the subject matches a certain filter.

◆ ObtainTrait() [1/3]

template<typename T >
T FSubjectHandleBase::ObtainTrait ( ) const
inlineprotected

Obtain a trait copy from a subject.

Templated version.

If the trait is not currently within the subject, it gets created anew and the default value is returned.

Template Parameters
TThe type of the trait to obtain.
Returns
A copy of the trait.

◆ ObtainTrait() [2/3]

template<typename T >
EApparatusStatus FSubjectHandleBase::ObtainTrait ( T &  OutTrait,
const bool  bTraitDataInitialized = true 
) const
inlineprotected

Obtain a trait from a subject.

Templated version.

If the trait is not currently within the subject, it gets created anew and the default value gets copied to the receiver.

Template Parameters
TThe type of the trait to obtain.
Parameters
OutTraitThe trait receiver.
bTraitDataInitializedIs the OutTrait actually initialized?
Returns
The status of the operation.

◆ ObtainTrait() [3/3]

EApparatusStatus FSubjectHandleBase::ObtainTrait ( UScriptStruct *  TraitType,
void *const  OutTraitData,
const bool  bTraitDataInitialized = true 
) const
inlineprotected

Obtain a trait from a subject by its type.

If the trait is not currently within the subject, it gets created anewand the default value gets copied to the receiver.

Parameters
TraitTypeThe type of the trait to obtain.
OutTraitDataThe trait data receiver.
bTraitDataInitializedIs the OutTraitData buffer actually initialized?
Returns
The status of the operation.

◆ operator bool()

FSubjectHandleBase::operator bool ( ) const
inline

Check if the subject handle is valid and is pointing to an existent subject.

Returns
Returns true if the subject is valid. Otherwise, false is returned.
See also
IsValid()

◆ operator!=() [1/2]

bool FSubjectHandleBase::operator!= ( const FSubjectHandleBase InSubject) const
inline

Check if the subject handles point to different subjects.

◆ operator!=() [2/2]

bool FSubjectHandleBase::operator!= ( TYPE_OF_NULLPTR  ) const
inline

Check if the subject handle is valid and is pointing to an existent subject.

Returns
Returns true if the subject is valid. Otherwise, false is returned.

◆ operator=()

FSubjectHandleBase& FSubjectHandleBase::operator= ( TYPE_OF_NULLPTR  )
inline

Clear the subject handle, essentially making it invalid.

◆ operator==() [1/2]

bool FSubjectHandleBase::operator== ( const FSubjectHandleBase InSubject) const
inline

Check if the subject handle points to the same subject as the other one.

If both handles are invalid, returns true

◆ operator==() [2/2]

bool FSubjectHandleBase::operator== ( TYPE_OF_NULLPTR  ) const
inline

Check if the subject handle is invalid and is pointing to a non-existent subject.

Returns
Returns true if the subject is invalid. Otherwise, false is returned.

◆ RemoveTrait() [1/2]

template<typename T >
EApparatusStatus FSubjectHandleBase::RemoveTrait ( ) const
inlineprotected

Remove a trait from the subject.

Templated version.

If there is no such trait in the subject, nothing is performed and EApparatusStatus::Noop is returned.

Template Parameters
TThe type of the trait to remove.
Returns
The status of the operation.

◆ RemoveTrait() [2/2]

EApparatusStatus FSubjectHandleBase::RemoveTrait ( UScriptStruct *  TraitType) const
inlineprotected

Remove a trait from the subject.

If there is no such trait in the subject, nothing is performed and EApparatusStatus::Noop is returned.

Parameters
TraitTypeThe type of the trait to remove.
Returns
The status of the operation.

◆ ResetHandle()

void FSubjectHandleBase::ResetHandle ( )
inline

Clear the subject handle, essentially making it invalid.

◆ SetTrait() [1/2]

template<typename T >
EApparatusStatus FSubjectHandleBase::SetTrait ( const T &  Trait) const
inlineprotected

Set a trait of the subject.

Templated version.

If the trait is not currently within the subject, it gets created anew and set accordingly.

Template Parameters
TA type of the trait to add.
Parameters
TraitA trait to initialize with.
Returns
The status of the operation.

◆ SetTrait() [2/2]

EApparatusStatus FSubjectHandleBase::SetTrait ( UScriptStruct *  TraitType,
const void *const  TraitData 
) const
inlineprotected

Set a trait of the subject by its type.

If the trait is not currently within the subject, it gets created anew and set accordingly

Parameters
TraitTypeThe type of the trait to add.
TraitDataThe trait data to initialize with.
Returns
The status of the operation.

Friends And Related Function Documentation

◆ FChunkSlot

friend struct FChunkSlot
friend

◆ FConstSubjectHandle

friend struct FConstSubjectHandle
friend

◆ FSolidSubjectHandle

friend struct FSolidSubjectHandle
friend

◆ FSubjectInfo

friend struct FSubjectInfo
friend

◆ ISubjective

friend class ISubjective
friend

◆ TBeltIt

template<typename SubjectHandleT >
friend struct TBeltIt
friend

◆ TChain

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

◆ TChunkIt

template<typename SubjectHandleT >
friend struct TChunkIt
friend

◆ UChunk

friend class UChunk
friend

◆ UMachine

friend class UMachine
friend

◆ UMechanism

friend class UMechanism
friend

Member Data Documentation

◆ Generation

int32 FSubjectHandleBase::Generation = InvalidGeneration
protected

A unique generation of the subject.

Used to validate the subject against reused slots.

◆ Id

int32 FSubjectHandleBase::Id = InvalidId
protected

A unique identifier of the subject within the mechanism.


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