DIWNE::NodeContainer
Basic implementation of a node container, eg. More...
#include "DIWNE/Core/Elements/Containers/NodeContainer.h"
Inherits from DIWNE::INodeContainer
Inherited by DIWNE::NodeDropZone, DIWNE::NodeEditor
Public Functions
Name | |
---|---|
NodeContainer(DiwneObject * owner)<br>Constructs the node container for a specific DiwneObject that it represents. | |
void | addNode(const std::shared_ptr< Node > & node)<br>Adds a node to the end of the list (O(1)) The new node has this container set as its parent. |
virtual void | addNodeAt(const std::shared_ptr< Node > & node, int index)<br>Adds a node at a specified index. |
virtual NodeList & | getNodeList() override<br>Returns the underlying std::vector node list of the container. |
virtual NodeRange | getNodes() const override<br>Returns a iterable range to the nodes of this container. |
void | purgeNodes()<br>Erases objects marked for deletion or removal from the container. |
bool | removeNode(const std::shared_ptr< Node > & node)<br>Removes a node from the container. |
virtual void | removeNodeAt(int index)<br>Removes a node at a specified index from the container. |
bool | replaceNode(const std::shared_ptr< Node > & oldNode, const std::shared_ptr< Node > & newNode)<br>Replaces an existing node with a new one. |
virtual void | replaceNodeAt(const std::shared_ptr< Node > & node, int index)<br>Replaces node at a specified index with a different one. |
Protected Functions
Name | |
---|---|
virtual void | onNodeAdd(Node * node, int index)<br>Called after a node is inserted into the container. |
virtual void | onNodeRemove(std::shared_ptr< Node > node, int index)<br>Called after a node is removed from the container. |
Protected Attributes
Name | |
---|---|
NodeList | m_nodes |
DiwneObject * | m_owner <br>Diwne object associated with this node container. |
Additional inherited members
Public Functions inherited from DIWNE::INodeContainer
Name | |
---|---|
virtual | ~INodeContainer() =default |
Detailed Description
class DIWNE::NodeContainer;
class DIWNE::NodeContainer;
Basic implementation of a node container, eg.
Warning: NodeContainer requires its DiwneObject owner to call purgeNodes() every frame if automatic removal of nodes is needed. Otherwise when a node is added it must be manually removed from its previous container.
an object owning other nodes. It is used to expand functionality of an existing DiwneObject, which is meant to inherit this class using multiple inheritance to add container functionality.
Public Functions Documentation
function NodeContainer
NodeContainer(
DiwneObject * owner
)
NodeContainer(
DiwneObject * owner
)
Constructs the node container for a specific DiwneObject that it represents.
function addNode
void addNode(
const std::shared_ptr< Node > & node
)
void addNode(
const std::shared_ptr< Node > & node
)
Adds a node to the end of the list (O(1)) The new node has this container set as its parent.
Triggers onNodeAdd() with the new node.
function addNodeAt
virtual void addNodeAt(
const std::shared_ptr< Node > & node,
int index
)
virtual void addNodeAt(
const std::shared_ptr< Node > & node,
int index
)
Adds a node at a specified index.
The new node has this container set as its parent. This operation triggers shifting of all subsequent nodes by one position (O(n) worst case) and reallocation. Triggers onNodeAdd() with the new node.
function getNodeList
virtual NodeList & getNodeList() override
virtual NodeList & getNodeList() override
Returns the underlying std::vector node list of the container.
Reimplements: DIWNE::INodeContainer::getNodeList
Reimplemented by: DIWNE::NodeEditor::getNodeList
function getNodes
virtual NodeRange getNodes() const override
virtual NodeRange getNodes() const override
Returns a iterable range to the nodes of this container.
Reimplements: DIWNE::INodeContainer::getNodes
Reimplemented by: DIWNE::NodeEditor::getNodes
function purgeNodes
void purgeNodes()
void purgeNodes()
Erases objects marked for deletion or removal from the container.
This method needs to be called every frame by the container owner.
function removeNode
bool removeNode(
const std::shared_ptr< Node > & node
)
bool removeNode(
const std::shared_ptr< Node > & node
)
Removes a node from the container.
Return: false if the node isn't found
Must first find it (O(n)). This operation triggers shifting of all subsequent nodes by one position (O(n) worst case). Triggers onNodeRemove() callback with a pointer to the removed node.
function removeNodeAt
virtual void removeNodeAt(
int index
)
virtual void removeNodeAt(
int index
)
Removes a node at a specified index from the container.
This operation triggers shifting of all subsequent nodes by one position (O(n) worst case). Triggers onNodeRemove() callback with a pointer to the removed node.
function replaceNode
bool replaceNode(
const std::shared_ptr< Node > & oldNode,
const std::shared_ptr< Node > & newNode
)
bool replaceNode(
const std::shared_ptr< Node > & oldNode,
const std::shared_ptr< Node > & newNode
)
Replaces an existing node with a new one.
Return: false if the node isn't found
Must first find the old node (O(n)). The new node has this container set as its parent. The old node is destroyed. Triggers onNodeRemove() callback with a pointer to the old node and then onNodeAdd() with the new node.
function replaceNodeAt
virtual void replaceNodeAt(
const std::shared_ptr< Node > & node,
int index
)
virtual void replaceNodeAt(
const std::shared_ptr< Node > & node,
int index
)
Replaces node at a specified index with a different one.
An O(1) operation. The new node has this container set as its parent. The old node is destroyed. Triggers onNodeRemove() callback with a pointer to the old node and then onNodeAdd() with the new node.
Protected Functions Documentation
function onNodeAdd
inline virtual void onNodeAdd(
Node * node,
int index
)
inline virtual void onNodeAdd(
Node * node,
int index
)
Called after a node is inserted into the container.
Parameters:
- node Raw pointer to the just inserted node.
- index Index the node was inserted at.
Reimplemented by: Workspace::Sequence::SequenceDropZone::onNodeAdd, DIWNE::NodeDropZone::onNodeAdd
function onNodeRemove
inline virtual void onNodeRemove(
std::shared_ptr< Node > node,
int index
)
inline virtual void onNodeRemove(
std::shared_ptr< Node > node,
int index
)
Called after a node is removed from the container.
Parameters:
- node Owning shared pointer to the removed node.
- index Index the node was removed from (potentially invalid).
Reimplemented by: DIWNE::NodeDropZone::onNodeRemove
An owning pointer is passed as its ref count could be one.
Protected Attributes Documentation
variable m_nodes
NodeList m_nodes;
NodeList m_nodes;
variable m_owner
DiwneObject * m_owner;
DiwneObject * m_owner;
Diwne object associated with this node container.
Updated on 2025-05-31 at 12:55:31 +0000