12 #include <unordered_map>
20 template <
typename TOwner,
typename TCallbacks,
typename TCallbackClientId =
void *>
27 template<
typename TMemberFunction,
typename... Arguments>
28 void notify (TMemberFunction
function,
const Arguments &... arguments);
31 template<
typename TMemberFunction,
typename... Arguments>
32 void callback (TMemberFunction
function, Arguments &&... arguments);
34 template <
typename TReturnType,
typename TMemberFunction,
typename... Arguments>
35 TReturnType
aggregate (TReturnType result,
const std::function<TReturnType (TReturnType, TReturnType)> &combine,
36 TMemberFunction
function,
const Arguments &... arguments);
38 template<
typename TMemberFunction,
typename... Arguments>
39 bool queryUnanimousApproval (
bool default_result, TMemberFunction
function,
const Arguments &... arguments);
41 template<
typename TMemberFunction,
typename... Arguments>
42 bool queryAnyApproval (
bool default_result, TMemberFunction
function,
const Arguments &... arguments);
45 void subscribe (
const TCallbackClientId client_id,
const TCallbacks &handlers);
46 void unsubscribe (
const TCallbackClientId client_id);
A template class to manage callback, delegate and notification functions.
Definition: callback.h:21
TReturnType aggregate(TReturnType result, const std::function< TReturnType(TReturnType, TReturnType)> &combine, TMemberFunction function, const Arguments &... arguments)
Invoke a delegate function and aggregate the results.
Definition: callbackimpl.h:56
std::unordered_map< TCallbackClientId, TCallbacks > registered_handlers
The list of subscribers to the callbacks.
Definition: callback.h:25
void callback(TMemberFunction function, Arguments &&... arguments)
Invoke a callback function.
Definition: callbackimpl.h:40
void notify(TMemberFunction function, const Arguments &... arguments)
Invoke a notification function.
Definition: callbackimpl.h:26
void unsubscribe(const TCallbackClientId client_id)
Remove registered callbacks, delegates, or notifications.
Definition: callbackimpl.h:108
bool queryAnyApproval(bool default_result, TMemberFunction function, const Arguments &... arguments)
Check for approval by any delegate.
Definition: callbackimpl.h:92
void subscribe(const TCallbackClientId client_id, const TCallbacks &handlers)
Register callback, delegate, or notification functions.
Definition: callbackimpl.h:101
friend TOwner
Definition: callback.h:22
bool queryUnanimousApproval(bool default_result, TMemberFunction function, const Arguments &... arguments)
Check for approval from all delegates.
Definition: callbackimpl.h:80