Controlling the Graph State
When a node is created using dabfg::register_node()
, a handle
object is returned that must be used to control the lifetime of this
node. As soon as the handle is destroyed, the node is removed from the
graph.
The recommended approach for managing handles is to use feature specific daECS entities. The idea is to encapsulate all of the “settings” required for creating a node for a feature as well as a handle for that node inside a single entity and automatically re-create the node when the settings change using ECS tracking capabilities. When the feature is disabled, the entity is destroyed and the node is removed from the graph automagically.
Note also that the handles are generational, so it is safe to simply assign a new node handle to a component without explicitly resetting the old node handle.
-
class NodeHandle
Holds ownership over a node’s lifetime. As soon as a handle to a node destroyed, the node is unregistered, but only if it was not re-registered since the time that this handle was acquired.
Note that this is a move-only type.
Public Functions
-
NodeHandle() = default
Constructs an invalid handle.
-
inline NodeHandle(NodeHandle &&other)
Move constructor.
-
inline NodeHandle &operator=(NodeHandle &&other)
Move assignment operator.
-
inline explicit operator bool()
Returns true if the handle is valid.
-
NodeHandle() = default