Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TAttribute< ObjectType > Class Template Reference

#include <Attribute.h>

Public Member Functions

 DECLARE_DELEGATE_RetVal (ObjectType, FGetter)
 
 TAttribute ()
 
template<typename OtherType >
 TAttribute (const OtherType &InInitialValue)
 
 TAttribute (ObjectType &&InInitialValue)
 
template<class SourceType >
 TAttribute (TSharedRef< SourceType > InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
 
template<class SourceType >
 TAttribute (SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
 
template<typename OtherType >
void Set (const OtherType &InNewValue)
 
void Set (ObjectType &&InNewValue)
 
bool IsSet () const
 
const ObjectTypeGet () const
 
const ObjectTypeGet (const ObjectType &DefaultValue) const
 
void Bind (const FGetter &InGetter)
 
void Bind (FGetter &&InGetter)
 
template<typename... VarTypes>
void BindStatic (TIdentity_T< typename FGetter::template TFuncPtr< VarTypes... > > InFuncPtr, VarTypes... Vars)
 
template<class SourceType >
void BindRaw (SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
 
template<class SourceType >
void Bind (TSharedRef< SourceType > InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
 
template<class SourceType >
void Bind (SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
 
template<class SourceType >
void BindUObject (SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
 
template<class SourceType >
void BindUFunction (SourceType *InUserObject, const FName &InFunctionName)
 
bool IsBound () const
 
UE_NODISCARD const FGetterGetBinding () const
 
UE_NODISCARD TVariant< ObjectType, FGetterSteal ()
 
bool IdenticalTo (const TAttribute &InOther) const
 

Static Public Member Functions

static UE_NODISCARD TAttribute Create (const FGetter &InGetter)
 
template<typename... VarTypes>
static UE_NODISCARD TAttribute CreateStatic (TIdentity_T< typename FGetter::template TFuncPtr< VarTypes... > > InFuncPtr, VarTypes... Vars)
 
template<typename FuncPtrType , typename... VarTypes>
static UE_NODISCARD TAttribute CreateStatic (FuncPtrType &&InFuncPtr, VarTypes... Vars)
 
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute CreateRaw (SourceType *InObject, ObjectType(SourceTypeOrBase::*InMethod)(PayloadTypes...), typename TDecay< PayloadTypes >::Type... InputPayload)
 
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute CreateRaw (const SourceType *InObject, ObjectType(SourceTypeOrBase::*InMethod)(PayloadTypes...) const, typename TDecay< PayloadTypes >::Type... InputPayload)
 
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute CreateSP (SourceType *InObject, ObjectType(SourceTypeOrBase::*InMethod)(PayloadTypes...), typename TDecay< PayloadTypes >::Type... InputPayload)
 
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute CreateSP (const SourceType *InObject, ObjectType(SourceTypeOrBase::*InMethod)(PayloadTypes...) const, typename TDecay< PayloadTypes >::Type... InputPayload)
 
template<typename LambdaType , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute CreateLambda (LambdaType &&InCallable, PayloadTypes &&... InputPayload)
 
template<class SourceType >
static UE_NODISCARD TAttribute< ObjectTypeCreate (SourceType *InUserObject, const FName &InFunctionName)
 
UE_NODISCARD static FORCEINLINE TAttribute< ObjectTypeCreate (TFunction< ObjectType(void)> &&InLambda)
 

Private Member Functions

 TAttribute (const FGetter &InGetter, bool bExplicitConstructor)
 

Private Attributes

ObjectType Value
 
bool bIsSet
 
FGetter Getter
 

Friends

template<class OtherType >
class TAttribute
 

Detailed Description

template<typename ObjectType>
class TAttribute< ObjectType >

Attribute object

Definition at line 16 of file Attribute.h.

Constructor & Destructor Documentation

◆ TAttribute() [1/6]

Default constructor.

Definition at line 32 of file Attribute.h.

◆ TAttribute() [2/6]

template<typename ObjectType >
template<typename OtherType >
TAttribute< ObjectType >::TAttribute ( const OtherType & InInitialValue)
inline

Construct implicitly from an initial value

Parameters
InInitialValueThe value for this attribute

Definition at line 45 of file Attribute.h.

◆ TAttribute() [3/6]

template<typename ObjectType >
TAttribute< ObjectType >::TAttribute ( ObjectType && InInitialValue)
inline

Construct implicitly from moving an initial value

Parameters
InInitialValue

Definition at line 57 of file Attribute.h.

◆ TAttribute() [4/6]

template<typename ObjectType >
template<class SourceType >
TAttribute< ObjectType >::TAttribute ( TSharedRef< SourceType > InUserObject,
typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr )
inline

Constructs by binding an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectShared Pointer to the instance of the class that contains the member function you want to bind. The attribute will only retain a weak pointer to this class.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Definition at line 73 of file Attribute.h.

◆ TAttribute() [5/6]

template<typename ObjectType >
template<class SourceType >
TAttribute< ObjectType >::TAttribute ( SourceType * InUserObject,
typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr )
inline

Constructs by binding an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectShared Pointer to the instance of the class that contains the member function you want to bind. The attribute will only retain a weak pointer to this class.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Definition at line 89 of file Attribute.h.

◆ TAttribute() [6/6]

template<typename ObjectType >
TAttribute< ObjectType >::TAttribute ( const FGetter & InGetter,
bool bExplicitConstructor )
inlineprivate

Special explicit constructor for TAttribute::Create()

Definition at line 443 of file Attribute.h.

Member Function Documentation

◆ Bind() [1/4]

template<typename ObjectType >
void TAttribute< ObjectType >::Bind ( const FGetter & InGetter)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InGetterThe delegate object with your function binding

Definition at line 274 of file Attribute.h.

◆ Bind() [2/4]

template<typename ObjectType >
void TAttribute< ObjectType >::Bind ( FGetter && InGetter)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InGetterThe delegate object with your function binding

Definition at line 288 of file Attribute.h.

◆ Bind() [3/4]

template<typename ObjectType >
template<class SourceType >
void TAttribute< ObjectType >::Bind ( SourceType * InUserObject,
typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr )
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectShared Pointer to the instance of the class that contains the member function you want to bind. The attribute will only retain a weak pointer to this class.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Definition at line 347 of file Attribute.h.

◆ Bind() [4/4]

template<typename ObjectType >
template<class SourceType >
void TAttribute< ObjectType >::Bind ( TSharedRef< SourceType > InUserObject,
typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr )
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectShared Pointer to the instance of the class that contains the member function you want to bind. The attribute will only retain a weak pointer to this class.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Definition at line 332 of file Attribute.h.

◆ BindRaw()

template<typename ObjectType >
template<class SourceType >
void TAttribute< ObjectType >::BindRaw ( SourceType * InUserObject,
typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr )
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectInstance of the class that contains the member function you want to bind.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Definition at line 317 of file Attribute.h.

◆ BindStatic()

template<typename ObjectType >
template<typename... VarTypes>
void TAttribute< ObjectType >::BindStatic ( TIdentity_T< typename FGetter::template TFuncPtr< VarTypes... > > InFuncPtr,
VarTypes... Vars )
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InFuncPtrFunction to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Definition at line 302 of file Attribute.h.

◆ BindUFunction()

template<typename ObjectType >
template<class SourceType >
void TAttribute< ObjectType >::BindUFunction ( SourceType * InUserObject,
const FName & InFunctionName )
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectInstance of the class that contains the member function you want to bind.
InFunctionNameMember function name to bind.

Definition at line 377 of file Attribute.h.

◆ BindUObject()

template<typename ObjectType >
template<class SourceType >
void TAttribute< ObjectType >::BindUObject ( SourceType * InUserObject,
typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr )
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectInstance of the class that contains the member function you want to bind.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Definition at line 362 of file Attribute.h.

◆ Create() [1/3]

template<typename ObjectType >
static UE_NODISCARD TAttribute TAttribute< ObjectType >::Create ( const FGetter & InGetter)
inlinestatic

Static: Creates an attribute that's pre-bound to the specified 'getter' delegate

Parameters
InGetterDelegate to bind

Definition at line 101 of file Attribute.h.

◆ Create() [2/3]

template<typename ObjectType >
template<class SourceType >
static UE_NODISCARD TAttribute< ObjectType > TAttribute< ObjectType >::Create ( SourceType * InUserObject,
const FName & InFunctionName )
inlinestatic

Creates an attribute by binding an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectInstance of the class that contains the member function you want to bind.
InFunctionNameMember function name to bind.

Definition at line 192 of file Attribute.h.

◆ Create() [3/3]

Definition at line 199 of file Attribute.h.

◆ CreateLambda()

template<typename ObjectType >
template<typename LambdaType , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute TAttribute< ObjectType >::CreateLambda ( LambdaType && InCallable,
PayloadTypes &&... InputPayload )
inlinestatic

Helper function for creating TAttributes from a lambda TAttribute<float> FloatAttribute = TAttribute<float>::CreateLambda([]{ return 10.f; });

Definition at line 178 of file Attribute.h.

◆ CreateRaw() [1/2]

template<typename ObjectType >
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute TAttribute< ObjectType >::CreateRaw ( const SourceType * InObject,
ObjectType(SourceTypeOrBase::*)(PayloadTypes...) const InMethod,
typename TDecay< PayloadTypes >::Type... InputPayload )
inlinestatic

Helper function for creating TAttributes from a const member function pointer, accessed through a raw pointer

Definition at line 149 of file Attribute.h.

◆ CreateRaw() [2/2]

template<typename ObjectType >
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute TAttribute< ObjectType >::CreateRaw ( SourceType * InObject,
ObjectType(SourceTypeOrBase::*)(PayloadTypes...) InMethod,
typename TDecay< PayloadTypes >::Type... InputPayload )
inlinestatic

Helper function for creating TAttributes from a function pointer, accessed through a raw pointer

Definition at line 140 of file Attribute.h.

◆ CreateSP() [1/2]

template<typename ObjectType >
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute TAttribute< ObjectType >::CreateSP ( const SourceType * InObject,
ObjectType(SourceTypeOrBase::*)(PayloadTypes...) const InMethod,
typename TDecay< PayloadTypes >::Type... InputPayload )
inlinestatic

Helper function for creating TAttributes from a const member function pointer, accessed through a weak pointer to the shared object

Definition at line 168 of file Attribute.h.

◆ CreateSP() [2/2]

template<typename ObjectType >
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
UE_NODISCARD static FORCEINLINE TAttribute TAttribute< ObjectType >::CreateSP ( SourceType * InObject,
ObjectType(SourceTypeOrBase::*)(PayloadTypes...) InMethod,
typename TDecay< PayloadTypes >::Type... InputPayload )
inlinestatic

Helper function for creating TAttributes from a non-const member function pointer, accessed through a weak pointer to the shared object

Definition at line 159 of file Attribute.h.

◆ CreateStatic() [1/2]

template<typename ObjectType >
template<typename FuncPtrType , typename... VarTypes>
static UE_NODISCARD TAttribute TAttribute< ObjectType >::CreateStatic ( FuncPtrType && InFuncPtr,
VarTypes... Vars )
inlinestatic

Creates an attribute by binding an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InFuncPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Definition at line 129 of file Attribute.h.

◆ CreateStatic() [2/2]

template<typename ObjectType >
template<typename... VarTypes>
static UE_NODISCARD TAttribute TAttribute< ObjectType >::CreateStatic ( TIdentity_T< typename FGetter::template TFuncPtr< VarTypes... > > InFuncPtr,
VarTypes... Vars )
inlinestatic

Creates an attribute by binding an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InFuncPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Definition at line 115 of file Attribute.h.

◆ DECLARE_DELEGATE_RetVal()

template<typename ObjectType >
TAttribute< ObjectType >::DECLARE_DELEGATE_RetVal ( ObjectType ,
FGetter  )

Attribute 'getter' delegate

ObjectType GetValue() const

Returns
The attribute's value

◆ Get() [1/2]

template<typename ObjectType >
const ObjectType & TAttribute< ObjectType >::Get ( ) const
inline

Gets the attribute's current value. Assumes that the attribute is set.

Returns
The attribute's value

Definition at line 241 of file Attribute.h.

◆ Get() [2/2]

template<typename ObjectType >
const ObjectType & TAttribute< ObjectType >::Get ( const ObjectType & DefaultValue) const
inline

Gets the attribute's current value. The attribute may not be set, in which case use the default value provided. Shorthand for the boilerplate code: MyAttribute.IsSet() ? MyAttribute.Get() : DefaultValue

Definition at line 262 of file Attribute.h.

◆ GetBinding()

template<typename ObjectType >
UE_NODISCARD const FGetter & TAttribute< ObjectType >::GetBinding ( ) const
inline

Gets the attribute's 'getter' which can be bound or unbound

Returns
The attribute's FGetter.

Definition at line 398 of file Attribute.h.

◆ IdenticalTo()

template<typename ObjectType >
bool TAttribute< ObjectType >::IdenticalTo ( const TAttribute< ObjectType > & InOther) const
inline

Is this attribute identical to another TAttribute.

Parameters
InOtherThe other attribute to compare with.
Returns
true if the attributes are identical, false otherwise.

Definition at line 421 of file Attribute.h.

◆ IsBound()

template<typename ObjectType >
bool TAttribute< ObjectType >::IsBound ( ) const
inline

Checks to see if this attribute has a 'getter' function bound

Returns
True if attribute is bound to a getter function

Definition at line 388 of file Attribute.h.

◆ IsSet()

template<typename ObjectType >
bool TAttribute< ObjectType >::IsSet ( ) const
inline

Was this TAttribute ever assigned?

Definition at line 230 of file Attribute.h.

◆ Set() [1/2]

template<typename ObjectType >
template<typename OtherType >
void TAttribute< ObjectType >::Set ( const OtherType & InNewValue)
inline

Sets the attribute's value

Parameters
InNewValueThe value to set the attribute to

Definition at line 210 of file Attribute.h.

◆ Set() [2/2]

template<typename ObjectType >
void TAttribute< ObjectType >::Set ( ObjectType && InNewValue)
inline

Sets the attribute's value

Parameters
InNewValueThe value to set the attribute to

Definition at line 222 of file Attribute.h.

◆ Steal()

Move the attribute's 'getter' or the attribute's Value and reset the attribute. The attribute needs to be set.

Returns
The attribute's FGetter or Value

Definition at line 408 of file Attribute.h.

Friends And Related Symbol Documentation

◆ TAttribute

template<typename ObjectType >
template<class OtherType >
friend class TAttribute
friend

Definition at line 450 of file Attribute.h.

Member Data Documentation

◆ bIsSet

template<typename ObjectType >
bool TAttribute< ObjectType >::bIsSet
private

true when this attribute was explicitly set by a consumer, false when the attribute's value is set to the default

Definition at line 456 of file Attribute.h.

◆ Getter

template<typename ObjectType >
FGetter TAttribute< ObjectType >::Getter
private

Bound member function for this attribute (may be NULL if no function is bound.) When set, all attempts to read the attribute's value will instead call this delegate to generate the value. Our attribute's 'getter' delegate

Definition at line 461 of file Attribute.h.

◆ Value

template<typename ObjectType >
ObjectType TAttribute< ObjectType >::Value
mutableprivate

Current value. Mutable so that we can cache the value locally when using a bound Getter (allows const ref return value.)

Definition at line 453 of file Attribute.h.


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