Skip to content

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.
voidaddNode(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 voidaddNodeAt(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 NodeRangegetNodes() const override<br>Returns a iterable range to the nodes of this container.
voidpurgeNodes()<br>Erases objects marked for deletion or removal from the container.
boolremoveNode(const std::shared_ptr< Node > & node)<br>Removes a node from the container.
virtual voidremoveNodeAt(int index)<br>Removes a node at a specified index from the container.
boolreplaceNode(const std::shared_ptr< Node > & oldNode, const std::shared_ptr< Node > & newNode)<br>Replaces an existing node with a new one.
virtual voidreplaceNodeAt(const std::shared_ptr< Node > & node, int index)<br>Replaces node at a specified index with a different one.

Protected Functions ​

Name
virtual voidonNodeAdd(Node * node, int index)<br>Called after a node is inserted into the container.
virtual voidonNodeRemove(std::shared_ptr< Node > node, int index)<br>Called after a node is removed from the container.

Protected Attributes ​

Name
NodeListm_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 ​

cpp
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 ​

cpp
NodeContainer(
    DiwneObject * owner
)

Constructs the node container for a specific DiwneObject that it represents.

function addNode ​

cpp
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 ​

cpp
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 ​

cpp
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 ​

cpp
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 ​

cpp
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 ​

cpp
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 ​

cpp
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 ​

cpp
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 ​

cpp
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 ​

cpp
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 ​

cpp
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 ​

cpp
NodeList m_nodes;

variable m_owner ​

cpp
DiwneObject * m_owner;

Diwne object associated with this node container.


Updated on 2026-09-11 at 21:24:25 +0000