use strict;
use warnings;

use ChemPlugin;

$|=1;

print "Link ChemPlugin instances into a one-dimensional chain\n\n";

# Create the ChemPlugin instances
my $nchain = 8;
my $cp_inlet = new ChemPlugin();
my @cp = ();
for (my $i=0; $i<$nchain; $i++){
   push(@cp, new ChemPlugin());
}

# Link the instances into a chain
$cp[0]->Link($cp_inlet);
for (my $i=1; $i<$nchain; $i++){
   $cp[$i]->Link($cp[$i-1]);
}
$cp[$nchain-1]->Link(); #creates outlet link

# Report the number of links to each instance
print "Inlet is linked to ". $cp_inlet->nLinks() ." instance\n";

for (my$i=0; $i<$nchain; $i++){
   print "Instance $i is linked to ". $cp[$i]->nLinks() ." instances\n";
}


