Menu
Lumberyard
C++ API Reference (Version 1.10)

AZ::EBusReduceResult< T, Aggregator > Struct Template Reference

Aggregates results returned by all handlers of an EBus event. More...

Public Member Functions

AZ_FORCE_INLINE EBusReduceResult ()
 Creates an instance of the class without setting an initial value or a function object to use as the aggregator. More...
 
AZ_FORCE_INLINE EBusReduceResult (const T &initialValue, const Aggregator &aggregator=Aggregator())
 Creates an instance of the class and sets the initial value and the function object to use as the aggregator. More...
 
AZ_FORCE_INLINE void operator= (const T &rhs)
 Overloads the assignment operator to aggregate a new value with the existing aggregated value. More...
 
AZ_FORCE_INLINE void operator= (T &rhs)
 Overloads the assignment operator to aggregate a new value with the existing aggregated value. More...
 

Public Attributes

value
 The current value, which new values will be aggregated with. More...
 
Aggregator unary
 The function object that aggregates a new value with an existing value. More...
 

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.

EBusReduceResult<int, AZStd::plus<int>> result(0);
MyBus::BroadcastResult(result, &MyBus::Events::GetANumber);
AZ_Printf("%d", result.value);

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

EBusReduceResult<bool, AZStd::logical_and<bool>> result(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_FORCE_INLINE 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_FORCE_INLINE 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/2]

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

Overloads the assignment operator to aggregate a new value with the existing aggregated value.

Parameters
rhsA reference to the value that will be aggregated with the existing aggregated value.

◆ operator=() [2/2]

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

Overloads the assignment operator to aggregate a new value with the existing aggregated value.

Parameters
rhsA reference to the value that will be aggregated with the existing aggregated value.

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:
  • C:/lumberyard-root/dev/Code/Framework/AzCore/AzCore/EBus/Results.h