Algorithm-Dependency

 view release on metacpan or  search on metacpan

lib/Algorithm/Dependency/Ordered.pm  view on Meta::CPAN


#pod =pod
#pod
#pod =head1 DESCRIPTION
#pod
#pod Algorithm::Dependency::Ordered implements the most common variety of
#pod L<Algorithm::Dependency>, the one in which the dependencies of an item must
#pod be acted upon before the item itself can be acted upon.
#pod
#pod In use and semantics, this should be used in exactly the same way as for the
#pod main parent class. Please note that the output of the C<depends> method is
#pod NOT changed, as the order of the depends is not assumed to be important.
#pod Only the output of the C<schedule> method is modified to ensure the correct
#pod order.
#pod
#pod For API details, see L<Algorithm::Dependency>.
#pod
#pod =cut

use 5.005;
use strict;

lib/Algorithm/Dependency/Ordered.pm  view on Meta::CPAN


version 1.112

=head1 DESCRIPTION

Algorithm::Dependency::Ordered implements the most common variety of
L<Algorithm::Dependency>, the one in which the dependencies of an item must
be acted upon before the item itself can be acted upon.

In use and semantics, this should be used in exactly the same way as for the
main parent class. Please note that the output of the C<depends> method is
NOT changed, as the order of the depends is not assumed to be important.
Only the output of the C<schedule> method is modified to ensure the correct
order.

For API details, see L<Algorithm::Dependency>.

=head1 SEE ALSO

L<Algorithm::Dependency>

lib/Algorithm/Dependency/Source.pm  view on Meta::CPAN

package Algorithm::Dependency::Source;
# ABSTRACT: Implements a source of hierarchy items

#pod =pod
#pod
#pod =head1 DESCRIPTION
#pod
#pod The Algorithm::Dependency::Source class provides an abstract parent class for
#pod implementing sources for the hierarchy data the algorithm will use. For an
#pod example of an implementation of this, see
#pod L<Algorithm::Dependency::Source::File>, which is bundled with the main
#pod L<Algorithm::Dependency> package.
#pod
#pod =head1 METHODS
#pod
#pod =cut

use 5.005;

lib/Algorithm/Dependency/Source.pm  view on Meta::CPAN

=head1 NAME

Algorithm::Dependency::Source - Implements a source of hierarchy items

=head1 VERSION

version 1.112

=head1 DESCRIPTION

The Algorithm::Dependency::Source class provides an abstract parent class for
implementing sources for the hierarchy data the algorithm will use. For an
example of an implementation of this, see
L<Algorithm::Dependency::Source::File>, which is bundled with the main
L<Algorithm::Dependency> package.

=head1 METHODS

=head2 new @arguments

Although you cannot directly use the C<new> constructor for

lib/Algorithm/Dependency/Source.pm  view on Meta::CPAN

=over 4

=item Overload the C<new> method.

Assuming your subclass takes some form or argument on creation, you will
need to overload the C<new> method to accept the arguments, validate them,
and store them in the source object.

=item Define the method C<_load_item_list>.

Leaving our parent's C<load> method to take care of conflict, errors, and
whatever, the C<_load_item_list> method is used to simply create a list of
L<Algorithm::Dependency::Item> objects from wherever you store the item,
and return them as a list.

=back

Having completed these two things, your subclass should be completed. For
an example of the code, have a look at the source for the simple subclass
L<Algorithm::Dependency::Source::File>.

lib/Algorithm/Dependency/Source/Invert.pm  view on Meta::CPAN

	my @items = $source->items;
	my %hoa   = map { $_->id => [ ] } @items;
	foreach my $item ( @items ) {
		my $id   = $item->id;
		my @deps = $item->depends;
		foreach my $dep ( @deps ) {
			push @{ $hoa{$dep} }, $id;
		}
	}

	# Hand off to the parent class
	$class->SUPER::new( \%hoa );
}

1;

__END__

=pod

=encoding UTF-8



( run in 0.503 second using v1.01-cache-2.11-cpan-a5abf4f5562 )