Skip to content

Core::Node

Base class interface for all boxes.

#include "Core/Nodes/Node.h"

Inherits from std::enable_shared_from_this< Node >

Inherited by Core::Camera, Core::Cycle, Core::Model, Core::Operator< T >, Core::Sequence, Core::Transform

Public Functions

Name
virtual voidaddDeleteCallback(std::function< void(Node )> callback)<br> The callback parameters: Node = node that has been deleted
virtual voidaddPlugCallback(std::function< void(Node *, Node *, size_t, size_t)> callback)<br>Registers a callback that gets called when the node's output pins get plugged in.
virtual voidaddUnplugCallback(std::function< void(Node *, Node *, size_t, size_t)> callback)<br>Registers a callback that gets called when the node's input pins get unplugged.
virtual voidaddUpdateCallback(std::function< void(Node *)> callback)<br>Registers a callback that gets called on any updateValues() call.
voidappendChildNode(Ptr< Node > node)
boolareAllInputsPlugged()
boolareAllInputsUnplugged() const
boolareInputsPlugged(int numInputs)
template <typename T &gt; <br>Ptr< T >as()
const Data &data(size_t index =0) const<br>Get Node contents, read only.
Data &dataMut(size_t index)
voidfinalize()<br>Prepares node for its destruction, after that the destructor can be called.
IDgetId() const
Pin &getInput(size_t i)
std::vector< Pin > &getInputPins()
Data &getInternalData(size_t index =0)<br>Get data storage for read and write purposes.
const char *getLabel() const
const Operation *getOperation() const
Pin &getOutput(size_t i)
std::vector< Pin > &getOutputPins()
Ptr< Node >getOwner() const<br>Get direct owner of this node.
Ptr< Node >getPtr()<br>Get reference to this node instance.
Ptr< Node >getRootOwner()<br>Get the topmost owner of this node.
std::stringgetSignature()<br>"{node type} #{node ID}"
EValueStategetState(size_t pinIndex =0)
voidinit()<br>Initialize node id, inputs, and outputs according to the preset node type.
voidnotifyOwner()
virtual voidonInit()
booloperator!=(const Node & other) const
booloperator==(const Node & other) const
ENodePlugResultplug(const Ptr< Node > & childNode, unsigned fromIndex, unsigned toIndex)<br>Connect this (parent) node output to the childNode input.
voidpulse(size_t index)
virtual voidreceiveSignal(int inputIndex)<br>Implements the operator reaction to the change of its inputIndex input.
virtual SetValueResultsetValue(const glm::mat4 & mat)
virtual SetValueResultsetValue(const glm::mat4 & mat, const DataMap & map)<br>Smart set function, used with constrained transformation for value checking.
virtual SetValueResultsetValue(const glm::quat & q)
virtual SetValueResultsetValue(const glm::vec3 & vec)
virtual SetValueResultsetValue(const glm::vec4 & vec)
template <typename T &gt; <br>SetValueResultsetValue(const T & value, unsigned index)
virtual SetValueResultsetValue(float val)<br>Set the value of the node.
virtual SetValueResultsetValue(float val, glm::ivec2 coords)
virtual SetValueResultsetValue(void * ptr)
voidspreadSignal()<br>Spread signal to all outputs.
voidspreadSignal(size_t outIndex)<br>Spread signal to the selected output outIndex only.
virtual voidupdateValues(int inputIndex =0)<br>Computes new values of outputs based on inputs.

Protected Functions

Name
Node(const Operation * operation)<br>Node is never constructed directory.
virtual~Node()
ENodePlugResultisPlugCorrect(const Pin & input, const Pin & output)
virtual voidonUnplugInput(size_t index)
template <typename T &gt; <br>voidsetInternalValue(const T & value, size_t index =0)<br>Sets the node value without validation.
voidsetInternalValue(float value, glm::ivec2 coordinates, size_t index =0)
boolshouldPulse(size_t inputIndex, size_t updatedInputIndex)<br>Tests if the updatedInputIndex should be pulsed.
voidtriggerDeleteCallback(Node * node)
voidtriggerPlugCallback(Node * fromNode, Node * toNode, size_t fromIndex, size_t toIndex)
voidtriggerUnplugCallback(Node * fromNode, Node * toNode, size_t fromIndex, size_t toIndex)
voidtriggerUpdateCallback(Node * node)

Public Attributes

Name
std::vector< EValueState >m_OperatorState

Protected Attributes

Name
std::vector< Node * >m_children <br>Nested nodes.
IDm_id
std::vector< Pin >m_inputs <br>Inputs of the box: Input tabs with glyphs.
std::vector< Data >m_internalData <br>Results of operations.
const Operation *m_operation <br>Operator node properties.
std::vector< Pin >m_outputs <br>Outputs of the box: output tabs with glyphs.
Node *m_owner <br>Owner of the node, used in complex type of nodes, such as sequence or camera.

Friends

Name
classGraphManager
classPin

Public Functions Documentation

function addDeleteCallback

cpp
virtual void addDeleteCallback(
    std::function< void(Node *)> callback
)
virtual void addDeleteCallback(
    std::function< void(Node *)> callback
)

The callback parameters: Node* = node that has been deleted

function addPlugCallback

cpp
virtual void addPlugCallback(
    std::function< void(Node *, Node *, size_t, size_t)> callback
)
virtual void addPlugCallback(
    std::function< void(Node *, Node *, size_t, size_t)> callback
)

Registers a callback that gets called when the node's output pins get plugged in.

The callback parameters:

Node* = Start node

Node* = End node

size_t = Start node's output pin index

size_t = End node's input pin index

function addUnplugCallback

cpp
virtual void addUnplugCallback(
    std::function< void(Node *, Node *, size_t, size_t)> callback
)
virtual void addUnplugCallback(
    std::function< void(Node *, Node *, size_t, size_t)> callback
)

Registers a callback that gets called when the node's input pins get unplugged.

The callback parameters:

Node* = Start node

Node* = End node

size_t = Start node's output pin index

size_t = End node's input pin index

function addUpdateCallback

cpp
virtual void addUpdateCallback(
    std::function< void(Node *)> callback
)
virtual void addUpdateCallback(
    std::function< void(Node *)> callback
)

Registers a callback that gets called on any updateValues() call.

Note that some derived nodes might not always call this callback.

The callback parameters:

Node* = node that has been updated

function appendChildNode

cpp
void appendChildNode(
    Ptr< Node > node
)
void appendChildNode(
    Ptr< Node > node
)

function areAllInputsPlugged

cpp
bool areAllInputsPlugged()
bool areAllInputsPlugged()

function areAllInputsUnplugged

cpp
bool areAllInputsUnplugged() const
bool areAllInputsUnplugged() const

function areInputsPlugged

cpp
bool areInputsPlugged(
    int numInputs
)
bool areInputsPlugged(
    int numInputs
)

function as

cpp
template <typename T >
inline Ptr< T > as()
template <typename T >
inline Ptr< T > as()

function data

cpp
inline const Data & data(
    size_t index =0
) const
inline const Data & data(
    size_t index =0
) const

Get Node contents, read only.

Parameters:

  • index Index of the internal modifiable data field (e.g, 0 or 1 for two vectors). Value of field[0] is returned if this parameter omitted)

Return: Struct which holds data

function dataMut

cpp
inline Data & dataMut(
    size_t index
)
inline Data & dataMut(
    size_t index
)

function finalize

cpp
void finalize()
void finalize()

Prepares node for its destruction, after that the destructor can be called.

Todo: MH: Remove, use destructor directly.

function getId

cpp
ID getId() const
ID getId() const

Return: Application unique ID.

function getInput

cpp
inline Pin & getInput(
    size_t i
)
inline Pin & getInput(
    size_t i
)

function getInputPins

cpp
inline std::vector< Pin > & getInputPins()
inline std::vector< Pin > & getInputPins()

function getInternalData

cpp
Data & getInternalData(
    size_t index =0
)
Data & getInternalData(
    size_t index =0
)

Get data storage for read and write purposes.

Todo: Make this function non public.

No written value validation is performed.

Overridden in Sequence class. This function won't work for mapped pins.

function getLabel

cpp
inline const char * getLabel() const
inline const char * getLabel() const

function getOperation

cpp
inline const Operation * getOperation() const
inline const Operation * getOperation() const

function getOutput

cpp
inline Pin & getOutput(
    size_t i
)
inline Pin & getOutput(
    size_t i
)

function getOutputPins

cpp
inline std::vector< Pin > & getOutputPins()
inline std::vector< Pin > & getOutputPins()

function getOwner

cpp
Ptr< Node > getOwner() const
Ptr< Node > getOwner() const

Get direct owner of this node.

Return: nullptr if owner is not set.

function getPtr

cpp
inline Ptr< Node > getPtr()
inline Ptr< Node > getPtr()

Get reference to this node instance.

Note that this operation may be slower. A new shared pointer must be created, it obtains atomic counter increment.

function getRootOwner

cpp
Ptr< Node > getRootOwner()
Ptr< Node > getRootOwner()

Get the topmost owner of this node.

function getSignature

cpp
inline std::string getSignature()
inline std::string getSignature()

"{node type} #{node ID}"

function getState

cpp
EValueState getState(
    size_t pinIndex =0
)
EValueState getState(
    size_t pinIndex =0
)

function init

cpp
void init()
void init()

Initialize node id, inputs, and outputs according to the preset node type.

Called in create node function.

function notifyOwner

cpp
void notifyOwner()
void notifyOwner()

function onInit

cpp
inline virtual void onInit()
inline virtual void onInit()

function operator!=

cpp
inline bool operator!=(
    const Node & other
) const
inline bool operator!=(
    const Node & other
) const

function operator==

cpp
inline bool operator==(
    const Node & other
) const
inline bool operator==(
    const Node & other
) const

function plug

cpp
ENodePlugResult plug(
    const Ptr< Node > & childNode,
    unsigned fromIndex,
    unsigned toIndex
)
ENodePlugResult plug(
    const Ptr< Node > & childNode,
    unsigned fromIndex,
    unsigned toIndex
)

Connect this (parent) node output to the childNode input.

Parameters:

  • childNode this node's toIndex input will be connected
  • fromIndex index of the parent (this) node output
  • toIndex index of the childNode input

See: ENodePlugResult.

Return: Result enum is returned from the function.

function pulse

cpp
void pulse(
    size_t index
)
void pulse(
    size_t index
)

function receiveSignal

cpp
virtual void receiveSignal(
    int inputIndex
)
virtual void receiveSignal(
    int inputIndex
)

Implements the operator reaction to the change of its inputIndex input.

Parameters:

  • inputIndex Index of the input that was changed and that forces the operator to recompute its outputs.
  1. Forces the operator to recompute its outputs based on the changed input inputIndex by calling updateValues() and
  2. Spread signal to the connected children by spreadSignal().

This method is called by the spreadSignal() of the parent box in the scene graph. The computation may be restricted by internal bool value restrictedOutput to a single previously defined output index restrictedOutputIndex.

function setValue

cpp
inline virtual SetValueResult setValue(
    const glm::mat4 & mat
)
inline virtual SetValueResult setValue(
    const glm::mat4 & mat
)

Reimplemented by: Core::Transform::setValue, Core::TransformImpl< ETransformType::AxisAngle >::setValue, Core::TransformImpl< ETransformType::Quat >::setValue

function setValue

cpp
inline virtual SetValueResult setValue(
    const glm::mat4 & mat,
    const DataMap & map
)
inline virtual SetValueResult setValue(
    const glm::mat4 & mat,
    const DataMap & map
)

Smart set function, used with constrained transformation for value checking.

Parameters:

  • mat

function setValue

cpp
inline virtual SetValueResult setValue(
    const glm::quat & q
)
inline virtual SetValueResult setValue(
    const glm::quat & q
)

Reimplemented by: Core::TransformImpl< ETransformType::Quat >::setValue

function setValue

cpp
inline virtual SetValueResult setValue(
    const glm::vec3 & vec
)
inline virtual SetValueResult setValue(
    const glm::vec3 & vec
)

Reimplemented by: Core::TransformImpl< ETransformType::AxisAngle >::setValue, Core::TransformImpl< ETransformType::Scale >::setValue, Core::TransformImpl< ETransformType::EulerX >::setValue, Core::TransformImpl< ETransformType::EulerY >::setValue, Core::TransformImpl< ETransformType::EulerZ >::setValue, Core::TransformImpl< ETransformType::Translation >::setValue

function setValue

cpp
inline virtual SetValueResult setValue(
    const glm::vec4 & vec
)
inline virtual SetValueResult setValue(
    const glm::vec4 & vec
)

Reimplemented by: Core::TransformImpl< ETransformType::Scale >::setValue, Core::TransformImpl< ETransformType::EulerX >::setValue, Core::TransformImpl< ETransformType::EulerY >::setValue, Core::TransformImpl< ETransformType::EulerZ >::setValue, Core::TransformImpl< ETransformType::Translation >::setValue

function setValue

cpp
template <typename T >
inline SetValueResult setValue(
    const T & value,
    unsigned index
)
template <typename T >
inline SetValueResult setValue(
    const T & value,
    unsigned index
)

function setValue

cpp
inline virtual SetValueResult setValue(
    float val
)
inline virtual SetValueResult setValue(
    float val
)

Set the value of the node.

Parameters:

  • val

Reimplemented by: Core::TransformImpl< ETransformType::EulerX >::setValue, Core::TransformImpl< ETransformType::EulerY >::setValue, Core::TransformImpl< ETransformType::EulerZ >::setValue, Core::TransformImpl< ETransformType::AxisAngle >::setValue, Core::TransformImpl< ETransformType::Scale >::setValue, Core::TransformImpl< ETransformType::Translation >::setValue

Sets the value of the first float of DataStore. Derived types may override the default behavior.

function setValue

cpp
inline virtual SetValueResult setValue(
    float val,
    glm::ivec2 coords
)
inline virtual SetValueResult setValue(
    float val,
    glm::ivec2 coords
)

Parameters:

  • val new value
  • coords in the column major order: coords.x is the column index and coords.y is the row index.

Return:

Reimplemented by: Core::Transform::setValue, Core::TransformImpl< ETransformType::Free >::setValue, Core::TransformImpl< ETransformType::Scale >::setValue, Core::TransformImpl< ETransformType::EulerX >::setValue, Core::TransformImpl< ETransformType::EulerY >::setValue, Core::TransformImpl< ETransformType::EulerZ >::setValue, Core::TransformImpl< ETransformType::Translation >::setValue, Core::TransformImpl< ETransformType::Ortho >::setValue, Core::TransformImpl< ETransformType::Perspective >::setValue, Core::TransformImpl< ETransformType::Frustum >::setValue

function setValue

cpp
inline virtual SetValueResult setValue(
    void * ptr
)
inline virtual SetValueResult setValue(
    void * ptr
)

function spreadSignal

cpp
void spreadSignal()
void spreadSignal()

Spread signal to all outputs.

Todo: Does not use operators for calling each follower just once

TodoMH Correct the owner of the pin.

function spreadSignal

cpp
void spreadSignal(
    size_t outIndex
)
void spreadSignal(
    size_t outIndex
)

Spread signal to the selected output outIndex only.

function updateValues

cpp
virtual void updateValues(
    int inputIndex =0
)
virtual void updateValues(
    int inputIndex =0
)

Computes new values of outputs based on inputs.

Parameters:

  • inputIndex Index of the modified input.

Reimplemented by: Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Operator::updateValues, Core::Camera::updateValues, Core::Cycle::updateValues, Core::Operator::updateValues, Core::Sequence::updateValues, Core::Model::updateValues

Encodes the box function by updating the output values for a given inputIndex - fired by receiveSignal().

The base class method calls update callbacks registered with addUpdateCallback(). So derived methods should also call their base method if they want to inform any outside observers.

Protected Functions Documentation

function Node

cpp
inline Node(
    const Operation * operation
)
inline Node(
    const Operation * operation
)

Node is never constructed directory.

Parameters:

  • operation Node properties.

See: init() function for pin and data storage initialization

function ~Node

cpp
virtual ~Node()
virtual ~Node()

function isPlugCorrect

cpp
ENodePlugResult isPlugCorrect(
    const Pin & input,
    const Pin & output
)
ENodePlugResult isPlugCorrect(
    const Pin & input,
    const Pin & output
)

function onUnplugInput

cpp
inline virtual void onUnplugInput(
    size_t index
)
inline virtual void onUnplugInput(
    size_t index
)

Reimplemented by: Core::Model::onUnplugInput

function setInternalValue

cpp
template <typename T >
inline void setInternalValue(
    const T & value,
    size_t index =0
)
template <typename T >
inline void setInternalValue(
    const T & value,
    size_t index =0
)

Sets the node value without validation.

Parameters:

  • value Value to set.
  • index Index of the DataStore (if the node stores more than one value)

Template Parameters:

  • T Value type, no need to specify it in angle brackets, it will be deduced by the compiler (C++17).

function setInternalValue

cpp
inline void setInternalValue(
    float value,
    glm::ivec2 coordinates,
    size_t index =0
)
inline void setInternalValue(
    float value,
    glm::ivec2 coordinates,
    size_t index =0
)

function shouldPulse

cpp
bool shouldPulse(
    size_t inputIndex,
    size_t updatedInputIndex
)
bool shouldPulse(
    size_t inputIndex,
    size_t updatedInputIndex
)

Tests if the updatedInputIndex should be pulsed.

Parameters:

  • inputIndex Index of the tested input.
  • updatedInputIndex Index of the input which was updated.

Return:

function triggerDeleteCallback

cpp
void triggerDeleteCallback(
    Node * node
)
void triggerDeleteCallback(
    Node * node
)

function triggerPlugCallback

cpp
void triggerPlugCallback(
    Node * fromNode,
    Node * toNode,
    size_t fromIndex,
    size_t toIndex
)
void triggerPlugCallback(
    Node * fromNode,
    Node * toNode,
    size_t fromIndex,
    size_t toIndex
)

function triggerUnplugCallback

cpp
void triggerUnplugCallback(
    Node * fromNode,
    Node * toNode,
    size_t fromIndex,
    size_t toIndex
)
void triggerUnplugCallback(
    Node * fromNode,
    Node * toNode,
    size_t fromIndex,
    size_t toIndex
)

function triggerUpdateCallback

cpp
void triggerUpdateCallback(
    Node * node
)
void triggerUpdateCallback(
    Node * node
)

Public Attributes Documentation

variable m_OperatorState

cpp
std::vector< EValueState > m_OperatorState;
std::vector< EValueState > m_OperatorState;

Todo:

Protected Attributes Documentation

variable m_children

cpp
std::vector< Node * > m_children;
std::vector< Node * > m_children;

Nested nodes.

variable m_id

cpp
ID m_id {};
ID m_id {};

variable m_inputs

cpp
std::vector< Pin > m_inputs;
std::vector< Pin > m_inputs;

Inputs of the box: Input tabs with glyphs.

variable m_internalData

cpp
std::vector< Data > m_internalData;
std::vector< Data > m_internalData;

Results of operations.

variable m_operation

cpp
const Operation * m_operation = nullptr;
const Operation * m_operation = nullptr;

Operator node properties.

variable m_outputs

cpp
std::vector< Pin > m_outputs;
std::vector< Pin > m_outputs;

Outputs of the box: output tabs with glyphs.

variable m_owner

cpp
Node * m_owner = nullptr;
Node * m_owner = nullptr;

Owner of the node, used in complex type of nodes, such as sequence or camera.

Friends

friend GraphManager

cpp
friend class GraphManager(
    GraphManager 
);
friend class GraphManager(
    GraphManager 
);

friend Pin

cpp
friend class Pin(
    Pin 
);
friend class Pin(
    Pin 
);

Updated on 2024-11-06 at 20:16:54 +0000