NAME

Object::Dependency - maintain a dependency graph

use Object::Dependency;

my $graph = Object::Dependency->new()

$graph->add($object, @objects_the_first_object_depends_upon)

$graph->remove_dependency(@objects_that_are_no_longer_relevant)

@objects_without_dependencies = $graph->independent;

my $addr = $graph->get_addr($item);

my $item = $graph->get_item($addr);

DESCRIPTION

This module maintains a simple dependency graph. Items can be added more than once to note additional depenencies. Dependency relationships cannot be removed except by removing objects entirely.

We do not currently check for cycles so please be careful!

Items are expected to be objects, but do not have to be. Objects are identified by their refadd() so if you combine objects and other scalers, there is some chance of a collision between large intetgers and the refaddr(). The undef value will cause warnings.

CONSTRUCTION

Construction is easy: no parameters are expected.

METHODS

add($object, @depends_upon_objects)

Adds an item ($object) to the dependency graph and notes which items it depends upon.

remove_all_dependencies(@objects)

Removes the @objects from the dependency graph. All objects dependent on @objects will also be removed.

remove_dependency(@objects)

Removes the @objects from the dependency graph. Dependencies upon these objects will be considered to be satisfied.

stuck_dependency($object, $description_of_problem)

Mark that the $object will never be removed from the dependency graph because there is some problem with it. All objects that depend upon $object will now be considered "stuck".

independent(%opts)

Returns a list of objects that do not depend upon other objects. Mark the returned objects as active and locked.

Options are:

count => COUNT

Return at most COUNT items.

active => 1

Normally active objects are not included in the returned list. With active = 1>, active objects are returned.

lock => 1

Normally locked objects are not included in the returned list. With lock = 1>, locked objects are returned.

alldone()

Returns true if there are no non-stuck objects in the dependency graph.

desc($object, $description)

Sets the description of the object (if $description is defined).

Returns the description of the object, annotated by it's dependency graph status: LOCKED, INDEPENDENT, ACTIVE, or STUCK.

Special handling is done for Proc::JobQueue::Job and Proc::JobQueue::DependencyTask objects.

dummp_graph

Prints the dependency graph (described objects with the dependencies).

SEE ALSO

Proc::JobQueue::DependencyQueue

LICENSE

This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 251:

Unknown directive: =haad1