functional-dag
Loading...
Searching...
No Matches
Public Member Functions | List of all members
fn_dag::dag< OriginType, IDType > Class Template Reference

The main DAG function that encapulates generation and mapping of the data across the DAG. More...

#include <dag_impl.hpp>

Inheritance diagram for fn_dag::dag< OriginType, IDType >:

Public Member Functions

 dag (IDType _id, dag_source< OriginType > *_lsource, const _dag_context &_context, bool _startThread)
 Constructor of the DAG.
 
 ~dag ()
 Default deconstructor.
 
IDType get_id ()
 Simple getter for the ID of the DAG itself.
 
void manual_pump (OriginType *_raw_dat)
 Manually pumps some data across the children of the DAG.
 
bool dag_contains (IDType _id)
 Checks whether this DAG contains a specific ID.
 
template<typename In , typename Out >
void add_filter (IDType _newID, dag_node< In, Out > *_new_filter, IDType _on_node)
 Adds a new function to the DAG.
 
void print ()
 Simple print function to print the ID of this DAG and it's children.
 
void push_once ()
 Runs the generator and begins propagating the data to it's children.
 

Detailed Description

template<typename OriginType, typename IDType>
class fn_dag::dag< OriginType, IDType >

The main DAG function that encapulates generation and mapping of the data across the DAG.

The DAG calls the source generator to generate some data. That data is then propagated to it's children and across the entire DAG. The DAG stops propagating across the children of any node of the DAG if the previous parent returns nullptr. Otherwise, this runs either multithreaded or single threaded and can be manually manipulated (i.e. skip the generator) by turning it off and manually calling the manual_pump function.

Constructor & Destructor Documentation

◆ dag()

fn_dag::dag< OriginType, IDType >::dag ( IDType  _id,
dag_source< OriginType > *  _lsource,
const _dag_context _context,
bool  _startThread 
)
inline

Constructor of the DAG.

Ideally this is created in the manager but you can create your own DAG if you'd like.

Parameters
_idThe ID of the DAG itself
_lsourceThe main generator (source) of the DAG. Where data originates
_contextThe context shared across the DAG
_startThreadWhether or not to autostart calling the generator function

◆ ~dag()

Default deconstructor.

Waits for children to stop before cleaning up.

Member Function Documentation

◆ add_filter()

template<typename In , typename Out >
void fn_dag::dag< OriginType, IDType >::add_filter ( IDType  _newID,
dag_node< In, Out > *  _new_filter,
IDType  _on_node 
)
inline

Adds a new function to the DAG.

Since the generator already exists, this function recursively calls itself with the parents nodes type and, in a strongly typed way, attaches a child to the parent to process the data output by the parent node.

Parameters
_newIDThe ID of the new function
_new_filterThe mapping function itself to pass along
_on_nodeThe ID of the parent to attach the function to.

◆ dag_contains()

bool fn_dag::dag< OriginType, IDType >::dag_contains ( IDType  _id)
inline

Checks whether this DAG contains a specific ID.

Given an ID, it will check the optimized hash set to see if the child exists.

Parameters
_idThe ID to lookup
Returns
Whether or not the DAG contains the ID.

◆ get_id()

IDType fn_dag::dag< OriginType, IDType >::get_id ( )
inline

Simple getter for the ID of the DAG itself.

Gets the ID of the DAG.

Returns
ID of the DAG

◆ manual_pump()

void fn_dag::dag< OriginType, IDType >::manual_pump ( OriginType _raw_dat)
inline

Manually pumps some data across the children of the DAG.

This is a useful function for testing. It skips the generator and pushes the test source data across the DAGs children.

Parameters
_raw_datThe raw data that the user provides.

◆ push_once()

void fn_dag::dag< OriginType, IDType >::push_once ( )
inline

Runs the generator and begins propagating the data to it's children.

This function can be called from the thread on a loop or called on a single thread. This encapsulates a single pass across the DAG.