ArcDelegate
- Module
- Arc
- Header
#include "Arc/Core/ArcDelegate.h"- Namespace
Arcf- Template
template<typename Ret, typename... Args>
Type aliases
| Alias | Description |
|---|---|
using FunctionType = std::function<Ret(Args...)> |
Constructors
| Signature | Name | Description |
|---|---|---|
ArcDelegate() = default | ArcDelegate | |
ArcDelegate(const ArcDelegate& other) | ArcDelegate | 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). |
ArcDelegate(ArcDelegate&&) noexcept = default | ArcDelegate | |
~ArcDelegate() | ~ArcDelegate |
Public functions
| Returns | Name | Description |
|---|---|---|
ArcDelegate& | operator= | |
ArcDelegate& | 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
ArcDelegate
ArcDelegate() = defaultArcDelegate
ArcDelegate(const ArcDelegate& 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.
ArcDelegate
ArcDelegate(ArcDelegate&&) noexcept = default~ArcDelegate
~ArcDelegate()operator=
ArcDelegate& operator=(const ArcDelegate& other)operator=
ArcDelegate& operator=(ArcDelegate&&) 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