Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::EBusReduceResult< T, Aggregator > Struct Template Reference

#include <Results.h>

Public Member Functions

 EBusReduceResult ()
 
 EBusReduceResult (const T &initialValue, const Aggregator &aggregator=Aggregator())
 
void operator= (const T &rhs)
 
void operator= (T &&rhs)
 
EBusReduceResultoperator= (const EBusReduceResult &)=delete
 

Public Attributes

value
 
Aggregator unary
 

Detailed Description

template<class T, class Aggregator>
struct AZ::EBusReduceResult< T, Aggregator >

Aggregates results returned by all handlers of an EBus event. You can use this structure to add results, apply a logical AND to results, and so on.

Template Parameters
TThe output type of the aggregator.
AggregatorA function object that aggregates results. The return type must match T. For examples of function objects that you can use as aggregators, see functional_basic.h.

The following example sums the values returned by all handlers.

MyBus::BroadcastResult(result, &MyBus::Events::GetANumber);
AZ_Printf("%d", result.value);
Definition: Results.h:51

The following example determines whether all handlers, including the latest handler, return true.

MyBus::BroadcastResult(result, &MyBus::Events::IsDoneDoingThing);
// result.value is now only true if all handlers returned true.
AZ_Printf("%s", result.value ? "true" : "false");

Constructor & Destructor Documentation

◆ EBusReduceResult() [1/2]

template<class T , class Aggregator >
AZ::EBusReduceResult< T, Aggregator >::EBusReduceResult ( )
inline

Creates an instance of the class without setting an initial value or a function object to use as the aggregator.

◆ EBusReduceResult() [2/2]

template<class T , class Aggregator >
AZ::EBusReduceResult< T, Aggregator >::EBusReduceResult ( const T &  initialValue,
const Aggregator &  aggregator = Aggregator() 
)
inline

Creates an instance of the class and sets the initial value and the function object to use as the aggregator.

Parameters
initialValueThe initial value, which new values will be aggregated with.
aggregatorA function object to aggregate the values. For examples of function objects that you can use as aggregators, see functional_basic.h.

Member Function Documentation

◆ operator=() [1/3]

template<class T , class Aggregator >
EBusReduceResult & AZ::EBusReduceResult< T, Aggregator >::operator= ( const EBusReduceResult< T, Aggregator > &  )
delete

Disallows copying an EBusReduceResult object by reference.

◆ operator=() [2/3]

template<class T , class Aggregator >
void AZ::EBusReduceResult< T, Aggregator >::operator= ( const T &  rhs)
inline

Overloads the assignment operator to aggregate a new value with the existing aggregated value. Used ONLY when the return value of the function is const, or const&

◆ operator=() [3/3]

template<class T , class Aggregator >
void AZ::EBusReduceResult< T, Aggregator >::operator= ( T &&  rhs)
inline

Overloads the assignment operator to aggregate a new value with the existing aggregated value using rvalue-ref to move

Member Data Documentation

◆ unary

template<class T , class Aggregator >
Aggregator AZ::EBusReduceResult< T, Aggregator >::unary

The function object that aggregates a new value with an existing value.

◆ value

template<class T , class Aggregator >
T AZ::EBusReduceResult< T, Aggregator >::value

The current value, which new values will be aggregated with.


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