5#ifndef MOLYBDEN_DELEGATE_HPP
6#define MOLYBDEN_DELEGATE_HPP
29template <
typename Args,
typename Action>
62 std::mutex callback_mutex_;
63 std::function<Signature> callback_;
65 void operator()(
const Args& args,
Action action);
67 friend class ObservableOwner;
70template <
typename Args,
typename Action>
72 std::function<Signature> callback) {
73 std::lock_guard<std::mutex> guard(callback_mutex_);
78template <
typename Args,
typename Action>
80 std::lock_guard<std::mutex> guard(callback_mutex_);
82 callback_(args, std::move(action));
86template <
typename Args,
typename Action>
88 std::lock_guard<std::mutex> guard(callback_mutex_);
The base API that implements classes which represent delegate's action.
Definition delegate_action.hpp:18
Delegates allow you to make decisions that affect the application behavior.
Definition delegate.hpp:30
void reset()
Resets the callback registered for this delegate.
Definition delegate.hpp:87
Delegate & operator=(std::function< Signature > callback)
Registers a callback to be invoked by this delegate.
Definition delegate.hpp:71
void(const Args &args, Action action) Signature
The callback's signature.
Definition delegate.hpp:36