Enzo
Loading...
Searching...
No Matches
enzo::nt::Node Class Reference

The unique runtime representation of a node. More...

#include <Node.h>

Public Member Functions

 Node (enzo::nt::NodeId nodeId, const nt::NodeType &nodeType, const Path &path)
 Constructs a new node.
 
 Node (const Node &)=delete
 Deleted copy constructor to avoid accidental copies.
 
Nodeoperator= (const Node &)=delete
 Deleted copy assignment operator to avoid accidental copies.
 
void cook (nt::CookContext &context)
 Builds the node's implementation and runs its cook, filling the output packets.
 
std::shared_ptr< const enzo::NodePacketgetOutputPacket (unsigned int outputIndex) const
 Returns the current output geometry.
 
void setOutputPacket (unsigned int outputIndex, enzo::NodePacket packet)
 Stores finished geometry against one of the node's outputs.
 
bool outputRequested (unsigned int outputIndex) const
 Returns whether anything downstream is asking for one of the node's outputs.
 
std::vector< std::weak_ptr< prm::NodeParameter > > getParameters ()
 Returns all parameters belonging to this node.
 
std::weak_ptr< prm::NodeParametergetParameter (std::string_view parameterName)
 Returns a parameter with the given name belonging to this node.
 
bool isParameterEnabled (std::string_view parmName)
 Whether the named parameter's disable condition leaves it enabled.
 
bool isParameterHidden (std::string_view parmName)
 Whether the named parameter's hide condition currently hides it.
 
std::optional< std::string > getReferencedValue (const std::string &text)
 Returns the value text written as prm(name) reads from that parameter, or the text itself when it names no parameter.
 
const std::vector< prm::Template > & getTemplates () const
 Returns the template tree declared by this node's type.
 
std::string getName () const
 Returns the runtime name uniquely identifying this node among its siblings (eg. "grid1")
 
const PathgetPath () const
 Returns the full path locating this node within the network.
 
void setPath (const Path &path)
 Sets the full path locating this node within the network.
 
const nt::NodeTypegetType () const
 Returns the static type definition this node was created from.
 
void dirtyNode (bool dirtyDescendents=true)
 Marks the outputed geometry as outdated and notifies the network.
 
bool isDirty ()
 Returns true if the node is dirty and false if the node is clean (does not need cooking).
 
bool takesInput () const
 Returns whether the node takes any input at all.
 
unsigned int getMaxOutputs () const
 Returns the number of available outputs the node provides.
 
Vector2 getPosition () const
 Returns the node's position in the network graph.
 
void setPosition (Vector2 pos)
 Sets the node's position in the network graph.
 

Public Attributes

boost::signals2::signal< void(nt::NodeId nodeId, bool dirtyDescendents)> nodeDirtied
 A signal emitted when the node is dirtied. This will usually notify the NetworkManager.
 
boost::signals2::signal< void(const std::string &parmName)> parameterChanged
 A signal emitted when one parameter's value changes, carrying its name.
 

Detailed Description

The unique runtime representation of a node.

Constructor & Destructor Documentation

◆ Node()

enzo::nt::Node::Node ( enzo::nt::NodeId nodeId,
const nt::NodeType & nodeType,
const Path & path )

Constructs a new node.

Parameters
nodeIdthe node id assigned to this node. For most situations this should be set by the nt::NetworkManager
nodeTypeThe data class informing the node what its properties are that set it apart from other nodes. This is what makes a grid node different to a transform node.
pathThe full path locating the node, whose leaf is the node name. The nt::NetworkManager picks a path that is free within its parent.

Member Function Documentation

◆ cook()

void enzo::nt::Node::cook ( nt::CookContext & context)

Builds the node's implementation and runs its cook, filling the output packets.

Note
Does nothing while the node is clean.

◆ dirtyNode()

void enzo::nt::Node::dirtyNode ( bool dirtyDescendents = true)

Marks the outputed geometry as outdated and notifies the network.

Parameters
dirtyDescendentsSets whether all descendents (nodes connected directly or indirectly to the output of this node) are also dirtied. This is usually what you want.

◆ getName()

std::string enzo::nt::Node::getName ( ) const

Returns the runtime name uniquely identifying this node among its siblings (eg. "grid1")

The name is the leaf of the node's path, not stored separately. Unlike the type name it is per node and is intended to be user assignable. Only nodes sharing a parent have to differ, so the same name can appear once in every scope.

◆ getOutputPacket()

std::shared_ptr< const NodePacket > enzo::nt::Node::getOutputPacket ( unsigned int outputIndex) const

Returns the current output geometry.

Does not trigger a cook so if the geometry may be outdated if not cooked first.

Todo
Add option to force cook or cook if dirty.

◆ getParameter()

std::weak_ptr< prm::NodeParameter > enzo::nt::Node::getParameter ( std::string_view parameterName)

Returns a parameter with the given name belonging to this node.

Returns
Empty default constructed std::weak_ptr<prm::Parameter>() if no parameter of that name exists.

◆ getReferencedValue()

std::optional< std::string > enzo::nt::Node::getReferencedValue ( const std::string & text)

Returns the value text written as prm(name) reads from that parameter, or the text itself when it names no parameter.

Returns
Nothing when the text names a parameter this node does not have.

◆ getTemplates()

const std::vector< prm::Template > & enzo::nt::Node::getTemplates ( ) const

Returns the template tree declared by this node's type.

Returns
Top level templates. Group templates contain child templates recursively.

◆ getType()

const nt::NodeType & enzo::nt::Node::getType ( ) const

Returns the static type definition this node was created from.

The type carries data shared by every node of the same type such as its name and label. Use getType().getName() for the internal type name (eg. "copy_to_points") and getType().getLabel() for the display label (eg. "Copy To Points").

◆ isParameterEnabled()

bool enzo::nt::Node::isParameterEnabled ( std::string_view parmName)

Whether the named parameter's disable condition leaves it enabled.

Returns
True when the condition is empty, unparsable, or not met.

◆ isParameterHidden()

bool enzo::nt::Node::isParameterHidden ( std::string_view parmName)

Whether the named parameter's hide condition currently hides it.

Returns
True only when the condition is present and met.

◆ outputRequested()

bool enzo::nt::Node::outputRequested ( unsigned int outputIndex) const

Returns whether anything downstream is asking for one of the node's outputs.

Todo
Always true until dirtiness is tracked per output.

The documentation for this class was generated from the following files: