functional-dag
Loading...
Searching...
No Matches
fn_dag::library Class Reference

(Library related) A library defines what is needed to construct a dag tree. More...

#include <lib_utils.h>

Public Member Functions

expected< bool, fn_dag::error_codes > load_lib (const fs::path _lib_path)
 This function loads the library and keeps the constructor around for subsequent asks to create the node.
 
void load_all_available_libs (const fs::directory_entry &_library_path)
 This function is for convenience.
 
expected< fn_dag::dag_manager< string > *, fn_dag::error_codes > fsys_deserialize (const string &_json_in)
 Takes highly structured JSON in and turns it into a lambda dag.
 

Static Public Member Functions

static bool preflight_lib (const fs::path _lib_path)
 A quick and easy function to test whether a dynamic library conforms to the library specifications.
 

Protected Member Functions

expected< bool, fn_dag::error_codes > _create_node (dag_manager< string > &_manager, const fn_dag::node_spec *const _spec)
 Private function to verify parameters, create the node, and attach it.
 

Protected Attributes

map< GUID< node_spec >, function< construction_signature > > m_constructors
 A mapping between IDs to the constructors that create the nodes; The user will need to define these libraries.constructors in their dynamic libraries.
 
map< GUID< node_spec >, vector< option_spec > > m_options
 This is a parallel data structure that ensures that whatever options/parameters are passed to it at runtime conform to the expectations of the constructors signature.
 

Detailed Description

(Library related) A library defines what is needed to construct a dag tree.

The library is a utility that defines an interface for dynamic libraries to be loaded into the library. Once a set number of nodes are available to be constructed from the dynamic libraries, users can define a "pipe" which represents the dag to be added to a manager to be managed.

Member Function Documentation

◆ _create_node()

expected< bool, fn_dag::error_codes > fn_dag::library::_create_node ( dag_manager< string > & _manager,
const fn_dag::node_spec *const _spec )
protected

Private function to verify parameters, create the node, and attach it.

Parameters
_managerA dag manager to attach the new node to.
_specSpecifications about which node and what parameters should be used to create it.
Returns
If successful, returns true but if not, then it returns an error code.

◆ fsys_deserialize()

expected< fn_dag::dag_manager< string > *, fn_dag::error_codes > fn_dag::library::fsys_deserialize ( const string & _json_in)
nodiscard

Takes highly structured JSON in and turns it into a lambda dag.

In some ways this can be considered the casual user's interface to this entire library. This function will connect the functional dag's functionality to a simple JSON specification. It will check if the node specified in the JSON file is available.

Parameters
_json_inThe JSON specification to create the DAG structure.
Returns
A normal dag manager to start/stop/modify if successful and an error if unsuccessful.

◆ load_all_available_libs()

void fn_dag::library::load_all_available_libs ( const fs::directory_entry & _library_path)

This function is for convenience.

This function takes a directory and iterates through the .so or .dylibs. It will preflight them and load them if they are indeed compatible.

Parameters
_library_pathA path where many .so and .dylibs are expected to be.

◆ load_lib()

expected< bool, fn_dag::error_codes > fn_dag::library::load_lib ( const fs::path _lib_path)
nodiscard

This function loads the library and keeps the constructor around for subsequent asks to create the node.

It is recommended to preflight the library before loading it but not necessary. This is only due to the heavyweight nature of this funciton compared to preflight. Once The library is known to be compatible with the signatures, then this function will load the dynamic library and store it's constructors and specifications to be used later during construction.

Parameters
_lib_pathThe path to the dynamic library.
Returns
True if successfully loaded; otherwise an error code is passed providing more info.

◆ preflight_lib()

static bool fn_dag::library::preflight_lib ( const fs::path _lib_path)
staticnodiscard

A quick and easy function to test whether a dynamic library conforms to the library specifications.

If the user of the library would like to check if a dynamic library could be tracked and used to create nodes, then this function will help you check. It's meant to be a stateless way to just double check before asking the library to load it.

Parameters
_lib_pathThe path to the dynamic library
Returns
True if loadable; false otherwise.