Liz::Tree - create structures of ID's
use Liz::Tree; $tree = new Liz::Tree;
The Liz::Tree package allows a tree-structure to be created for any ID's that are compatible with the Liz::SQL package.
The following methods create new objects.
Return list of file identification names of all tree(sets) in
the database specified. Usually not called by itself, but rather
incorporated inside a Client Module.
1 Liz::SQL compatible handle or reference to routine that performs connect (default: &Connect from caller's namespace) 2 wildcard specification to match (default: all)
1 reference to list of identification names in the current database 2 reference to hash with full names 2 reference to hash with version info
$hn = new HN;
($id,$name) = $hn->Trees;
$trees = @{$id};
print "All $trees trees in Hospitality Net:\n";
foreach( @{$id} ) {
print " Tree '$$name{$_}' ($_)\n";
}
In HN.pm:
sub Trees { Liz::Tree->trees( @_ ) }
Create a new Liz::Tree object. Normally not called by itself, but with the within a client module.
1 Liz::SQL compatible object to be used 2 identification name of tree (default: the default name of the tree object)
1 instantiated object 2 flag: whether the table was just created
$tree = new Liz::Tree( 'ModPerl' );
Create a cache object that contains all possible structure information for the whole tree, or from a specific parentID down. It in fact creates a Liz::Tree::Cache object, see that module for more information.
1 parent ID of which to create a cache (default: list from top) 2 number of levels of recursion for creation of cache (default: 0, -1 for maximum number of levels, >0 limited number of levels) 3 maximum number of ID's to obtain (default: unlimited)
1 instantiated cache object
$cache = $tree->Cache; $cache = $tree->Cache( $parentID );
The following methods allow changes to information that is associated with the list object.
Reset all ID information in the table.
$tree->Reset; print "All structure to messages has been removed\n";
Add an ID at the specified position. Move the ID to the indicated position if the ID is already in the list.
1 ID to be added or moved 2 ID of parent to which this ID belongs (default: 0 = top level) 3 ID (if top level) after which this ID should be added (default: at end)
$tree->AddID( $newthreadID ); $tree->AddID( $newresponseID,$parentID );
Delete an ID and all the ID's that have that ID as a (grand) parent. Optionally allows the ID's below to be saved: in that case they will appended to the children list of the parent of the ID being deleted.
1 ID to be deleted
2 flag: whether to delete just this ID
(default: delete all ID's below also)
1..N ID's that were deleted
@removedID = $tree->DeleteID( $deleteID );
Returns whether an ID exists in the list.
1 ID to check for
1 flag: true if ID found
if( $tree->ExistsID( $isitID ) ) {
print "ID $isitID exists in this list\n";
}
Return the child ID's of an ID
1 ID of which to obtain children
(default: top = 0)
2 flag: whether to obtain all grandchildren also
(default: just own children)
1..N ID's of the children of given ID
@childID = $tree->ChildIDs( $currentID );
The following methods can be used to ``move'' between messages in the Liz::Tree object.
Return the ID of the next ID in the tree. By default, this is the first child of the current ID, or the next ID if there are no children. If children search is inhibited, then the next ID on the same level will be returned.
The ID of the next ID will always be returned, unless the current ID is actually the very, very last ID in the tree.
1 ID of which to return the next ID 2 flag: whether to not search for children (default: search for children)
1 next ID (undef = no next ID)
$nextID = $tree->NextID( $currentID );
Return the ID of the previous ID in the tree
1 ID of which to return the previous ID
1 previous ID (undef = no previous ID)
$previousID = $tree->PreviousID( $currentID );
Return the ID of the original ID (to which the first child was given) in the tree.
1 ID of which to return the original ID
1 original ID (undef = invalid ID to start with)
$originalID = $tree->OriginalID( $currentID );
Return the parent ID of an ID
1 ID of which to obtain the parent ID
1 parent ID (undef: invalid ID specified)
$parentID = $tree->ParentID( $currentID );
Return the first ID in the next thread
1 ID of which to return the first ID in next thread 2 original ID (default: lookup)
1 first ID in next thread (undef = no next thread)
$nextthreadID = $tree->NextThreadID( $currentID );
Return the first ID in the previous thread
1 ID of which to return the first ID in previous thread 2 original ID (default: lookup)
1 first ID in previous thread (undef = no previous thread)
$previousthreadID = $tree->PreviousThreadID( $currentID );
Elizabeth Mattijsen ( lizperl@INC.nl )
With contributions by:
- Sjoerd Lawende ( sjoerd@xxLINK.nl )
(C) 1998-1999 International Network Consultants
Put module name between quotes to fix obscure bug in Perl 5.005x under ModPerl in method Cache.
Now no longer puts Exporter in ISA: it was not needed.
New method trees added: list all possible tree(sets) in the client module.
Method new now also returns the created flag.
Support for field ``TOKEN'' added.
Method new now uses the Liz::SQL ``new'' method to create the object.
Made regular expressions constant were possible, thereby increasing execution speed at the expense of memory footprint.
Change to new source typography.
Changed field 'responses' to 'children' in update query of method AddID.
Changed CREATE TABLE to new Liz::SQL 'create' method format.
Changed from using method ``Exists'' to ``Count'' in method new to allow for a much faster check for the existence of a table.
First version based on the Liz::Forum::List module.