CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::EventAccumulator< S, T, F, A > Class Template Referencefinal

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 constevent
 Reference to the underlying event to proxy.
 
T init
 Initial value of the accumulate algorithm.
 
F func
 Accumulator function.
 

Detailed Description

template<typename S, typename T, typename F, typename... A>
class CeresEngine::EventAccumulator< S, T, F, A >

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.

Template Parameters
SType of event. The EventAccumulator acts as a type of proxy for a event instance of this type.
TType of initial value of the accumulate algorithm. This type must meet the requirements of CopyAssignable and CopyConstructible
FType of accumulation function.
AArgument types of the underlying event type.

Member Typedef Documentation

◆ ResultType

template<typename S , typename T , typename F , typename... A>
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.

Constructor & Destructor Documentation

◆ EventAccumulator()

template<typename S , typename T , typename F , typename... A>
CeresEngine::EventAccumulator< S, T, F, A >::EventAccumulator ( S const event,
T  init,
F  func 
)
inline

Construct a EventAccumulator as a proxy to a given event.

Parameters
eventEvent instance.
initInitial value of the accumulate algorithm.
funcBinary 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 )
  • The signature does not need to have const&.
  • The initial value, type T, must be implicitly convertible to R
  • The return type R must be implicitly convertible to type T1.
  • The type R must be CopyAssignable.
  • The type S::SlotType::result_type (return type of the events slots) must be implicitly convertible to type T2.

Member Function Documentation

◆ operator()()

template<typename S , typename T , typename F , typename... A>
ResultType CeresEngine::EventAccumulator< S, T, F, A >::operator() ( A &&...  args) const
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.

Parameters
argsArguments to propagate to the slots of the underlying when triggering the event.

Member Data Documentation

◆ event

template<typename S , typename T , typename F , typename... A>
S const& CeresEngine::EventAccumulator< S, T, F, A >::event
private

Reference to the underlying event to proxy.

◆ func

template<typename S , typename T , typename F , typename... A>
F CeresEngine::EventAccumulator< S, T, F, A >::func
private

Accumulator function.

◆ init

template<typename S , typename T , typename F , typename... A>
T CeresEngine::EventAccumulator< S, T, F, A >::init
private

Initial value of the accumulate algorithm.


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