NAME
PNI::Node - is a basic unit of code
SYNOPSIS
# Create a node in a scenario.
use PNI;
my $scenario = PNI::scen;
my $node = $scenario->add_node( type => 'Foo::Bar' );
# Decorate node, add an input and an output.
my $in = $node->in('lead');
my $out = $node->out('gold');
# Fill input data.
$in->data('1Kg');
# Produce something.
$node->task;
# Get output data.
my $gold = $out->data;
ATTRIBUTES
box
father
$node->father;
Returns father
scenario.
ins
outs
type
METHODS
get_ins_edges
get_outs_edges
in
$node->in('input_name');
Creates an input by the given name if such input does not exists.
my $in = $node->in('input_name');
Returns a PNI::In object.
$node->in->data(1);
say $node->in->data;
Default input name is 'in', so you can be lazy.
$node->in(1);
$node->in('in1'); # idem
If you pass digit x
as input_name, it will be replaced by inx
.
is_on
$node->task if $node->is_on;
off
$node->off;
Turn off a node if something is wrong.
sub task {
my $self = shift;
# if "in" is not defined, return and turn off the node.
$self->in->is_defined or return $self->off;
}
on
label
out
$node->out('output_name');
Creates an output by the given name if such output does not exists.
my $out = $node->out('output_name');
Returns a PNI::Out object.
$node->out->data(1);
say $node->out->data;
Default output name is 'out', so you can be lazy.
$node->out(1);
$node->out('out1'); # ditto
If you pass digit x
as output_name, it will be replaced by outx
.
parents
my @parents = $node->parents;
Returns the list of nodes which outputs are connected to the node inputs.