NAME
Tree::Simple::Manager - A class for managing multiple Tree::Simple hierarchies
SYNOPSIS
use Tree::Simple::Manager;
# use the default index and default views
my $tree_manager = Tree::Simple::Manager->new(
"Organizational Level" => {
tree_file_path => "data/organization_level.tree",
tree_root => Tree::Simple->new(Tree::Simple->ROOT),
}
);
# specify your own index class and your own view class
my $tree_manager = Tree::Simple::Manager->new(
"Organizational Level" => {
tree_file_path => "data/organization_level.tree",
tree_root => Tree::Simple->new(Tree::Simple->ROOT),
tree_index => "My::Tree::Indexing::Class",
tree_index => "My::Tree::Simple::View::Class",
}
);
DESCRIPTION
This is a class for managing multiple Tree::Simple hierarchies at a time. It integrates several Tree::Simple classes together to attempt to make things easier to manage. This is the first release of this module. It is currently tailored to my current needs, and will likely get more flexible later on. If you want to use it, and need it to work differently, let me know and I can try to help, or you can submit a patch.
The basic idea of this module is that you can load and store Tree::Simple hierarchies by name. You use Tree::Parser to load the hierarchy from disk, the tree is then indexed for fast node retrieval by Tree::Simple::Manager::Index. If you need a Tree::Simple::View of the tree, you can create one with this class, or get the Tree::Simple::View subclass which is associated with this tree.
METHODS
- new (%tree_configs)
-
This will load all the tree heirachies from disk, index them. The config format is show above in SYNOPSIS, the only required fields are
tree_root
, which must be a Tree::Simple object (or a subclass of Tree::Simple) andtree_file_path
which must be a valid file path to a file which Tree::Parser will understand. - getTreeList
-
This will return a list of names of the tree hierarchies currently being managed.
- getRootTree ($tree_name)
-
This will return the root of the tree found at
$tree_name
. - getTreeIndex ($tree_name)
-
This will return the Tree::Simple::Manager::Index object found at
$tree_name
. - getTreeByID ($tree_name, $tree_id)
-
This will ask the tree index (found at
$tree_name
) for the tree whose id is$tree_id
. - getTreeViewClass ($tree_name)
-
This will return the Tree::Simple::View class associated with
$tree_name
. - getNewTreeView ($tree_name, @view_args)
-
This will return an instance of the Tree::Simple::View class associated with
$tree_name
, passing in the@view_args
to the view constructor.
TO DO
- A bunch of stuff
-
This is the first release of this module. I wrote it a while ago for a specific project, and decided it was useful outside of that project as well. I am sure this can be expanded much further, and I am sure I will discover ways to do that as I use it more and more.
Suggestions, comments and even patches are always welcome.
BUGS
None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it.
CODE COVERAGE
I use Devel::Cover to test the code coverage of my tests, below is the Devel::Cover report on this module test suite.
--------------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt branch cond sub pod time total
--------------------------------- ------ ------ ------ ------ ------ ------ ------
Tree/Simple/Manager.pm 100.0 100.0 66.7 100.0 100.0 47.9 97.5
Tree/Simple/Manager/Exceptions.pm 100.0 n/a n/a 100.0 n/a 4.2 100.0
Tree/Simple/Manager/Index.pm 100.0 75.0 66.7 100.0 100.0 47.9 93.8
--------------------------------- ------ ------ ------ ------ ------ ------ ------
Total 100.0 94.7 66.7 100.0 100.0 100.0 96.7
--------------------------------- ------ ------ ------ ------ ------ ------ ------
SEE ALSO
AUTHOR
stevan little, <stevan@iinteractive.com>
COPYRIGHT AND LICENSE
Copyright 2004 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.