class ComputationalGraphManager

Overview

Singleton class managing a computational graph. More…

#include <computational_graph_manager.h>

class ComputationalGraphManager {
public:
    // construction

    ComputationalGraphManager(const ComputationalGraphManager&);
    ComputationalGraphManager(ComputationalGraphManager&&);

    // methods

    ComputationalGraphManager& operator = (const ComputationalGraphManager&);
    ComputationalGraphManager& operator = (ComputationalGraphManager&&);
    void registerNode(std::shared_ptr<ComputationalNode>& obj);
    ComputationalNode* getNode(const std::string& id);

    template <class T_IN, class T_OUT>
    void registerEdge(
        OutputPort<T_IN>* source,
        InputPort<T_IN, T_OUT>* target
    );

    void compute();
    void configure();
    void graphLoadComplete();
    void clear();
    void setExecMode(ComputationalGraph::ExecMode mode);
    ComputationalGraph::ExecMode getExecMode();
    static ComputationalGraphManager& getInstance();
    static ComputationalGraphManager& resetInstance();
};

Detailed Documentation

Singleton class managing a computational graph.

ComputationalGraph is only concerned about the graph structure and node execution policies while ComputationalGraphManager remains responsible for managing the registration of nodes and edges, establishing the actual connections between ports. It owns a ComputationalGraph and all its nodes.

Methods

void registerNode(std::shared_ptr<ComputationalNode>& obj)

Register a node in the graph.

If the node is of type ‘Functional’, an attempt to register a node with an ‘id’ already existing is considered an error and an exception is thrown. If the type is different to ‘Functional’ the new node is not registered and the reference obj is shifted to the existing node with the same ‘id’

ComputationalNode* getNode(const std::string& id)

Retrieve a node from the graph as a pointer.

template <class T_IN, class T_OUT>
void registerEdge(
    OutputPort<T_IN>* source,
    InputPort<T_IN, T_OUT>* target
)

Connects an InputPort to an Output port and registers an edge in the graph between their parent nodes.

void compute()

Executes ComputationalGraph.

void configure()

Configure ComputationalGraph.

void graphLoadComplete()

Function to be called externally after all nodes has been added to the graph.

void clear()

Resets ComputationalGraphManager.

static ComputationalGraphManager& getInstance()

Get singleton instance of ComputationalGraphManager.

static ComputationalGraphManager& resetInstance()

Reset singleton instance.