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

The base structure for all subject handles. More...

#include <CommonSubjectHandle.h>

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

Public Types

typedef FSubjectInfo::IdType IdType
 The type of the unique subject identifier. More...
 
typedef FSubjectInfo::GenerationType GenerationType
 The type of the subject generation counter. More...
 

Public Member Functions

 FCommonSubjectHandle ()
 Initialize an invalid (null) handle. More...
 
 FCommonSubjectHandle (const FCommonSubjectHandle &InSubjectHandle)
 Initialize as a copy of an another subject handle. More...
 
Common Functionality
IdType GetId () const
 Get the unique identifier of the subject. More...
 
GenerationType GetGeneration () const
 Get the current generation of the subject. More...
 
bool IsSolid () const
 Check if the subject is currently solid. More...
 
void ResetHandle ()
 Reset the subject handle. More...
 
FCommonSubjectHandleoperator= (TYPE_OF_NULLPTR)
 Clear the subject handle, essentially making it invalid. More...
 
uint32 CalcHash () const
 Calculate the hash-sum value for the handle. More...
 
AMechanismGetMechanism () const
 Get the mechanism the subject is part of. More...
 
const FFingerprintGetFingerprint () const
 Get the current fingerprint of the subject. More...
 
bool Matches (const FFilter &InFilter) const
 Check if the subject matches a certain filter. More...
 
Validity
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...
 
Comparison
bool EqualsRaw (const FCommonSubjectHandle &InSubject) const
 Check if two subject handles are equal byte-wise. More...
 
bool Equals (const FCommonSubjectHandle &InSubjectHandle) const
 Check if the subject handle points to the same subject as the other one. More...
 
bool operator== (const FCommonSubjectHandle &InSubjectHandle) const
 Check if the subject handle points to the same subject as the other one. More...
 
bool operator!= (const FCommonSubjectHandle &InSubjectHandle) const
 Check if the subject handles point to different subjects. More...
 
Flagmark Examination
EFlagmark GetFlagmark () const
 Get the flagmark of the subject. More...
 
bool HasFlag (const EFlagmarkBit Flag) const
 Get the state of a certain flag of the subject. More...
 
Components Examination
bool HasTrait (UScriptStruct *const TraitType) const
 Check if the subject has a certain trait. More...
 
template<typename T >
std::enable_if< IsTraitType< T >(), bool >::type 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 D >
std::enable_if< IsDetailClass< D >(), bool >::type HasDetail () const
 Check if the subject has a certain detail. More...
 
Traits Getting
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 >
std::enable_if< IsTraitType< T >(), EApparatusStatus >::type GetTrait (T &OutTrait, const bool bTraitDataInitialized=true) const
 Get a trait from a subject by its type. More...
 
template<typename T >
std::enable_if< IsTraitType< T >(), T >::type GetTrait () const
 Get a trait copy from a subject by its type. More...
 
Common Networking
bool IsOnline () const
 Check if the subject currently networked. More...
 
uint32 GetNetworkId () const
 Get a unique network identifier of a subject (if any). More...
 
bool IsServerSide () const
 Check if this is a server-side version of the subject. More...
 
bool IsClientSide () const
 Check if this is a client-side version of the subject. More...
 
UNetConnection * GetConnectionPermit () const
 Get the server-side connection that is allowed to push to the server's version of the subject. More...
 
const FTraitmarkGetTraitmarkPermit () const
 Get the server-side list of traits allowed to be received from clients. More...
 
const FTraitmarkGetTraitmarkPass () const
 
Assignment
FCommonSubjectHandleoperator= (const FCommonSubjectHandle &InSubjectHandle)
 Assign to be a copy of an another subject handle. More...
 

Static Public Attributes

static const IdType InvalidId = FSubjectInfo::InvalidId
 Invalid subject identifier. More...
 
static const IdType FirstId = FSubjectInfo::FirstId
 A first valid subject identifier. More...
 
static const IdType IdMax = FSubjectInfo::IdMax
 The maximum valid subject identifier. More...
 
static const GenerationType FirstGeneration = FSubjectInfo::FirstGeneration
 The first valid generation. More...
 
static const GenerationType GenerationMax = FSubjectInfo::GenerationMax
 The maximum valid generation. More...
 
static const FCommonSubjectHandle Invalid
 An invalid common subject handle constant. 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...
 
FFingerprintGetFingerprintRef () const
 Get the current fingerprint's reference of the subject. More...
 
bool MarkBooted () const
 
UChunkGetChunk () const
 Get the current chunk of the subject. More...
 
ISubjectiveGetSubjective () const
 Get a subjective this handle is associated with (if any). More...
 
UDetailGetDetail (TSubclassOf< UDetail > DetailClass) const
 Get a detail of a certain class. More...
 
template<class D >
DGetDetail () const
 Get a detail of a certain class. More...
 
 FCommonSubjectHandle (const int32 InId, const GenerationType InGeneration)
 Initialize with explicit id and generation specifications. More...
 

Protected Attributes

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

Friends

template<typename ChunkItT , typename BeltItT , EParadigm Paradigm>
struct TChain
 
template<typename SubjectHandleT >
struct TChunkIt
 
template<typename SubjectHandleT >
struct TBeltIt
 
struct FSubjectInfo
 
struct FSubjectNetworkState
 
struct FSubjectHandle
 
struct FSolidSubjectHandle
 
struct FConstSubjectHandle
 
struct FUnsafeSubjectHandle
 
struct FChunkSlot
 
struct FSubjectRecord
 
class UChunk
 
class AMechanism
 
class UMachine
 
class ISubjective
 
class UNetworkBearerComponent
 
class ASubjectiveActor
 
class USubjectiveActorComponent
 

Detailed Description

The base structure for all subject handles.

Shouldn't really be used by the end-user of the framework.

The size of the handle should be exactly 64-bits and can be passed to functions by value.

Subject handles are not meant to be serialized.

See also
FSubjectHandle, FSolidSubjectHandle, FConstSubjectHandle

Member Typedef Documentation

◆ GenerationType

The type of the subject generation counter.

◆ IdType

The type of the unique subject identifier.

Constructor & Destructor Documentation

◆ FCommonSubjectHandle() [1/3]

FCommonSubjectHandle::FCommonSubjectHandle ( const int32  InId,
const GenerationType  InGeneration 
)
inlineprotected

Initialize with explicit id and generation specifications.

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

◆ FCommonSubjectHandle() [2/3]

FCommonSubjectHandle::FCommonSubjectHandle ( )
inline

Initialize an invalid (null) handle.

◆ FCommonSubjectHandle() [3/3]

FCommonSubjectHandle::FCommonSubjectHandle ( const FCommonSubjectHandle InSubjectHandle)
inline

Initialize as a copy of an another subject handle.

Parameters
InSubjectHandleThe subject handle to copy.

Member Function Documentation

◆ CalcHash()

uint32 FCommonSubjectHandle::CalcHash ( ) const

Calculate the hash-sum value for the handle.

◆ Equals()

bool FCommonSubjectHandle::Equals ( const FCommonSubjectHandle InSubjectHandle) const
inline

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

If both handles are invalid, returns true

Parameters
InSubjectHandleA subject handle to compare with.
Returns
true if the handles point to the same subject or both are invalid.
false if the handles point to different subjects or one is invalid.

◆ EqualsRaw()

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

Check if two subject handles are equal byte-wise.

◆ FindInfo()

FSubjectInfo * FCommonSubjectHandle::FindInfo ( ) const
protected

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 * FCommonSubjectHandle::GetChunk ( ) const
protected

Get the current chunk of the subject.

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

◆ GetConnectionPermit()

UNetConnection * FCommonSubjectHandle::GetConnectionPermit ( ) const

Get the server-side connection that is allowed to push to the server's version of the subject.

Can only be queried from a server-side subject.

See also
SetConnectionPermit()

◆ GetDetail() [1/2]

template<class D >
D * FCommonSubjectHandle::GetDetail ( ) const
protected

Get a detail of a certain class.

Templated version.

The method is protected since the child classes have to provide the exact return value semantics.

Template Parameters
DThe class of the detail to get.
Returns
A pointer to the detail of the designated class.
nullptr If there is no such detail.

◆ GetDetail() [2/2]

UDetail * FCommonSubjectHandle::GetDetail ( TSubclassOf< UDetail DetailClass) const
protected

Get a detail of a certain class.

The method is protected since the child classes have to provide the exact return value semantics.

Parameters
DetailClassThe class of the detail to get.
Returns
A pointer to the detail of the designated class.
nullptr If there is no such detail.

◆ GetFingerprint()

const FFingerprint & FCommonSubjectHandle::GetFingerprint ( ) const

Get the current fingerprint of the subject.

◆ GetFingerprintRef()

FFingerprint & FCommonSubjectHandle::GetFingerprintRef ( ) const
protected

Get the current fingerprint's reference of the subject.

◆ GetFlagmark()

EFlagmark FCommonSubjectHandle::GetFlagmark ( ) const
inline

Get the flagmark of the subject.

◆ GetGeneration()

GenerationType FCommonSubjectHandle::GetGeneration ( ) const
inline

Get the current generation of the subject.

Each unique instance of a subject has a unique combination of its generation and identifier.

See also
GetId()

◆ GetId()

IdType FCommonSubjectHandle::GetId ( ) const
inline

Get the unique identifier of the subject.

The identifier is unique along the lifetime of the subject. It gets reused (under a different generation) after the subject is despawned.

You can use the identifier for the purpose of ordering.

See also
GetGeneration()

◆ GetInfo()

FSubjectInfo & FCommonSubjectHandle::GetInfo ( ) const
protected

Get the subject info record associated with it.

◆ GetMechanism()

AMechanism * FCommonSubjectHandle::GetMechanism ( ) const

Get the mechanism the subject is part of.

Returns
The mechanism the subject resides within.
nullptr If the mechanism is invalid.

◆ GetNetworkId()

uint32 FCommonSubjectHandle::GetNetworkId ( ) const

Get a unique network identifier of a subject (if any).

This unique identifier clearly and unequivocally identifies a subject within multiple peers (client(s) and server) and is used internally to address the subject in the networking environment.

Returns
The unique cross-peer identifier of the subject or FSubjectNetworkState::InvalidId, if the subject is not online just yet.
See also
IsOnline() BringOnline()

◆ GetSubjective()

ISubjective * FCommonSubjectHandle::GetSubjective ( ) const
protected

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

Subjectives are high-level UObject-compatible entities. The method is non-public, cause a cast to a specific version is actually in the child struct.

The method is private, cause the exact subjective pointer type has to be cast to.

◆ GetTrait() [1/3]

template<typename T >
std::enable_if< IsTraitType< T >(), T >::type FCommonSubjectHandle::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 >
std::enable_if< IsTraitType< T >(), EApparatusStatus >::type FCommonSubjectHandle::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.
EApparatusStatus::NotFound If there is no such trait in the subject.

◆ GetTrait() [3/3]

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

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.

◆ GetTraitmarkPass()

const FTraitmark & FCommonSubjectHandle::GetTraitmarkPass ( ) const
inline

◆ GetTraitmarkPermit()

const FTraitmark & FCommonSubjectHandle::GetTraitmarkPermit ( ) const

Get the server-side list of traits allowed to be received from clients.

Can only be queried from a server-side subject.

See also
SetTraitmarkPermit()

◆ HasDetail() [1/2]

template<typename D >
std::enable_if< IsDetailClass< D >(), bool >::type FCommonSubjectHandle::HasDetail ( ) const
inline

Check if the subject has a certain detail.

Templated version.

◆ HasDetail() [2/2]

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

Check if the subject has a certain detail.

◆ HasFlag()

bool FCommonSubjectHandle::HasFlag ( const EFlagmarkBit  Flag) const
inline

Get the state of a certain flag of the subject.

Always returns false for invalid subject handles.

Parameters
FlagThe flag to examine.
Returns
The state of the flag.

◆ HasTrait() [1/2]

template<typename T >
std::enable_if< IsTraitType< T >(), bool >::type FCommonSubjectHandle::HasTrait ( ) const
inline

Check if the subject has a certain trait.

Templated version.

◆ HasTrait() [2/2]

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

Check if the subject has a certain trait.

◆ IsClientSide()

bool FCommonSubjectHandle::IsClientSide ( ) const

Check if this is a client-side version of the subject.

A subject must be both online and be part of a client world's mechanism in order to be considered client-side.

See also
IsOnline() IsServerSide()

◆ IsOnline()

bool FCommonSubjectHandle::IsOnline ( ) const

Check if the subject currently networked.

Networked subject can receive and push traits over the network to the remote versions of themselves.

See also
GetNetworkId() BringOnline()

◆ IsServerSide()

bool FCommonSubjectHandle::IsServerSide ( ) const

Check if this is a server-side version of the subject.

A subject must be both online and be part of a server world's mechanism in order to be considered server-side.

See also
IsOnline() IsClientSide()

◆ IsSolid()

bool FCommonSubjectHandle::IsSolid ( ) const
inline

Check if the subject is currently solid.

The subject is solid if it's part of a solid mechanism.

Invalid subject handles will return false here.

◆ IsValid()

bool FCommonSubjectHandle::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()

bool FCommonSubjectHandle::MarkBooted ( ) const
protected

◆ Matches()

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

Check if the subject matches a certain filter.

◆ operator bool()

FCommonSubjectHandle::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 FCommonSubjectHandle::operator!= ( const FCommonSubjectHandle InSubjectHandle) const
inline

Check if the subject handles point to different subjects.

Two invalid subject handles are considered to be the same and this operator would return false.

Parameters
InSubjectHandleA subject handle to compare with.
Returns
true if the handles point to different subjects or one is invalid.
false if the handles point to the same subject or both are invalid.

◆ operator!=() [2/2]

bool FCommonSubjectHandle::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=() [1/2]

FCommonSubjectHandle & FCommonSubjectHandle::operator= ( const FCommonSubjectHandle InSubjectHandle)
inline

Assign to be a copy of an another subject handle.

Parameters
InSubjectHandleThe subject handle to copy.

◆ operator=() [2/2]

FCommonSubjectHandle & FCommonSubjectHandle::operator= ( TYPE_OF_NULLPTR  )
inline

Clear the subject handle, essentially making it invalid.

◆ operator==() [1/2]

bool FCommonSubjectHandle::operator== ( const FCommonSubjectHandle InSubjectHandle) const
inline

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

If both handles are invalid, returns true

Parameters
InSubjectHandleA subject handle to compare with.
Returns
true if the handles point to the same subject or both are invalid.
false if the handles point to different subjects or one is invalid.

◆ operator==() [2/2]

bool FCommonSubjectHandle::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.

◆ ResetHandle()

void FCommonSubjectHandle::ResetHandle ( )
inline

Reset the subject handle.

Only the handle itself is reset. The referenced subject (if any) will remain intact.

Friends And Related Function Documentation

◆ AMechanism

friend class AMechanism
friend

◆ ASubjectiveActor

friend class ASubjectiveActor
friend

◆ FChunkSlot

friend struct FChunkSlot
friend

◆ FConstSubjectHandle

friend struct FConstSubjectHandle
friend

◆ FSolidSubjectHandle

friend struct FSolidSubjectHandle
friend

◆ FSubjectHandle

friend struct FSubjectHandle
friend

◆ FSubjectInfo

friend struct FSubjectInfo
friend

◆ FSubjectNetworkState

friend struct FSubjectNetworkState
friend

◆ FSubjectRecord

friend struct FSubjectRecord
friend

◆ FUnsafeSubjectHandle

friend struct FUnsafeSubjectHandle
friend

◆ ISubjective

friend class ISubjective
friend

◆ TBeltIt

template<typename SubjectHandleT >
friend struct TBeltIt
friend

◆ TChain

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

◆ TChunkIt

template<typename SubjectHandleT >
friend struct TChunkIt
friend

◆ UChunk

friend class UChunk
friend

◆ UMachine

friend class UMachine
friend

◆ UNetworkBearerComponent

friend class UNetworkBearerComponent
friend

◆ USubjectiveActorComponent

friend class USubjectiveActorComponent
friend

Member Data Documentation

◆ FirstGeneration

const GenerationType FCommonSubjectHandle::FirstGeneration = FSubjectInfo::FirstGeneration
static

The first valid generation.

◆ FirstId

const IdType FCommonSubjectHandle::FirstId = FSubjectInfo::FirstId
static

A first valid subject identifier.

◆ Generation

uint32 FCommonSubjectHandle::Generation = FirstGeneration
protected

A unique generation of the subject.

Used to validate the subject against reused slots.

◆ GenerationMax

const GenerationType FCommonSubjectHandle::GenerationMax = FSubjectInfo::GenerationMax
static

The maximum valid generation.

◆ Id

int32 FCommonSubjectHandle::Id = InvalidId
protected

A unique identifier of the subject within the mechanism.

If this identifier is invalid, the handle is considered to be invalid.

◆ IdMax

const IdType FCommonSubjectHandle::IdMax = FSubjectInfo::IdMax
static

The maximum valid subject identifier.

◆ Invalid

const FCommonSubjectHandle FCommonSubjectHandle::Invalid
static

An invalid common subject handle constant.

◆ InvalidId

const IdType FCommonSubjectHandle::InvalidId = FSubjectInfo::InvalidId
static

Invalid subject identifier.


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