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

The scoped Apparatus state manager. More...

#include <Mechanism.h>

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

Classes

struct  FDeferredsApplicator
 A safe applicator for the deferred changes (or deferreds). More...
 

Public Types

enum  { InvalidChainId = FChain::InvalidId , FirstChainId = FChain::FirstId }
 
typedef FSubjectInfo::IdType SubjectIdType
 The type for the unique subject identifiers. More...
 

Public Member Functions

const TSet< ISubjective * > & GetSubjectives () const
 All of the subjectives currently available and registered. More...
 
FAdjectiveInfoGetAdjective (const int32 Id)
 Get subject information by an identifier. More...
 
EApparatusStatus FindBeltsMatchingFingerprint (const struct FFingerprint &Fingerprint, TArray< UBelt * > &OutBelts)
 Get all of the belts matching a fingerprint. More...
 
EApparatusStatus BootAll ()
 Boot all of the halted subjectives currently present in the Mechanism. More...
 
template<typename IterableT , typename ChainT = FChain, typename FilterT = FFilter>
std::enable_if< std::is_base_of< FFilterIndicator, FilterT >::value, TSharedRef< ChainT > >::type EnchainIterables (const FilterT &Filter)
 Enchain multiple iterables with a filter. More...
 
template<typename ChainT = FChain, typename FilterT = FFilter>
TSharedRef< ChainT > Enchain (FilterT &&Filter)
 Enchain multiple iterable sequences based on a filter. More...
 
template<typename FilterT = FFilter, typename ... Ts>
std::enable_if< std::is_base_of< FFilterIndicator, FilterT >::value, void >::type Enchain (FilterT &&Filter, TArray< TChunkProxy< Ts... > > &OutChunkProxies, const bool bIncludeEmpty=false)
 Enchain the matching chunks into proxies. More...
 
template<typename FilterT = FFilter>
TSharedRef< FSolidChainEnchainSolid (FilterT &&Filter)
 Enchain multiple iterable sequences based on a filter, returning a solid chain. More...
 
template<bool bInSolidity, typename FilterT = FFilter>
std::conditional< bInSolidity, TSharedRef< FSolidChain >, TSharedRef< FChain > >::type EnchainWithSolidity (FilterT &&Filter)
 Enchain subjects using a specific solidity. More...
 
EApparatusStatus HandleDetailsChange (ISubjective *const Subjective)
 Handle the subjective change. More...
 
EApparatusStatus RegisterSubjective (ISubjective *const Subjective)
 Register a subjective within the mechanism. More...
 
EApparatusStatus UnregisterSubjective (ISubjective *const Subjective)
 Remove a subjective from the mechanism completely. More...
 
EApparatusStatus UnregisterAllSubjectives ()
 Unregister all of the currently registered subjectives. More...
 
template<typename ChainT = FChain>
TSharedRef< ChainT > ObtainChain (const int32 ChainId) const
 Obtain an embedded chain of a specific identifier. More...
 
template<typename ChainT = FChain>
TSharedRef< ChainT > ObtainChain () const
 Obtain an unused chain of a specific type. More...
 
EApparatusStatus RegisterMechanical (TScriptInterface< IMechanical > Mechanical)
 Register a mechanical within the mechanism. More...
 
EApparatusStatus UnregisterMechanical (TScriptInterface< IMechanical > Mechanical)
 Unregister a mechanical from the mechanism. More...
 
EApparatusStatus UnregisterAllMechanicals ()
 Unregister all of the currently registered mechanicals. More...
 
UChunkObtainChunk (const struct FTraitmark &Traitmark, EApparatusStatus &OutStatus, const int32 Capacity=32)
 Find existing or create a new chunk for a traitmark. More...
 
UChunkObtainChunk (const struct FTraitmark &Traitmark, const int32 Capacity=32)
 Find existing or create a new chunk for a traitmark. More...
 
EApparatusStatus DespawnAllSubjects ()
 Despawn all of the subjects currently available within the mechanism. More...
 
void Reset () override
 Reset the mechanism completely, unregistering all of the entities and despawning all of the subjects. More...
 
bool IsSolid () const
 Check if the mechanism is currently in the uniform mode preventing any structural changes to its subjects and subjectives. More...
 
bool IsLiquid () const
 Check if the mechanism is currently in the mutable mode allowing any structural changes to its subjects and subjectives. More...
 
void BeginDestroy () override
 Destroy the mechanism object. More...
 
Inspection
SubjectIdType SubjectsNum () const
 Get the current number of subjects residing within the mechanism. More...
 
int32 SubjectivesNum () const
 Get the current number of effective subjectives in the mechanism. More...
 
Concurrency
bool IsInConcurrentEnvironment () const
 Check if the mechanism is currently inside a multi-threaded context. More...
 
Spawning
EApparatusStatus SpawnSubject (FSubjectHandle &SubjectHandle, const FTraitmark &Traitmark, const EFlagmark Flagmark=FM_None)
 Spawn a new subject within the mechanism and a chunk of a specific traitmark. More...
 
EApparatusStatus SpawnSubject (FSubjectHandle &SubjectHandle, FTraitmark &&Traitmark, const EFlagmark Flagmark=FM_None)
 Spawn a new subject within the mechanism and a chunk of a specific traitmark. More...
 
EApparatusStatus SpawnSubject (FSubjectHandle &SubjectHandle, const EFlagmark Flagmark=FM_None)
 Spawn a new subject within the mechanism. More...
 
FSubjectHandle SpawnSubject (const FSubjectRecord &SubjectRecord, EApparatusStatus &OutStatus)
 Spawn a new subject within the mechanism based on a record. More...
 
FSubjectHandle SpawnSubject (FSubjectRecord &&SubjectRecord, EApparatusStatus &OutStatus)
 Spawn a new subject based on a packed subject data record. More...
 
FSubjectHandle SpawnSubject (FSubjectRecord &SubjectRecord, EApparatusStatus &OutStatus)
 Spawn a new subject based on a packed subject data record. More...
 
FSubjectHandle SpawnSubject (const FSubjectRecord &SubjectRecord)
 Spawn a new subject based on a packed subject data record. More...
 
FSubjectHandle SpawnSubject (FSubjectRecord &&SubjectRecord)
 Spawn a new subject based on a packed subject data record. More...
 
FSubjectHandle SpawnSubject (FSubjectRecord &SubjectRecord)
 Spawn a new subject based on a packed subject data record. More...
 
EApparatusStatus SpawnSubjectDeferred (const FSubjectRecord &SubjectRecord)
 Spawn a new subject based on a packed subject data record. More...
 
EApparatusStatus SpawnSubjectDeferred (FSubjectRecord &&SubjectRecord)
 Spawn a new subject based on a packed subject data record. More...
 
EApparatusStatus SpawnSubjectDeferred (FSubjectRecord &SubjectRecord)
 Spawn a new subject based on a packed subject data record. More...
 
FSubjectHandle SpawnSubject (const EFlagmark Flagmark=FM_None)
 Spawn a new subject within the mechanism, returning the handle to the caller. More...
 
template<typename ... Ts>
FSubjectHandle SpawnSubject (Ts &&... Traits)
 Spawn a new subject with traits, returning the handle. More...
 
template<typename ... Ts>
EApparatusStatus SpawnSubjectDeferred (Ts &&... Traits)
 Spawn a new subject with traits, returning the handle. More...
 
template<typename ... Ts>
FSubjectHandle SpawnSubject (Ts &&... Traits, const EFlagmark Flagmark)
 Spawn a new subject with traits, returning the handle. More...
 
template<typename ... Ts>
EApparatusStatus SpawnSubjectDeferred (Ts &&... Traits, const EFlagmark Flagmark)
 Spawn a new subject with traits, returning the handle. More...
 
FSubjectHandle SpawnSubject (UScriptStruct *const TraitType, void *const TraitData, const EFlagmark Flagmark=FM_None)
 Spawn a new subject with a typed trait data, returning the handle. More...
 
Deferreds
bool HasDeferreds () const
 Check if there are any deferreds queued. More...
 
EApparatusStatus ApplyDeferreds ()
 Apply all of the currently pending changes. More...
 
EApparatusStatus ApplyDeferreds (const EDeferred InFilter)
 Apply a certain kind of the currently pending changes. More...
 
template<typename ContainerT >
EApparatusStatus ApplyDeferreds (const ContainerT &InKinds)
 Apply a subset of the currently pending changes. More...
 
bool IsAutomaticDeferredsApplicationPossible () const
 Check if the automatic deferreds application is possible within the current context. More...
 
FDeferredsApplicator CreateDeferredsApplicator (const EDeferred InFilter=EDeferred::All)
 Create a new deferreds applicator. More...
 
Collecting
template<typename AllocatorT >
EApparatusStatus CollectSubjects (TArray< FSubjectHandle, AllocatorT > &OutSubjects, const FFilter &Filter=FFilter::Zero)
 Collect all of the subjects being part of the mechanism. More...
 
EApparatusStatus CollectSubjects (USubjectRecordCollection *const OutSubjects, const FFilter &Filter=FFilter::Zero, const EFlagmark FlagmarkMask=FM_AllUserLevel)
 Collect the subjects being part of the mechanism. More...
 
Operating
int32 OperatingsNum () const
 Get the current number of (concurrent) operatings on the chain. More...
 
void WaitForOperatingsCompletion () const
 Wait for all the current operatings to be completed. More...
 
template<typename ChainT = void, typename FilterT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type Operate (FilterT &&Filter, const MechanicT &Mechanic)
 Process the mechanism using a functor mechanic. More...
 
template<typename ChainT = void, typename FilterT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type Operate (FilterT &&Filter, MechanicT &Mechanic)
 Process the mechanism using a functor mechanic. More...
 
template<typename ChainT = void, typename FilterT = void, typename FunctionT = void>
std::enable_if< std::is_function< FunctionT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type Operate (FilterT &&Filter, FunctionT *const Mechanic)
 Process the chain using a free function mechanic. More...
 
template<typename ChainT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value, EApparatusStatus >::type Operate (const MechanicT &Mechanic)
 Process the mechanism using a functor mechanic. More...
 
template<typename ChainT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value, EApparatusStatus >::type Operate (MechanicT &Mechanic)
 Process the mechanism using a functor mechanic. More...
 
template<typename ChainT = void, typename FunctionT = void>
std::enable_if< std::is_function< FunctionT >::value, EApparatusStatus >::type Operate (FunctionT *const Mechanic)
 Process the chain using a free function mechanic. More...
 
template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename FilterT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type OperateConcurrently (FilterT &&Filter, const MechanicT &Mechanic, const int32 ThreadsCountMax, const int32 SlotsPerThreadMin=1, const bool bSync=true)
 Process the mechanism using a functor mechanic in a threaded manner. More...
 
template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename FilterT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type OperateConcurrently (FilterT &&Filter, MechanicT &Mechanic, const int32 ThreadsCountMax, const int32 SlotsPerThreadMin=1, const bool bSync=true)
 Process the mechanism using a functor mechanic in a threaded manner. More...
 
template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename FilterT = void, typename FunctionT = void>
std::enable_if< std::is_function< FunctionT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type OperateConcurrently (FilterT &&Filter, FunctionT *const Mechanic, const int32 ThreadsCountMax, const int32 SlotsPerThreadMin=1, const bool bSync=true)
 Process the chain using a free function mechanic in a parallel manner. More...
 
template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value, EApparatusStatus >::type OperateConcurrently (const MechanicT &Mechanic, const int32 ThreadsCountMax, const int32 SlotsPerThreadMin=1, const bool bSync=true)
 Process the mechanism using a functor mechanic in a threaded manner. More...
 
template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value, EApparatusStatus >::type OperateConcurrently (MechanicT &Mechanic, const int32 ThreadsCountMax, const int32 SlotsPerThreadMin=1, const bool bSync=true)
 Process the mechanism using a functor mechanic in a threaded manner. More...
 
template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename FunctionT = void>
std::enable_if< std::is_function< FunctionT >::value, EApparatusStatus >::type OperateConcurrently (FunctionT *const Mechanic, const int32 ThreadsCountMax, const int32 SlotsPerThreadMin=1, const bool bSync=true)
 Process the chain using a free function mechanic in a parallel manner. More...
 

Static Public Attributes

static constexpr SubjectIdType InvalidSubjectId = FSubjectInfo::InvalidId
 Invalid subject identifier. More...
 
static constexpr SubjectIdType FirstSubjectId = FSubjectInfo::FirstId
 A first valid subject identifier. More...
 
static constexpr SubjectIdType SubjectsCountMax = FSubjectInfo::CountMax
 The maximum number of subjects within the machine. More...
 
static constexpr SubjectIdType SubjectIdMax = FSubjectInfo::IdMax
 The maximum valid subject identifier. More...
 

Friends

struct FCommonChain
 
struct FSubjectNetworkState
 
class UNetworkBearerComponent
 
class UMachine
 
class IIterable
 
template<typename ChunkItT , typename BeltItT , EParadigm Paradigm>
struct TChain
 
class UBelt
 
class UChunk
 
class UApparatusFunctionLibrary
 
struct FSubjectInfo
 
struct FCommonSubjectHandle
 
template<typename SubjectHandleT >
struct TChunkIt
 
template<typename SubjectHandleT >
struct TBeltIt
 

Detailed Description

The scoped Apparatus state manager.

This consists of subjects, subjectives and the mechanicals in the current world.

An instance of mechanism is created automatically per each UWorld, when it's needed. You can also instantiate it manually or even place it on the map in the Editor.

Member Typedef Documentation

◆ SubjectIdType

The type for the unique subject identifiers.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
InvalidChainId 

Invalid chain identifier.

FirstChainId 

First valid chain identifier.

Member Function Documentation

◆ ApplyDeferreds() [1/3]

EApparatusStatus AMechanism::ApplyDeferreds ( )
inline

Apply all of the currently pending changes.

Returns
The status of the operation.
EApparatusStatus::Noop if nothing was actually changed.

◆ ApplyDeferreds() [2/3]

template<typename ContainerT >
EApparatusStatus AMechanism::ApplyDeferreds ( const ContainerT &  InKinds)
inline

Apply a subset of the currently pending changes.

Parameters
InKindsThe list of deferred changes to apply.
Returns
The status of the operation.
EApparatusStatus::Noop if nothing was actually changed.

◆ ApplyDeferreds() [3/3]

EApparatusStatus AMechanism::ApplyDeferreds ( const EDeferred  InFilter)
inline

Apply a certain kind of the currently pending changes.

Parameters
InFilterThe kind of deferreds to apply.
Returns
The status of the operation.
EApparatusStatus::Noop if nothing was actually changed.

◆ BeginDestroy()

void AMechanism::BeginDestroy ( )
override

Destroy the mechanism object.

This should happen when the mechanism is no longer needed.

◆ BootAll()

EApparatusStatus AMechanism::BootAll ( )
inline

Boot all of the halted subjectives currently present in the Mechanism.

◆ CollectSubjects() [1/2]

template<typename AllocatorT >
EApparatusStatus AMechanism::CollectSubjects ( TArray< FSubjectHandle, AllocatorT > &  OutSubjects,
const FFilter Filter = FFilter::Zero 
)

Collect all of the subjects being part of the mechanism.

Note
The operation is relatively slow and shouldn't be used during normal frame time. Enchaining/operating should be used instead.
Parameters
OutSubjectsThe array to store the subjects.
FilterThe filter used to match the collected subjects.
Returns
The status of the operation.
EApparatusStatus::Noop If there were no items collected.

◆ CollectSubjects() [2/2]

EApparatusStatus AMechanism::CollectSubjects ( USubjectRecordCollection *const  OutSubjects,
const FFilter Filter = FFilter::Zero,
const EFlagmark  FlagmarkMask = FM_AllUserLevel 
)

Collect the subjects being part of the mechanism.

Note
The operation is relatively slow and shouldn't be used during normal frame time. Enchaining/operating should be used instead.
Parameters
OutSubjectsThe collection to store the subjects within.
FilterThe filter used to match the collected subjects.
FlagmarkMaskThe mask for flags to capture. Only user-level flags are captured by default.
Returns
The status of the operation.
EApparatusStatus::Noop If there were no items collected.

◆ CreateDeferredsApplicator()

FDeferredsApplicator AMechanism::CreateDeferredsApplicator ( const EDeferred  InFilter = EDeferred::All)
inline

Create a new deferreds applicator.

Parameters
InFilterA filter to request an applicator under.
Returns
The resulting applicator.

◆ DespawnAllSubjects()

EApparatusStatus AMechanism::DespawnAllSubjects ( )

Despawn all of the subjects currently available within the mechanism.

Returns
The status of the operation.

◆ Enchain() [1/2]

template<typename ChainT = FChain, typename FilterT = FFilter>
TSharedRef< ChainT > AMechanism::Enchain ( FilterT &&  Filter)
inline

Enchain multiple iterable sequences based on a filter.

Parameters
FilterThe filter to enchain under.
Returns
The resulting chain.

◆ Enchain() [2/2]

template<typename FilterT = FFilter, typename ... Ts>
std::enable_if< std::is_base_of< FFilterIndicator, FilterT >::value, void >::type AMechanism::Enchain ( FilterT &&  Filter,
TArray< TChunkProxy< Ts... > > &  OutChunkProxies,
const bool  bIncludeEmpty = false 
)
inline

Enchain the matching chunks into proxies.

Template Parameters
FilterTThe type of filter to enchain with.
TsThe types of traits to proxy.
Parameters
FilterThe filter to enchain under.
OutChunkProxiesThe chunk proxies array to output to. Those will be the locking ones.
bIncludeEmptyShould empty chunks be included?

◆ EnchainIterables()

template<typename IterableT , typename ChainT = FChain, typename FilterT = FFilter>
std::enable_if< std::is_base_of< FFilterIndicator, FilterT >::value, TSharedRef< ChainT > >::type AMechanism::EnchainIterables ( const FilterT &  Filter)
inline

Enchain multiple iterables with a filter.

Template Parameters
IterableTThe type of iterable to enchain.
ChainTThe type of chain to enchain with.
Parameters
FilterThe filter to enchain with.
Returns
The resulting chain.

◆ EnchainSolid()

template<typename FilterT = FFilter>
TSharedRef< FSolidChain > AMechanism::EnchainSolid ( FilterT &&  Filter)
inline

Enchain multiple iterable sequences based on a filter, returning a solid chain.

Parameters
FilterThe filter to enchain under.
Returns
The resulting chain.

◆ EnchainWithSolidity()

template<bool bInSolidity, typename FilterT = FFilter>
std::conditional< bInSolidity, TSharedRef< FSolidChain >, TSharedRef< FChain > >::type AMechanism::EnchainWithSolidity ( FilterT &&  Filter)
inline

Enchain subjects using a specific solidity.

Template Parameters
bInSolidityThe solidity to enchain in.
FilterTThe type of the filter to enchain by.
Returns
The chain matching the solidity.

◆ FindBeltsMatchingFingerprint()

EApparatusStatus AMechanism::FindBeltsMatchingFingerprint ( const struct FFingerprint Fingerprint,
TArray< UBelt * > &  OutBelts 
)
inline

Get all of the belts matching a fingerprint.

◆ GetAdjective()

FAdjectiveInfo & AMechanism::GetAdjective ( const int32  Id)
inline

Get subject information by an identifier.

◆ GetSubjectives()

const TSet< ISubjective * > & AMechanism::GetSubjectives ( ) const
inline

All of the subjectives currently available and registered.

◆ HandleDetailsChange()

EApparatusStatus AMechanism::HandleDetailsChange ( ISubjective *const  Subjective)
inline

Handle the subjective change.

◆ HasDeferreds()

bool AMechanism::HasDeferreds ( ) const
inline

Check if there are any deferreds queued.

This operation is thread-safe and lock-free.

◆ IsAutomaticDeferredsApplicationPossible()

bool AMechanism::IsAutomaticDeferredsApplicationPossible ( ) const
inline

Check if the automatic deferreds application is possible within the current context.

◆ IsInConcurrentEnvironment()

bool AMechanism::IsInConcurrentEnvironment ( ) const
inline

Check if the mechanism is currently inside a multi-threaded context.

The value returned by this method is guaranteed not to change for the caller's environment, as long as the caller is part of the normal built-in iterating/operating flow.

Certain actions are performed differently when working among several threads.

Returns
true The mechanism is currently in the concurrent-executed environment.
false The single-threaded environment is taking place.

◆ IsLiquid()

bool AMechanism::IsLiquid ( ) const
inline

Check if the mechanism is currently in the mutable mode allowing any structural changes to its subjects and subjectives.

◆ IsSolid()

bool AMechanism::IsSolid ( ) const
inline

Check if the mechanism is currently in the uniform mode preventing any structural changes to its subjects and subjectives.

The mechanism is solid if it has any solid-locked iterables within itself.

Returns
The state of examination.

◆ ObtainChain() [1/2]

template<typename ChainT = FChain>
TSharedRef< ChainT > AMechanism::ObtainChain ( ) const
inline

Obtain an unused chain of a specific type.

◆ ObtainChain() [2/2]

template<typename ChainT = FChain>
TSharedRef< ChainT > AMechanism::ObtainChain ( const int32  ChainId) const
inline

Obtain an embedded chain of a specific identifier.

Parameters
ChainIdThe identifier of the chain to obtain.
Returns
The obtained chain reference.

◆ ObtainChunk() [1/2]

UChunk * AMechanism::ObtainChunk ( const struct FTraitmark Traitmark,
const int32  Capacity = 32 
)
inline

Find existing or create a new chunk for a traitmark.

Parameters
TraitmarkA traitmark to ensure for.
CapacityThe desired capacity of the chunk.
Returns
The resulting chunk.

◆ ObtainChunk() [2/2]

UChunk * AMechanism::ObtainChunk ( const struct FTraitmark Traitmark,
EApparatusStatus OutStatus,
const int32  Capacity = 32 
)
inline

Find existing or create a new chunk for a traitmark.

Parameters
TraitmarkA traitmark to ensure for.
OutStatusThe status of the operation.
CapacityThe desired capacity of the chunk.
Returns
The resulting chunk.

◆ Operate() [1/6]

template<typename ChainT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value, EApparatusStatus >::type AMechanism::Operate ( const MechanicT &  Mechanic)
inline

Process the mechanism using a functor mechanic.

Supports lambdas. Constant mechanic auto-filter version.

Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on functor argument types by default.
MechanicTThe type of the functor to operate on the enchained slots. Can be a lambda expression.
Parameters
MechanicThe functor mechanic to operate with. Can be a lambda expression.
Returns
The status of the operation.

◆ Operate() [2/6]

template<typename ChainT = void, typename FilterT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type AMechanism::Operate ( FilterT &&  Filter,
const MechanicT &  Mechanic 
)
inline

Process the mechanism using a functor mechanic.

Supports lambdas. Constant mechanic version.

Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on functor argument types by default.
FilterTThe type of filter that takes place.
MechanicTThe type of the functor to operate on the enchained slots. Can be a lambda expression.
Parameters
FilterThe filter to query with.
MechanicThe functor mechanic to operate with. Can be a lambda expression.
Returns
The status of the operation.

◆ Operate() [3/6]

template<typename ChainT = void, typename FilterT = void, typename FunctionT = void>
std::enable_if< std::is_function< FunctionT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type AMechanism::Operate ( FilterT &&  Filter,
FunctionT *const  Mechanic 
)
inline

Process the chain using a free function mechanic.

Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on function's argument types by default.
FilterTThe type of filter that takes place.
FunctionTThe type of the mechanic function to operate on the slots.
Parameters
FilterThe filter to query with.
MechanicThe mechanical function to operate with.

◆ Operate() [4/6]

template<typename ChainT = void, typename FilterT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type AMechanism::Operate ( FilterT &&  Filter,
MechanicT &  Mechanic 
)
inline

Process the mechanism using a functor mechanic.

Supports lambdas. Mutable mechanic version.

Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on functor argument types by default.
FilterTThe type of filter that takes place.
MechanicTThe type of the functor to operate on the enchained slots. Can be a lambda expression.
Parameters
FilterThe filter to query with.
MechanicThe functor mechanic to operate with. Can be a lambda expression.
Returns
The status of the operation.

◆ Operate() [5/6]

template<typename ChainT = void, typename FunctionT = void>
std::enable_if< std::is_function< FunctionT >::value, EApparatusStatus >::type AMechanism::Operate ( FunctionT *const  Mechanic)
inline

Process the chain using a free function mechanic.

Auto-filter version.

Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on function's argument types by default.
FunctionTThe type of the mechanic function to operate on the slots.
Parameters
MechanicThe mechanical function to operate with.

◆ Operate() [6/6]

template<typename ChainT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value, EApparatusStatus >::type AMechanism::Operate ( MechanicT &  Mechanic)
inline

Process the mechanism using a functor mechanic.

Supports lambdas. Mutable mechanic auto-filter version.

Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on functor argument types by default.
MechanicTThe type of the functor to operate on the enchained slots. Can be a lambda expression.
Parameters
MechanicThe functor mechanic to operate with. Can be a lambda expression.
Returns
The status of the operation.

◆ OperateConcurrently() [1/6]

template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value, EApparatusStatus >::type AMechanism::OperateConcurrently ( const MechanicT &  Mechanic,
const int32  ThreadsCountMax,
const int32  SlotsPerThreadMin = 1,
const bool  bSync = true 
)
inline

Process the mechanism using a functor mechanic in a threaded manner.

Supports lambdas. Constant mechanic auto-filter version.

Note
Only solid chains can be safely operated concurrently.
Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on functor's argument types by default.
ParadigmThe security paradigm to utilize.
MechanicTThe type of the functor to operate on the enchained slots. Can be a lambda expression.
Parameters
MechanicThe functor mechanic to operate with. Can be a lambda expression.
ThreadsCountMaxThe maximum number of threads to process with.
SlotsPerThreadMinThe minimum number of slots per thread to process.
bSyncShould the operation be synced within the current branch.
Returns
The status of the operation.

◆ OperateConcurrently() [2/6]

template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename FilterT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type AMechanism::OperateConcurrently ( FilterT &&  Filter,
const MechanicT &  Mechanic,
const int32  ThreadsCountMax,
const int32  SlotsPerThreadMin = 1,
const bool  bSync = true 
)
inline

Process the mechanism using a functor mechanic in a threaded manner.

Supports lambdas. Constant mechanic version.

Note
Only solid chains can be safely operated concurrently.
Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on functor's argument types by default.
ParadigmThe security paradigm to utilize.
FilterTThe type of filter to query with.
MechanicTThe type of the functor to operate on the enchained slots. Can be a lambda expression.
Parameters
FilterThe filter to query with.
MechanicThe functor mechanic to operate with. Can be a lambda expression.
ThreadsCountMaxThe maximum number of threads to process with.
SlotsPerThreadMinThe minimum number of slots per thread to process.
bSyncShould the operation be synced within the current branch.
Returns
The status of the operation.

◆ OperateConcurrently() [3/6]

template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename FilterT = void, typename FunctionT = void>
std::enable_if< std::is_function< FunctionT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type AMechanism::OperateConcurrently ( FilterT &&  Filter,
FunctionT *const  Mechanic,
const int32  ThreadsCountMax,
const int32  SlotsPerThreadMin = 1,
const bool  bSync = true 
)
inline

Process the chain using a free function mechanic in a parallel manner.

Note
Only solid chains can be safely operated concurrently.
Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on function's argument types by default.
ParadigmThe security paradigm to utilize.
FilterTThe type of filter to query with.
FunctionTThe type of the mechanic function to operate on the slots.
Parameters
FilterThe filter to query with.
MechanicThe mechanical function to operate with.
ThreadsCountMaxThe maximum number of threads to process with.
SlotsPerThreadMinThe minimum number of slots per thread to process.
bSyncShould the operation be synced within the current branch.
Returns
The status of the operation.

◆ OperateConcurrently() [4/6]

template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename FilterT = void, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value &&std::is_base_of< FFilterIndicator, FilterT >::value, EApparatusStatus >::type AMechanism::OperateConcurrently ( FilterT &&  Filter,
MechanicT &  Mechanic,
const int32  ThreadsCountMax,
const int32  SlotsPerThreadMin = 1,
const bool  bSync = true 
)
inline

Process the mechanism using a functor mechanic in a threaded manner.

Supports lambdas. Mutable mechanic version.

Note
Only solid chains can be safely operated concurrently.
Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on functor's argument types by default.
ParadigmThe security paradigm to utilize.
FilterTThe type of filter to query with.
MechanicTThe type of the functor to operate on the enchained slots. Can be a lambda expression.
Parameters
FilterThe filter to query with.
MechanicThe functor mechanic to operate with. Can be a lambda expression.
ThreadsCountMaxThe maximum number of threads to process with.
SlotsPerThreadMinThe minimum number of slots per thread to process.
bSyncShould the operation be synced within the current branch.
Returns
The status of the operation.

◆ OperateConcurrently() [5/6]

template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename FunctionT = void>
std::enable_if< std::is_function< FunctionT >::value, EApparatusStatus >::type AMechanism::OperateConcurrently ( FunctionT *const  Mechanic,
const int32  ThreadsCountMax,
const int32  SlotsPerThreadMin = 1,
const bool  bSync = true 
)
inline

Process the chain using a free function mechanic in a parallel manner.

Auto-filter version.

Note
Only solid chains can be safely operated concurrently.
Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on function's argument types by default.
ParadigmThe security paradigm to utilize.
FunctionTThe type of the mechanic function to operate on the slots.
Parameters
MechanicThe mechanical function to operate with.
ThreadsCountMaxThe maximum number of threads to process with.
SlotsPerThreadMinThe minimum number of slots per thread to process.
bSyncShould the operation be synced within the current branch.
Returns
The status of the operation.

◆ OperateConcurrently() [6/6]

template<typename ChainT = void, EParadigm Paradigm = EParadigm::None, typename MechanicT = void>
std::enable_if<!std::is_function< MechanicT >::value, EApparatusStatus >::type AMechanism::OperateConcurrently ( MechanicT &  Mechanic,
const int32  ThreadsCountMax,
const int32  SlotsPerThreadMin = 1,
const bool  bSync = true 
)
inline

Process the mechanism using a functor mechanic in a threaded manner.

Supports lambdas. Mutable mechanic auto-filter version.

Note
Only solid chains can be safely operated concurrently.
Template Parameters
ChainTThe type of chain to utilize. Detected automatically based on functor's argument types by default.
ParadigmThe security paradigm to utilize.
MechanicTThe type of the functor to operate on the enchained slots. Can be a lambda expression.
Parameters
MechanicThe functor mechanic to operate with. Can be a lambda expression.
ThreadsCountMaxThe maximum number of threads to process with.
SlotsPerThreadMinThe minimum number of slots per thread to process.
bSyncShould the operation be synced within the current branch.
Returns
The status of the operation.

◆ OperatingsNum()

int32 AMechanism::OperatingsNum ( ) const
inline

Get the current number of (concurrent) operatings on the chain.

This operation is thread-safe and can be used to sync in the remaining active operatings.

◆ RegisterMechanical()

EApparatusStatus AMechanism::RegisterMechanical ( TScriptInterface< IMechanical Mechanical)
inline

Register a mechanical within the mechanism.

Parameters
MechanicalA mechanical to register.
Returns
The status of the operation.

◆ RegisterSubjective()

EApparatusStatus AMechanism::RegisterSubjective ( ISubjective *const  Subjective)

Register a subjective within the mechanism.

Only an un-booted subjective can be registered.

Parameters
SubjectiveThe subjective to register within the mechanism.
Returns
The status of the operation.
EApparatusStatus::Noop If the subjective is already registered.

◆ Reset()

void AMechanism::Reset ( )
override

Reset the mechanism completely, unregistering all of the entities and despawning all of the subjects.

◆ SpawnSubject() [1/13]

FSubjectHandle AMechanism::SpawnSubject ( const EFlagmark  Flagmark = FM_None)
inline

Spawn a new subject within the mechanism, returning the handle to the caller.

Parameters
FlagmarkThe initial flagmark of the subject to spawn with.
Returns
A subject handle to initialize with the new entity.

◆ SpawnSubject() [2/13]

FSubjectHandle AMechanism::SpawnSubject ( const FSubjectRecord SubjectRecord)

Spawn a new subject based on a packed subject data record.

Parameters
SubjectRecordThe subject record to initialize a new subject with.
Returns
The handle for the newly created subject.

◆ SpawnSubject() [3/13]

FSubjectHandle AMechanism::SpawnSubject ( const FSubjectRecord SubjectRecord,
EApparatusStatus OutStatus 
)

Spawn a new subject within the mechanism based on a record.

Status version.

Parameters
SubjectRecordThe subject record to initialize a new subject with.
OutStatusThe status of the operation.

◆ SpawnSubject() [4/13]

EApparatusStatus AMechanism::SpawnSubject ( FSubjectHandle SubjectHandle,
const EFlagmark  Flagmark = FM_None 
)
inline

Spawn a new subject within the mechanism.

Parameters
SubjectHandleA subject handle to initialize with the new entity.
FlagmarkThe initial flagmark of the subject to spawn with.
Returns
The status of the operation.

◆ SpawnSubject() [5/13]

EApparatusStatus AMechanism::SpawnSubject ( FSubjectHandle SubjectHandle,
const FTraitmark Traitmark,
const EFlagmark  Flagmark = FM_None 
)
inline

Spawn a new subject within the mechanism and a chunk of a specific traitmark.

The chunk's slot will be initialized to a default trait state.

Parameters
SubjectHandleA subject handle to initialize with the new entity.
TraitmarkThe traitmark for the chunk to spawn within.
FlagmarkThe initial flagmark of the subject to spawn with. May not contain any of the system-level flags.
Returns
The status of the operation.

◆ SpawnSubject() [6/13]

EApparatusStatus AMechanism::SpawnSubject ( FSubjectHandle SubjectHandle,
FTraitmark &&  Traitmark,
const EFlagmark  Flagmark = FM_None 
)
inline

Spawn a new subject within the mechanism and a chunk of a specific traitmark.

R-value version.

Parameters
SubjectHandleA subject handle to initialize with the new entity.
TraitmarkThe traitmark for the chunk to spawn within.
FlagmarkThe initial flagmark of the subject to spawn with.
Returns
The status of the operation.

◆ SpawnSubject() [7/13]

FSubjectHandle AMechanism::SpawnSubject ( FSubjectRecord &&  SubjectRecord)
inline

Spawn a new subject based on a packed subject data record.

RValue refernce compatibility version.

Parameters
SubjectRecordThe subject record to initialize a new subject with.
Returns
The handle for the newly created subject.

◆ SpawnSubject() [8/13]

FSubjectHandle AMechanism::SpawnSubject ( FSubjectRecord &&  SubjectRecord,
EApparatusStatus OutStatus 
)
inline

Spawn a new subject based on a packed subject data record.

RValue refernce compatibility version with a status.

Parameters
SubjectRecordThe subject record to initialize a new subject with.
OutStatusThe status of the operation.
Returns
The handle for the newly created subject.

◆ SpawnSubject() [9/13]

FSubjectHandle AMechanism::SpawnSubject ( FSubjectRecord SubjectRecord)
inline

Spawn a new subject based on a packed subject data record.

Non-constant refernce compatibility version.

Parameters
SubjectRecordThe subject record to initialize a new subject with.
Returns
The handle for the newly created subject.

◆ SpawnSubject() [10/13]

FSubjectHandle AMechanism::SpawnSubject ( FSubjectRecord SubjectRecord,
EApparatusStatus OutStatus 
)
inline

Spawn a new subject based on a packed subject data record.

Non-constant compatibility version with a status.

Parameters
SubjectRecordThe subject record to initialize a new subject with.
OutStatusThe status of the operation.
Returns
The handle for the newly created subject.

◆ SpawnSubject() [11/13]

template<typename ... Ts>
FSubjectHandle AMechanism::SpawnSubject ( Ts &&...  Traits)
inline

Spawn a new subject with traits, returning the handle.

Template Parameters
TsThe types of traits to spawn with.
Parameters
TraitsThe traits to spawn with.
Returns
A handle for the newly spawned subject.

◆ SpawnSubject() [12/13]

template<typename ... Ts>
FSubjectHandle AMechanism::SpawnSubject ( Ts &&...  Traits,
const EFlagmark  Flagmark 
)
inline

Spawn a new subject with traits, returning the handle.

Template Parameters
TsThe types of traits to spawn with.
Parameters
TraitsThe traits to spawn with.
FlagmarkThe initial flagmark of the subject to spawn with.
Returns
A handle for the newly spawned subject.

◆ SpawnSubject() [13/13]

FSubjectHandle AMechanism::SpawnSubject ( UScriptStruct *const  TraitType,
void *const  TraitData,
const EFlagmark  Flagmark = FM_None 
)
inline

Spawn a new subject with a typed trait data, returning the handle.

Parameters
TraitTypeThe type of the trait to spawn with. Must not be a nullptr.
TraitDataThe data fo the trait to spawn with. Must not be a nullptr.
FlagmarkThe initial flagmark of the subject to spawn with.
Returns
A subject handle to initialize with the new entity.

◆ SpawnSubjectDeferred() [1/5]

EApparatusStatus AMechanism::SpawnSubjectDeferred ( const FSubjectRecord SubjectRecord)
inline

Spawn a new subject based on a packed subject data record.

Deferred version.

The actual entity creation is deferred until the deferreds are applied either automatically or manually.

Parameters
SubjectRecordThe subject record to initialize a new subject with.
Returns
The status of the operation.

◆ SpawnSubjectDeferred() [2/5]

EApparatusStatus AMechanism::SpawnSubjectDeferred ( FSubjectRecord &&  SubjectRecord)
inline

Spawn a new subject based on a packed subject data record.

Deferred version for RValue compatibility.

The actual entity creation is deferred until the deferreds are applied either automatically or manually.

Parameters
SubjectRecordThe subject record to initialize a new subject with.
Returns
The status of the operation.

◆ SpawnSubjectDeferred() [3/5]

EApparatusStatus AMechanism::SpawnSubjectDeferred ( FSubjectRecord SubjectRecord)
inline

Spawn a new subject based on a packed subject data record.

Deferred version for non-constant compatibility.

The actual entity creation is deferred until the deferreds are applied either automatically or manually.

Parameters
SubjectRecordThe subject record to initialize a new subject with.
Returns
The status of the operation.

◆ SpawnSubjectDeferred() [4/5]

template<typename ... Ts>
EApparatusStatus AMechanism::SpawnSubjectDeferred ( Ts &&...  Traits)
inline

Spawn a new subject with traits, returning the handle.

Deferred version.

Template Parameters
TsThe types of traits to spawn with.
Parameters
TraitsThe traits to spawn with.
Returns
The status of the operation.

◆ SpawnSubjectDeferred() [5/5]

template<typename ... Ts>
EApparatusStatus AMechanism::SpawnSubjectDeferred ( Ts &&...  Traits,
const EFlagmark  Flagmark 
)
inline

Spawn a new subject with traits, returning the handle.

Deferred version.

Template Parameters
TsThe types of traits to spawn with.
Parameters
TraitsThe traits to spawn with.
FlagmarkThe initial flagmark of the subject to spawn with.
Returns
The status of the operation.

◆ SubjectivesNum()

int32 AMechanism::SubjectivesNum ( ) const
inline

Get the current number of effective subjectives in the mechanism.

Returns
The number of subjectives in the mechanism.

◆ SubjectsNum()

SubjectIdType AMechanism::SubjectsNum ( ) const
inline

Get the current number of subjects residing within the mechanism.

Returns
The current number of subjects in the mechanism.

◆ UnregisterAllMechanicals()

EApparatusStatus AMechanism::UnregisterAllMechanicals ( )
inline

Unregister all of the currently registered mechanicals.

◆ UnregisterAllSubjectives()

EApparatusStatus AMechanism::UnregisterAllSubjectives ( )

Unregister all of the currently registered subjectives.

◆ UnregisterMechanical()

EApparatusStatus AMechanism::UnregisterMechanical ( TScriptInterface< IMechanical Mechanical)
inline

Unregister a mechanical from the mechanism.

Parameters
MechanicalA mechanical to unregister.
Returns
The status of the operation.

◆ UnregisterSubjective()

EApparatusStatus AMechanism::UnregisterSubjective ( ISubjective *const  Subjective)

Remove a subjective from the mechanism completely.

◆ WaitForOperatingsCompletion()

void AMechanism::WaitForOperatingsCompletion ( ) const
inline

Wait for all the current operatings to be completed.

You can use this method after you queued up the asynchronous operatings in order to sync them all.

Friends And Related Function Documentation

◆ FCommonChain

friend struct FCommonChain
friend

◆ FCommonSubjectHandle

friend struct FCommonSubjectHandle
friend

◆ FSubjectInfo

friend struct FSubjectInfo
friend

◆ FSubjectNetworkState

friend struct FSubjectNetworkState
friend

◆ IIterable

IIterable
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

◆ UApparatusFunctionLibrary

friend class UApparatusFunctionLibrary
friend

◆ UBelt

friend class UBelt
friend

◆ UChunk

friend class UChunk
friend

◆ UMachine

friend class UMachine
friend

◆ UNetworkBearerComponent

friend class UNetworkBearerComponent
friend

Member Data Documentation

◆ FirstSubjectId

constexpr SubjectIdType AMechanism::FirstSubjectId = FSubjectInfo::FirstId
staticconstexpr

A first valid subject identifier.

◆ InvalidSubjectId

constexpr SubjectIdType AMechanism::InvalidSubjectId = FSubjectInfo::InvalidId
staticconstexpr

Invalid subject identifier.

◆ SubjectIdMax

constexpr SubjectIdType AMechanism::SubjectIdMax = FSubjectInfo::IdMax
staticconstexpr

The maximum valid subject identifier.

◆ SubjectsCountMax

constexpr SubjectIdType AMechanism::SubjectsCountMax = FSubjectInfo::CountMax
staticconstexpr

The maximum number of subjects within the machine.


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