MCRO
C++23 utilities for Unreal Engine.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
Mcro::Observable Namespace Reference

Namespaces

namespace  Detail
 

Data Structures

struct  FStatePolicy
 Flags expressing how TState should handle object comparison and lifespan. More...
 
struct  IState
 Public API and base class for TState which shouldn't concern with policy flags or thread safety. More...
 
struct  IStateTag
 
struct  TChangeData
 This struct holds the circumstances of the data change. It cannot be moved or copied and its lifespan is managed entirely by TState More...
 
struct  TState
 Storage wrapper for any value which state needs to be tracked or their change needs to be observed. By default, TState is not thread-safe unless EStatePolicy::ThreadSafe policy is active in DefaultPolicy. More...
 

Concepts

concept  CState
 Concept constraining given type to a state.
 
concept  CChangeNextOnlyListener
 Concept describing a function which can listen to changes to the current value of a TState only.
 
concept  CChangeNextPreviousListener
 Concept describing a function which can listen to changes to the current and the previous values of a TState.
 
concept  CChangeListener
 Concept describing a function which can be a change listener on a TState.
 

Typedefs

template<typename T >
using TStateRef = TSharedRef<IState<T>>
 Convenience alias for shared reference to a base type of TState. Use this in APIs which may modify or get the value of a state declared elsewhere.
 
template<typename T >
using TStatePtr = TSharedPtr<IState<T>>
 Convenience alias for shared pointer to a base type of TState. Use this in APIs which may modify or get the value of a state declared elsewhere.
 
template<typename T >
using TStateWeakPtr = TWeakPtr<IState<T>>
 Convenience alias for weak pointer to a base type of TState. Use this in APIs which may modify or get the value of a state declared elsewhere.
 
template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using TDeclareStateRef = TSharedRef<TState<T, DefaultPolicy>>
 Convenience alias for declaring a state as a shared reference. Use this only as object members.
 
template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using TDeclareStatePtr = TSharedPtr<TState<T, DefaultPolicy>>
 Convenience alias for declaring a state as a shared pointer. Use this only as object members.
 
template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using TDeclareStateTSRef = TSharedRef<TState<T, DefaultPolicy.With({.ThreadSafe = true})>>
 Convenience alias for declaring a thread-safe state as a shared reference. Use this only as object members.
 
template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using TDeclareStateTSPtr = TSharedPtr<TState<T, DefaultPolicy.With({.ThreadSafe = true})>>
 Convenience alias for declaring a thread-safe state as a shared pointer. Use this only as object members.
 
template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using TStateTS = TState<T, DefaultPolicy.With({.ThreadSafe = true})>
 Convenience alias for thread safe states.
 
using FBool = TState<bool>
 Convenience alias for boolean states.
 
using FBoolTS = TStateTS<bool>
 Convenience alias for thread-safe boolean states.
 

Functions

template<typename LeftValue , CWeaklyEqualityComparableWith< LeftValue > RightValue>
bool operator== (IState< LeftValue > const &left, IState< RightValue > const &right)
 
template<typename LeftValue , CPartiallyOrderedWith< LeftValue > RightValue>
bool operator<=> (IState< LeftValue > const &left, IState< RightValue > const &right)
 

Variables

template<typename T >
constexpr FStatePolicy StatePolicyFor
 
template<>
constexpr FStatePolicy StatePolicyFor< bool > = {.NotifyOnChangeOnly = true, .StorePrevious = false}
 

Typedef Documentation

◆ FBool

Convenience alias for boolean states.

Definition at line 187 of file Observable.Fwd.h.

◆ FBoolTS

Convenience alias for thread-safe boolean states.

Definition at line 190 of file Observable.Fwd.h.

◆ TDeclareStatePtr

template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using Mcro::Observable::TDeclareStatePtr = TSharedPtr<TState<T, DefaultPolicy>>

Convenience alias for declaring a state as a shared pointer. Use this only as object members.

Definition at line 143 of file Observable.Fwd.h.

◆ TDeclareStateRef

template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using Mcro::Observable::TDeclareStateRef = TSharedRef<TState<T, DefaultPolicy>>

Convenience alias for declaring a state as a shared reference. Use this only as object members.

Definition at line 139 of file Observable.Fwd.h.

◆ TDeclareStateTSPtr

template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using Mcro::Observable::TDeclareStateTSPtr = TSharedPtr<TState<T, DefaultPolicy.With({.ThreadSafe = true})>>

Convenience alias for declaring a thread-safe state as a shared pointer. Use this only as object members.

Definition at line 151 of file Observable.Fwd.h.

◆ TDeclareStateTSRef

template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using Mcro::Observable::TDeclareStateTSRef = TSharedRef<TState<T, DefaultPolicy.With({.ThreadSafe = true})>>

Convenience alias for declaring a thread-safe state as a shared reference. Use this only as object members.

Definition at line 147 of file Observable.Fwd.h.

◆ TStatePtr

template<typename T >
using Mcro::Observable::TStatePtr = TSharedPtr<IState<T>>

Convenience alias for shared pointer to a base type of TState. Use this in APIs which may modify or get the value of a state declared elsewhere.

Definition at line 127 of file Observable.Fwd.h.

◆ TStateRef

template<typename T >
using Mcro::Observable::TStateRef = TSharedRef<IState<T>>

Convenience alias for shared reference to a base type of TState. Use this in APIs which may modify or get the value of a state declared elsewhere.

Definition at line 119 of file Observable.Fwd.h.

◆ TStateTS

template<typename T , FStatePolicy DefaultPolicy = StatePolicyFor<T>>
using Mcro::Observable::TStateTS = TState<T, DefaultPolicy.With({.ThreadSafe = true})>

Convenience alias for thread safe states.

Definition at line 184 of file Observable.Fwd.h.

◆ TStateWeakPtr

template<typename T >
using Mcro::Observable::TStateWeakPtr = TWeakPtr<IState<T>>

Convenience alias for weak pointer to a base type of TState. Use this in APIs which may modify or get the value of a state declared elsewhere.

Definition at line 135 of file Observable.Fwd.h.

Function Documentation

◆ operator<=>()

template<typename LeftValue , CPartiallyOrderedWith< LeftValue > RightValue>
bool Mcro::Observable::operator<=> ( IState< LeftValue > const & left,
IState< RightValue > const & right )

Definition at line 404 of file Observable.h.

◆ operator==()

template<typename LeftValue , CWeaklyEqualityComparableWith< LeftValue > RightValue>
bool Mcro::Observable::operator== ( IState< LeftValue > const & left,
IState< RightValue > const & right )

Definition at line 398 of file Observable.h.

Variable Documentation

◆ StatePolicyFor

template<typename T >
FStatePolicy Mcro::Observable::StatePolicyFor
inlineconstexpr
Initial value:
=
CClass<T>
? CCoreEqualityComparable<T>
? FStatePolicy {.NotifyOnChangeOnly = true}
: FStatePolicy {.AlwaysNotify = true}
: FStatePolicy {.NotifyOnChangeOnly = true, .StorePrevious = true}
Flags expressing how TState should handle object comparison and lifespan.

Definition at line 94 of file Observable.Fwd.h.

◆ StatePolicyFor< bool >

template<>
FStatePolicy Mcro::Observable::StatePolicyFor< bool > = {.NotifyOnChangeOnly = true, .StorePrevious = false}
inlineconstexpr

Definition at line 102 of file Observable.Fwd.h.