HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_GraphData.h File Reference
#include "UN_API.h"
#include "UN_GraphContext.h"
#include "UN_GraphTopology.h"
#include "UN_Include.h"
#include "UN_NodeData.h"
#include "UN_ParmData.h"
#include "UN_PortData.h"
#include "UN_StickyNoteData.h"
#include "UN_SubnetData.h"
#include "UN_WireData.h"
+ Include dependency graph for UN_GraphData.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  UN_GraphData
 

Typedefs

using UN_WireDrawStyle = UNI_WireStyle
 

Typedef Documentation

A container and a manager for utility nodes, their parameters and ports, and wire connections between them.

This graph object owns the node data containers, and these containers own the data buffers. It manages node creation and deletion, and maintains the parental relationship between them. This class also establishes and maintains connections between the nodes, i.e., creates and manages wires via the topology class.

Having such a central manager has several advantages:

  • Better memory management by avoiding numerous small heap allocs. It can maintain memory blocks of nodes and wires, and reuse slots freed by deleted items, thus avoiding numerous heap memory allocations during repeated cycles of node creation/deletion of nodes and wires connection/disconnection.
  • Enforces structural integrity of the nodes and connections:
    • No free-floating nodes that belong to nobody.
    • Ensuring wires connect siblings only (no wires to outside of a subnet).
  • Easier management and ownership of wires.
  • Enforces const-correctess: you can edit the graph only if you have non-const reference to it; a const graph reference is not editable.
  • Thread safety: allows parallel processing of the node chains only if they belong to different graphs; without graphs, it's hard to know that two nodes are independent and can be processed in parallel.
  • the struct-of-arrays approach (ie data-oriented-design) is cache friendly and optimizes performance when iterating over elements.

Some disadvantages:

  • Overhead that stems from handles holding an ID rather than a direct pointer, so access is somewhat slower.
  • Adding a single element (eg, a node) potentially requires several allocations of smaller data chunks (data buffer), rather than a single allocation of a larger chunk that array-of-structs would require. Multiple allocs are slower than a single one.

NOTE: This class is generally not trivially relocatable, because its members (eg, myNodeData) are not trivially relocatable (see comment there).

Definition at line 68 of file UN_GraphData.h.