NAME

PNI::Scenario - is a set of nodes connected by edges

SYNOPSIS

# You can call the constructor to get a scenario ...
use PNI::Scenario;
$standalone_scenario = PNI::Scenario->new;

# ... but it will not belong to PNI hierarchy tree,
# so its task method will not be called, unless you call it.
$standalone_scenario->task;

# You can start adding a scenario to the PNI root.
use PNI;
my $scenario = PNI::root->add_scenario;

# Add two nodes.
my $foo = $scenario->add_node('Foo');
my $bar = $scenario->add_node('Bar');

# Connect nodes with an edge.
$scenario->add_edge( $foo => $bar, 'out' => 'in' );

# Calling PNI task method will execute all the tasks once.
PNI::task;

# Or call PNI loop to keep it running.
PNI::loop;

DESCRIPTION

A scenario is a directed graph of subs called task.

ATTRIBUTES

edges

my @edges = $scenario->edges->list;

A PNI::Set containing <PNI::Edge>s.

nodes

my @nodes = $scenario->nodes->list;

A PNI::Set containing <PNI::Node>s.

scenarios

my @scenarios = $scenario->scenarios->list;

A PNI::Set containing <PNI::Scenario>s.

METHODS

add_edge

add_node

add_scenario

$sub_scenario = $scenario->add_scenario;

del_edge

del_node

del_scenario

task

$scen->task;

Probably the most important PNI method. The task of a scenario is to trigger every node (and scenario) it contains to run its own task, following the natural order.

to_hash

my $data_hashref = $scen->to_hash;