MiriDelegate
- Module
- Miri
- Header
#include "Miri/Core/MiriDelegate.h"- Namespace
Miri- Template
template<typename Ret, typename... Args>
Type aliases
| Alias | Description |
|---|---|
using FunctionType = std::function<Ret(Args...)> |
Constructors
| Signature | Name | Description |
|---|---|---|
MiriDelegate() = default | MiriDelegate | |
MiriDelegate(const MiriDelegate& other) | MiriDelegate | Bindings are owned by a shared block rather than by the delegate itself so a Broadcast can keep walking after a handler destroys the delegate (a button whose click closes the panel that owns it). |
MiriDelegate(MiriDelegate&&) noexcept = default | MiriDelegate | |
~MiriDelegate() | ~MiriDelegate |
Public functions
| Returns | Name | Description |
|---|---|---|
MiriDelegate& | operator= | |
MiriDelegate& | operator= | |
CDelegateHandle | Add | The returned handle is what Remove takes |
CDelegateHandle | Add | |
bool | Remove | |
void | Clear | |
void | Broadcast | Handlers may add or remove listeners, destroy the widget that owns this delegate, or close the panel a LATER listener belongs to. |
bool | IsBound | |
size_t | GetCount | |
void | operator() |
Function details
MiriDelegate
MiriDelegate() = defaultMiriDelegate
MiriDelegate(const MiriDelegate& other)Bindings are owned by a shared block rather than by the delegate itself so a Broadcast can keep walking after a handler destroys the delegate (a button whose click closes the panel that owns it). A copied delegate must not share that block — it would fire the source's listeners — so copies deep-copy it.
MiriDelegate
MiriDelegate(MiriDelegate&&) noexcept = default~MiriDelegate
~MiriDelegate()operator=
MiriDelegate& operator=(const MiriDelegate& other)operator=
MiriDelegate& operator=(MiriDelegate&&) noexcept = defaultAdd
CDelegateHandle Add(FunctionType func)The returned handle is what Remove takes
Add
template<typename T> CDelegateHandle Add(T* obj, Ret (T::*method)(Args...))Remove
bool Remove(CDelegateHandle handle)Clear
void Clear()Broadcast
void Broadcast(Args... args) constHandlers may add or remove listeners, destroy the widget that owns this delegate, or close the panel a LATER listener belongs to. The walk therefore never touches this after the first call: it pins the shared block, snapshots the handles, and before each call re-resolves the handle against the live list — a listener removed by an earlier handler is skipped rather than run against an object that no longer exists. The functor is copied out before the call because a handler that removes ITSELF would otherwise free the storage it is executing from.
IsBound
bool IsBound() constGetCount
size_t GetCount() constoperator()
void operator()(Args... args) const