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

The DAG manager manages all of the dags created by the user. More...

#include <filter_sys.hpp>

Public Member Functions

 dag_manager ()
 Default constructor.
 
 ~dag_manager ()
 Default deconstructor.
 
template<typename In , typename Out >
void add_node (IDType _id, dag_node< In, Out > *_new_filter, IDType _onto)
 Implementation to template funcs must be visible to link correctly.
 
bool manager_contains_id (IDType _id)
 Containment function for checking presence.
 
void set_indention_string (string _new_indent_str)
 Indentation delimiter.
 
void set_logging_stream (std::ostream *_new_stream)
 Set a logging stream to print to.
 
void run_single_threaded (bool _is_single_threaded)
 Sets whether to run the DAGs on the same thread.
 
template<typename Out >
dag< Out, IDType > * add_dag (IDType _id, dag_source< Out > *_new_filter, bool _startImmediately)
 Starts a new DAG with a given source of data out.
 
void print_all_dags ()
 Print all of the trees for verification purposes.
 
void stahp ()
 Stops all of the DAGs from generating data out.
 
void clear ()
 Clears all of the DAGs out of the "forest" of DAGs.
 

Public Attributes

vector< _dag_base< IDType > * > m_all_dags
 All of the DAGs the manager maintains.
 

Detailed Description

template<typename IDType>
class fn_dag::dag_manager< IDType >

The DAG manager manages all of the dags created by the user.

Think of it like a forest of trees.

The dag manager is the main interfaces that users should interact with. You should be able to create new root nodes (sources) and add leaves along the way (nodes).

Constructor & Destructor Documentation

◆ dag_manager()

template<typename IDType >
fn_dag::dag_manager< IDType >::dag_manager ( )
inline

Default constructor.

Begins in the "on" state and in multi-threaded mode.

Member Function Documentation

◆ add_dag()

template<typename IDType >
template<typename Out >
dag< Out, IDType > * fn_dag::dag_manager< IDType >::add_dag ( IDType  _id,
dag_source< Out > *  _new_filter,
bool  _startImmediately 
)
inline

Starts a new DAG with a given source of data out.

This begins a new dag (tree) that must generate output data sequentially.

Parameters
_idThe DAGs name
_new_filterThe generator function.
_startImmediatelyWhether or not to begin generating data on a loop immediately.
Returns
Returns the created DAG if the user wants it. Otherwise, NULL if something fails.

◆ add_node()

template<typename IDType >
template<typename In , typename Out >
void fn_dag::dag_manager< IDType >::add_node ( IDType  _id,
dag_node< In, Out > *  _new_filter,
IDType  _onto 
)
inline

Implementation to template funcs must be visible to link correctly.

Use this function to add a lambda function onto a parent.

Parameters
_idThe node's name for later referencing
_new_filterThe lambda function to run fromt he parent
_ontoThe node ID of the parent to attach the lambda function on to.

◆ clear()

template<typename IDType >
void fn_dag::dag_manager< IDType >::clear ( )
inline

Clears all of the DAGs out of the "forest" of DAGs.

This doesn't stop the nodes, this simply clears out the tracked DAGs so if you need to stop the DAGs and maintain the pointers manually, feel free to do so.

◆ manager_contains_id()

template<typename IDType >
bool fn_dag::dag_manager< IDType >::manager_contains_id ( IDType  _id)
inline

Containment function for checking presence.

This function simply looks for an ID on all dags

Parameters
_idThe ID to check for
Returns
Whether or not any of the dags contain the ID provided.

◆ print_all_dags()

template<typename IDType >
void fn_dag::dag_manager< IDType >::print_all_dags ( )
inline

Print all of the trees for verification purposes.

Simply prints all of the dags and their nodes to the given output stream. Defaults to std::cout.

◆ run_single_threaded()

template<typename IDType >
void fn_dag::dag_manager< IDType >::run_single_threaded ( bool  _is_single_threaded)
inline

Sets whether to run the DAGs on the same thread.

Setter that will let all new nodes be created on separate threads or on the same thread as it was called on.

This has unsafe behavior when set during a single dags construction. This can be set between each dags creation, however.

Parameters
_is_single_threadedWhether or not new nodes and source nodes are on same node.

◆ set_indention_string()

template<typename IDType >
void fn_dag::dag_manager< IDType >::set_indention_string ( string  _new_indent_str)
inline

Indentation delimiter.

Setter for the print function to set the identation spaces between nodes when printing the dags.

Parameters
_new_indent_strThe new indentation string. These are concatenated.

◆ set_logging_stream()

template<typename IDType >
void fn_dag::dag_manager< IDType >::set_logging_stream ( std::ostream *  _new_stream)
inline

Set a logging stream to print to.

Logging is complicated. As long as the user conforms to a std::ostream then they can override the printout stream to print elsewhere like a file or another interleaved stream instead of std::cout.

Parameters
_new_streamThe new stream to print to for debug messaging.

◆ stahp()

template<typename IDType >
void fn_dag::dag_manager< IDType >::stahp ( )
inline

Stops all of the DAGs from generating data out.

Stops all of the DAGs from generating data out. Fair warning, sometimes it takes a second for the nodes to complete.