flow  3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | List of all members
flow::graph Class Reference

Object that manages the connections and state of multiple nodes. More...

#include <graph.h>

Inheritance diagram for flow::graph:
Inheritance graph
[legend]
Collaboration diagram for flow::graph:
Collaboration graph
[legend]

Public Member Functions

 graph (const std::string name_r="graph")
 
virtual void add (std::shared_ptr< node > node_p, const std::string &name_r=std::string())
 Adds a node to the graph.
 
virtual std::shared_ptr< noderemove (const std::string &name_r)
 Removes a node from the graph.
 
virtual void remove (const std::shared_ptr< node > &sp_node)
 Removes a node from the graph.
 
template<typename T >
bool connect (const std::string &p_name_r, const size_t p_pin, const std::string &c_name_r, const size_t c_pin, const size_t max_length=0, const size_t max_weight=0)
 Connects two nodes' pins from the graph together.
 
template<typename T >
bool connect (std::shared_ptr< flow::producer< T >> sp_p, const size_t p_pin, std::shared_ptr< flow::consumer< T >> sp_c, const size_t c_pin, const size_t max_length=0, const size_t max_weight=0)
 Connects two nodes' pins from the graph together.
 
template<typename T >
void disconnect (std::shared_ptr< flow::producer< T >> sp_p, const size_t p_pin)
 Disconnects a node's pin.
 
template<typename T >
void disconnect (std::shared_ptr< flow::consumer< T >> sp_c, const size_t c_pin)
 Disconnects a node's pin.
 
virtual void start ()
 Starts all nodes in the graph.
 
virtual void pause ()
 Pauses all nodes in the graph.
 
virtual void stop ()
 Stops all nodes in the graph.
 
virtual std::ostream & to_dot (std::ostream &o)
 Produces a dot syntax of the graph.
 
- Public Member Functions inherited from flow::named
 named (const std::string &name_r)
 Constructor the takes a name.
 
 named (named &&name_rr)
 Move constructor.
 
 named (const named &name_r)
 Copy constructor.
 
virtual const std::string & name () const
 A const reference to this object's name.
 
virtual std::string rename (const std::string &name_r)
 Sets this object's name to a new name.
 

Detailed Description

Object that manages the connections and state of multiple nodes.

When starting or stopping a graph, nodes are started and stopped in a fashion to minize build-up of packets.

Constructor & Destructor Documentation

flow::graph::graph ( const std::string  name_r = "graph")
inline
Parameters
name_rThe name of this graph.

Member Function Documentation

virtual void flow::graph::add ( std::shared_ptr< node node_p,
const std::string &  name_r = std::string() 
)
inlinevirtual

Adds a node to the graph.

The node will initially be disconnected and paused.

Parameters
node_pPointer to the node to add.
name_rOptional. New name to give the node.
virtual std::shared_ptr<node> flow::graph::remove ( const std::string &  name_r)
inlinevirtual

Removes a node from the graph.

Parameters
name_rThe name of the node to remove.
Returns
Node that was removed.
virtual void flow::graph::remove ( const std::shared_ptr< node > &  sp_node)
inlinevirtual

Removes a node from the graph.

Parameters
sp_nodeThe name of the node to remove.
template<typename T >
bool flow::graph::connect ( const std::string &  p_name_r,
const size_t  p_pin,
const std::string &  c_name_r,
const size_t  c_pin,
const size_t  max_length = 0,
const size_t  max_weight = 0 
)
inline

Connects two nodes' pins from the graph together.

Parameters
p_name_rName of the producing node.
p_pinThe index of the producing node's output pin to connect.
c_name_rName of the consuming node.
c_pinThe index of the consuming node's input pin to connect.
max_lengthThe maximum length to give the pipe. Do not set or set to 0 for uncapped length.
max_weightThe maximum weight to give the pipe. Do not set or set to 0 for uncapped weight.
Returns
False if the nodes had not yet been added to the graph.
template<typename T >
bool flow::graph::connect ( std::shared_ptr< flow::producer< T >>  sp_p,
const size_t  p_pin,
std::shared_ptr< flow::consumer< T >>  sp_c,
const size_t  c_pin,
const size_t  max_length = 0,
const size_t  max_weight = 0 
)
inline

Connects two nodes' pins from the graph together.

Parameters
sp_pThe producing node.
p_pinThe index of the producing node's output pin to connect.
sp_cThe consuming node.
c_pinThe index of the consuming node's input pin to connect.
max_lengthThe maximum length to give the pipe. Do not set or set to 0 for uncapped length.
max_weightThe maximum weight to give the pipe. Do not set or set to 0 for uncapped weight.
Returns
False if the nodes had not yet been added to the graph.
template<typename T >
void flow::graph::disconnect ( std::shared_ptr< flow::producer< T >>  sp_p,
const size_t  p_pin 
)
inline

Disconnects a node's pin.

Parameters
sp_pThe node.
p_pinThe pin's index.
template<typename T >
void flow::graph::disconnect ( std::shared_ptr< flow::consumer< T >>  sp_c,
const size_t  c_pin 
)
inline

Disconnects a node's pin.

Parameters
sp_cThe node.
c_pinThe pin's index.
virtual void flow::graph::start ( )
inlinevirtual

Starts all nodes in the graph.

To avoid packet build-up in pipes, pure consuming node are started first, transforming nodes second and pure producing nodes last. If a node had been stopped earlier, a new thread is created for it.

virtual void flow::graph::pause ( )
inlinevirtual

Pauses all nodes in the graph.

To avoid packet build-up in pipes, pure producing node are paused first, transforming nodes second and pure consuming nodes last.

virtual void flow::graph::stop ( )
inlinevirtual

Stops all nodes in the graph.

node::stop() is called on all nodes.

virtual std::ostream& flow::graph::to_dot ( std::ostream &  o)
inlinevirtual

Produces a dot syntax of the graph.

Parameters
oThe output stream to output the syntax.

The documentation for this class was generated from the following file: