NAME
Data::Hopen::G::GraphBuilder - fluent interface for building graphs
SYNOPSIS
A GraphBuilder wraps a Data::Hopen::G::DAG and a current Data::Hopen::G::Node. It permits building chains of nodes in a fluent way. For example, in an App::hopen hopen file:
# $Build is a Data::Hopen::G::DAG created by App::hopen
use language 'C';
my $builder = $Build->C::compile(file => 'foo.c');
# Now $builder holds $Build (the DAG) and a node created by
# C::compile().
ATTRIBUTES
name
An optional name, in case you want to identify your Builder instances.
dag
The current Data::Hopen::G::DAG instance, if any.
node
The current Data::Hopen::G::Node instance, if any.
INSTANCE FUNCTIONS
add
Adds a node to the graph. Returns the node. Note that this does not change the builder's current node ("node").
default_goal
Links the most recent node in the chain to the default goal in the DAG. If the DAG does not have a default goal, adds one called "all". Clears the builder's record of the current node and returns undef.
goal
Links the most recent node in the chain to the given goal in the DAG. Clears the builder's record of the current node and returns undef.
STATIC FUNCTIONS
make_GraphBuilder
Given the name of a subroutine, wrap the given subroutine for use in a GraphBuilder chain such as that shown in the "SYNOPSIS". Usage:
sub worker {
my $graphbuilder = shift;
...
return $node; # Will automatically be linked into the chain
}
make_GraphBuilder 'worker';
# now worker can take a DAG or GraphBuilder, and the
# return value will be the GraphBuilder.
The worker
subroutine is called in scalar context.