27 concept delegate_pipe_c = std::default_initializable<T> &&
requires(T t) {
28 { t | t } -> std::convertible_to<T>;
31 using delegate_token_type = time_ordered_priority_key;
65 template<
class signature_t>
82 template<
class derived_t,
class return_t,
class... args_t>
92 using function_type = std::function<return_t(args_t...)>;
95 using single_value_type = std::pair<time_ordered_priority_key, function_type>;
96 using container_type = std::map<time_ordered_priority_key, function_type>;
97 using variant_type = std::variant<single_value_type, container_type>;
98 using data_type = std::optional<variant_type>;
110 template<
class... creation_args_t>
124 template<callable_c<return_t, args_t...> callable_t>
139 template<
class object_t>
142 return_t (object_t::*pMethod)(args_t...),
143 priority ePriority = priority::normal) noexcept;
153 template<callable_c<return_t, args_t...> callable_t>
156 priority ePriority = priority::normal) noexcept;
167 template<
class object_t>
170 return_t (object_t::*pMethod)(args_t...),
171 priority ePriority = priority::normal) noexcept;
183 template<
class object_t, callable_c<return_t, args_t...> callable_t>
185 std::weak_ptr<object_t> pWeakObject,
187 priority ePriority = priority::normal) noexcept;
198 template<
class object_t>
200 std::weak_ptr<object_t> pWeakObject,
201 return_t (object_t::*pMethod)(args_t...),
202 priority ePriority = priority::normal) noexcept;
214 void clear() noexcept;
220 size_t size()
const noexcept;
226 bool empty()
const noexcept;
237 template<
class invoke_single_t,
class invoke_multiple_t>
238 return_t
execute_internal(
const invoke_single_t& invokeSingle,
const invoke_multiple_t& invokeMultiple)
265 template<
class object_t, callable_c<return_t, object_t*, args_t...> callable_t>
269 data_type m_optFunctions;
272 std::shared_ptr<bool> m_pDelegateAliveMarker;
278 template<
class return_t,
class... args_t>
279 requires(
sizeof...(args_t) > 0 && (!std::is_void_v<args_t> && ...))
280 class
delegate<return_t(args_t...)> final
281 : public details::base_delegate<
delegate<return_t(args_t...)>, return_t, args_t...>
291 return_t execute(args_t... args)
const noexcept;
295 template<
class return_t>
310 #include <qx/patterns/delegate.inl>
return_t execute() const noexcept
Execute all the callables the delegate has.
Single or multicast delegate.
Class for RAII: functor passed in constructor will be called in destructor.
delegate_token_type add_weak(std::weak_ptr< object_t > pWeakObject, callable_t callable, priority ePriority=priority::normal) noexcept
Add a callable that will be executed only if the appropriate weak object is valid.
return_t execute_internal(const invoke_single_t &invokeSingle, const invoke_multiple_t &invokeMultiple) const noexcept
Execute all callables.
void clear() noexcept
Clear all the callables in this delegate.
destruction_callback add_destruction_callback(callable_t callable, priority ePriority=priority::normal) noexcept
Add a callable that will be removed from the delegate when its destruction callback is destroyed.
bool empty() const noexcept
Check if this delegate is empty.
size_t size() const noexcept
Get the number of functions bound to this delegate.
static derived_t create_singlecast(creation_args_t... args) noexcept
Create a singlecast delegate.
bool remove(delegate_token_type token) noexcept
Remove a callable using its token.
delegate_token_type add_token(callable_t callable, priority ePriority=priority::normal) noexcept
Add a callable using a token with manual unsubscribing.
A class that can be used as a key in ordered containers so that items are ordered in descending order...
requires(same_variadic_args_v< args_t... >) const expr auto coalesce(args_t &&... args)
Coalesce function, C# a ?? b analogue.
priority
User may use the predefined values or the custom ones, for ex. "normal - 1", this type is supposed to...