Liz::Tree::Cache - create a cache of Liz::Tree structures of ID's
use Liz::Tree; $tree = new Liz::Tree; $cache = $tree->Cache( $ID );
The Liz::Tree::Cache allows a cache of ID's to be created from a given parent ID. It is usually not called by itself, but as part of the Liz::Tree package.
The following methods create new objects.
Create a new Liz::Tree::Cache object. Normally not called by itself, but from the Liz::Tree module's Cache method.
1 Liz::SQL compatible object to be used 1 parent ID for which to create the cache (default: cache 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 object
$tree = new Liz::Tree( 'ModPerl' ); $cache = $tree->Cache;
The following methods can be used to ``move'' between ID's in the Liz::Tree::Cache object. They are identical to their counterpart methods in the Liz::Tree module, but do not require any SQL-queries.
Return all IDs that are stored in the cache object.
1..N ID's that are in the object
@ID = $cache->IDs;
Return the level of a specific ID in the cache. Levels are counted from the top down.
1 ID of which to return the level
1 the level of the specified ID
$level = $cache->Level( $ID );
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 = $cache->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 of the next thread. Only meaningful if the cache object was created from the top of the tree.
1 ID of which to return the next thread ID
1 next thread ID (undef = invalid ID to start with)
$nextthreadID = $tree->NextThreadID( $currentID );
Return the first ID of the previous thread. Only meaningful if the cache object was created from the top of the tree.
1 ID of which to return the previous thread ID
1 previous thread ID (undef = invalid ID to start with)
$previousthreadID = $tree->PreviousThreadID( $currentID );
The following methods return references to hashes that are stored in the Object.
Return a reference to the hash that contains all the children ID's keyed to ID.
1 reference to the hash
$children = $cache->ChildrenHash;
Return a reference to the hash that contains all the first child ID's keyed to ID.
1 reference to the hash
$firstchild = $cache->FirstChildIDHash;
Return a reference to the hash that contains the level of an ID keyed to ID.
1 reference to the hash
$level = $cache->LevelHash;
Return a reference to the hash that contains the next ID of an ID keyed to ID.
1 reference to the hash
$nextID = $cache->NextIDHash;
Return a reference to the hash that contains the original ID of an ID keyed to ID.
1 reference to the hash
$originalID = $cache->OriginalIDHash;
Return a reference to the hash that contains the parent ID of an ID keyed to ID.
1 reference to the hash
$parentID = $cache->ParentIDHash;
Return a reference to the hash that contains the previous ID of an ID keyed to ID.
1 reference to the hash
$previousID = $cache->PreviousIDHash;
Elizabeth Mattijsen ( lizperl@INC.nl )
(C) 1998-1999 International Network Consultants
Now no longer puts Exporter in ISA: it was not needed.
First version based on the Liz::Forum::List module.