控制图形状态
使用 dabfg::register_node() 创建节点时,会返回一个句柄对象,必须用它来控制节点的生命周期。一旦句柄被销毁,节点就会从图中移除。
管理句柄的推荐方法是使用特定功能的 daECS 实体。这样做的目的是将为某一功能创建节点所需的所有 “设置 ”以及该节点的句柄封装在一个实体中,并在使用 ECS 跟踪功能改变设置时自动重新创建节点。当功能被禁用时,实体会被销毁,节点也会自动从图形中移除。
还需注意的是,节点句柄是世代相传的,因此只需为组件分配一个新的节点句柄即可,无需明确重置旧的节点句柄。
-
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 bool valid() const
Returns true if the handle is valid.
-
inline explicit operator bool() const
Returns true if the handle is valid.
-
NodeHandle() = default