GGUI::GGHandler class

GGHandler: an event handler stored on a node.

A lambda that is trivially copyable and small enough is stored inline. One that captures something owning memory (a string, a vector), or that is too big, goes in a pooled block the node holds (GGCaptured) and is freed when the reaction is removed. Authors write the same lambda either way; it must be copyable and must not capture references to locals. HandlerOf<TEvent> is what the authoring API takes: a lambda taking the event, or nothing.

Handlers run in the UI update. They can change UI state, bump a GGRevision, write an atomic, or queue a command. They must not touch the tree or the simulation directly.

Derived classes

template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.
template<typename TEvent>
class HandlerOf
A handler of events of type TEvent: a lambda taking the event, or nothing.

Public static variables

static size_t InlineBytes constexpr
the most a lambda stored inline takes

Constructors, destructors, conversion operators

GGHandler() defaulted
No handler.
operator bool() const explicit
Whether it has a handler.

Public functions

void Run(const void* event) const
event must point at the event type the handler was created for.
auto OwnsCaptures() const -> bool
True if the captures live in a separate block.

Protected static functions

template<typename TFn>
static auto Kept(const void* bytes) -> const TFn&
The stored callable, inline or via the block pointer.

Protected functions

template<typename TFn>
void Store(TFn&& fn, void(*)(const void*bytes, const void*event) thunk)
Keep fn, called through thunk.

Protected static variables

template<typename TFn>
static bool FitsInline constexpr
Whether TFn is stored inline, rather than in a block.