functional-dag
Loading...
Searching...
No Matches
fn_dag::dag_fanout_node< Out, IDType > Class Template Reference

Internal node to take data from parent and run children. More...

#include <dag_fanout_impl.hpp>

Public Member Functions

 dag_fanout_node (const _dag_context &_context)
 This node uses data computed from the previous node to fan-out to it's children.
 
 ~dag_fanout_node ()
 Standard deconstructor.
 
void fan_out (unique_ptr< Type > _data)
 Function to move data through the graph.
 
void print (const string &_indent)
 Printing function.
 
template<typename In, typename Out>
expected< IDType, error_codes > add_node_to_subdag (_internal_dag_node< In, Out, IDType > *_node_to_add, const IDType _onto, const IDType _parent_id)
 Recursively adds a node to children.
 

Detailed Description

template<typename Out, typename IDType>
class fn_dag::dag_fanout_node< Out, IDType >

Internal node to take data from parent and run children.

Every node when generating output will send it's output to the nodes children. All child nodes run with the output data being immutable.

Constructor & Destructor Documentation

◆ dag_fanout_node()

template<typename Out, typename IDType>
fn_dag::dag_fanout_node< Out, IDType >::dag_fanout_node ( const _dag_context & _context)
inline

This node uses data computed from the previous node to fan-out to it's children.

This node specifically fans data out and makes sure the children can't modify the data as well as cleaning up the data on the heap when finished

Parameters
_contextThe shared state between the nodes

Member Function Documentation

◆ add_node_to_subdag()

template<typename Out, typename IDType>
template<typename In, typename Out>
expected< IDType, error_codes > fn_dag::dag_fanout_node< Out, IDType >::add_node_to_subdag ( _internal_dag_node< In, Out, IDType > * _node_to_add,
const IDType _onto,
const IDType _parent_id )
inlinenodiscard

Recursively adds a node to children.

This function will check whether the node attaches to the parent of this fan-out. If so, then it becomes a child of the parent function. If it did not attach to parent node, then it will recursively check its children until it finds it. If the parent isn't found, it will return false.

Parameters
_node_to_addThe node to add
_ontoThe ID of the parent the node wants to attach to
_parent_idThe current ID of this nodes parent
Returns
The parent ID if successfully added. Otherwise it returns an error code.

◆ fan_out()

template<typename Out, typename IDType>
void fn_dag::dag_fanout_node< Out, IDType >::fan_out ( unique_ptr< Type > _data)
inline

Function to move data through the graph.

This function will take data from the parent node and execute the subsequent functions with the data. After the subsequent nodes have been run, it deletes the data. The nodes will run on their own threads in the event that run_single_threaded is off. Otherwise, this function will block until the children are finished in a depth-first way.

Parameters
_dataData from the parent node

◆ print()

template<typename Out, typename IDType>
void fn_dag::dag_fanout_node< Out, IDType >::print ( const string & _indent)
inline

Printing function.

This will print recursively to the logging stream the identity of the nodes. This can help ensure the dag was constructed correctly

Parameters
_indentThe parents indent context