| Graph-Reader-LoadClassHierarchy documentation | Contained in the Graph-Reader-LoadClassHierarchy distribution. |
Graph::Reader::LoadClassHierarchy - load Graphs from class hierarchies
use Graph;
use Graph::Reader::LoadClassHierarchy;
my $reader = Graph::Reader::LoadClassHierarchy->new;
my $graph = $reader->read_graph('Foo::Bar');
Graph::Reader::LoadClassHierarchy is a class for loading a class hierarchy into a directed graph.
my $reader = Graph::Reader::LoadClassHierarchy->new;
Constructor - generate a new reader instance. Doesn't take any arguments.
my $graph = $reader->read_graph( $class_name );
Builds a graph with the class hierarchy of $class_name.
Florian Ragwitz <rafl@debian.org>
Please report any bugs or feature requests to
bug-graph-reader-loadclasshierarchy at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Graph-Reader-LoadClassHierarchy.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Graph::Reader::LoadClassHierarchy
You can also look for information at:
http://cpanratings.perl.org/d/Graph-Reader-LoadClassHierarchy
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Graph-Reader-LoadClassHierarchy
Copyright 2006 Florian Ragwitz, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Graph-Reader-LoadClassHierarchy documentation | Contained in the Graph-Reader-LoadClassHierarchy distribution. |
package Graph::Reader::LoadClassHierarchy; use strict; use warnings; use Graph;
our $VERSION = '0.01';
sub new { my ($class) = @_; my $self = bless {}, $class; return $self; }
sub read_graph { my ($self, $class_name) = @_; my $graph = Graph->new; $graph->add_vertex($class_name); $self->_read_graph($graph, $class_name); return $graph; } sub _read_graph { my ($self, $graph, $class_name) = @_; my @superclasses; { no strict 'refs'; @superclasses = @{ $class_name . '::ISA' }; } for my $superclass (@superclasses) { $graph->add_vertex($superclass); $graph->add_edge( $class_name => $superclass ); $self->_read_graph($graph, $superclass); } }
1; # End of Graph::Reader::LoadClassHierarchy