NodeStorage class
#include <GGUI/Public/NodeStorage.h>
The nodes of one document, and how they are joined. See the file description.
Public static variables
- static uint32_t SlotsPerChunk constexpr
- static uint32_t RecycleFrames constexpr
- Frames a destroyed slot waits before reuse: the depth of the published snapshot chain, so no reader can still hold a snapshot referring to the old node.
- static uint16_t MaxDepth constexpr
- Maximum tree depth. An attach that would exceed it is refused.
Constructors, destructors, conversion operators
- NodeStorage()
- No nodes.
- ~NodeStorage()
- Frees every chunk. No listener is called.
- NodeStorage(const NodeStorage&) deleted
Public functions
- auto operator=(const NodeStorage&) -> NodeStorage& deleted
- void SetListener(const NodeStorageListener& listener)
- Who hears of every change. Set before the first node is created.
- auto Create(WidgetTypeID type, uint64_t key = 0) -> NodeHandle
- Create a parentless node.
keyidentifies it among its siblings (0 = by position). - void Destroy(NodeHandle node)
- Destroy the node and its subtree. Stale or null handles are ignored.
- auto IsAlive(NodeHandle node) const -> bool
- Whether
nodestill exists. - auto NodeAt(NodeIndex index) const -> NodeHandle
- The node in slot
index; null if the slot is empty. - void AdvanceFrame()
- End of a UI frame: recycle slots destroyed RecycleFrames ago and free empty chunks.
- auto AppendChild(NodeHandle parent, NodeHandle child) -> bool
- Append
childtoparent, detaching it from its current parent. - auto InsertBefore(NodeHandle parent, NodeHandle child, NodeHandle before) -> bool
- Insert
childintoparentbeforebefore. - auto Remove(NodeHandle child) -> bool
- Detach
child. It and its subtree stay alive as a separate tree. - auto Parent(NodeHandle node) const -> NodeHandle
- Its parent.
- auto FirstChild(NodeHandle node) const -> NodeHandle
- Its first child.
- auto LastChild(NodeHandle node) const -> NodeHandle
- Its last child.
- auto NextSibling(NodeHandle node) const -> NodeHandle
- The child after it in its parent.
- auto PrevSibling(NodeHandle node) const -> NodeHandle
- The child before it in its parent.
- auto ChildCount(NodeHandle node) const -> uint32_t
- How many children it has; 0 if it is stale.
- auto Depth(NodeHandle node) const -> uint16_t
- How deep it is: 0 for a root.
- auto Type(NodeHandle node) const -> WidgetTypeID
- What kind of element it is; 0 if it is stale.
- auto Key(NodeHandle node) const -> uint64_t
- Its key among its siblings; 0 if it has none or is stale.
- auto LiveCount() const -> uint32_t
- How many nodes exist.
- auto ChunkCount() const -> uint32_t
- How many chunks are allocated.
- auto PendingRecycleCount() const -> uint32_t
- Slots waiting out the recycle window.
- auto Bytes() const -> size_t
- Memory held by the chunks.
Variable documentation
static uint32_t GGUI:: NodeStorage:: SlotsPerChunk constexpr
nodes per chunk