|
CeresEngine 0.2.0
A game development framework
|
Event accumulator class template. More...
#include <CeresEngine/Foundation/Event.hpp>
Public Types | |
| using | ResultType = decltype(std::declval< F >()(std::declval< T >(), std::declval< typename S::SlotType::result_type >())) |
| Result type when calling the accumulating function operator. | |
Public Member Functions | |
| EventAccumulator (S const &event, T init, F func) | |
| Construct a EventAccumulator as a proxy to a given event. | |
| ResultType | operator() (A &&... args) const |
| Function call operator. | |
Private Attributes | |
| S const & | event |
| Reference to the underlying event to proxy. | |
| T | init |
| Initial value of the accumulate algorithm. | |
| F | func |
| Accumulator function. | |
Event accumulator class template.
This acts sort of as a proxy for triggering a event and accumulating the slot return values.
This class is not really intended to instantiate by client code. Instances are acquired as return values of the method accumulate() called on events.
| S | Type of event. The EventAccumulator acts as a type of proxy for a event instance of this type. |
| T | Type of initial value of the accumulate algorithm. This type must meet the requirements of CopyAssignable and CopyConstructible |
| F | Type of accumulation function. |
| A | Argument types of the underlying event type. |
| using CeresEngine::EventAccumulator< S, T, F, A >::ResultType = decltype(std::declval<F>()(std::declval<T>(), std::declval<typename S::SlotType::result_type>())) |
Result type when calling the accumulating function operator.
|
inline |
Construct a EventAccumulator as a proxy to a given event.
| event | Event instance. |
| init | Initial value of the accumulate algorithm. |
| func | Binary operation function object that will be applied to all slot return values. The signature of the function should be equivalent of the following: R func( T1 const& a, T2 const& b )
|
|
inline |
Function call operator.
Calling this will trigger the underlying event and accumulate all of the connected slots return values with the current initial value and accumulator function.
When called, this will invoke the accumulator function will be called for each return value of the slots. The semantics are similar to the std::accumulate algorithm.
| args | Arguments to propagate to the slots of the underlying when triggering the event. |
Reference to the underlying event to proxy.
Initial value of the accumulate algorithm.