NAME

Liz::Tree::Cache - create a cache of Liz::Tree structures of ID's


SYNOPSIS

 use Liz::Tree;
 $tree = new Liz::Tree;
 $cache = $tree->Cache( $ID );


EXAMPLES


DESCRIPTION

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.


CONSTRUCTOR METHODS

The following methods create new objects.


new

Create a new Liz::Tree::Cache object. Normally not called by itself, but from the Liz::Tree module's Cache method.

Input Parameters

 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)
Output Parameters

 1 instantiated object
Example

 $tree = new Liz::Tree( 'ModPerl' );
 $cache = $tree->Cache;


DIRECTION METHODS

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.


IDs

Return all IDs that are stored in the cache object.

Output Parameters

 1..N ID's that are in the object
Example

 @ID = $cache->IDs;


Level

Return the level of a specific ID in the cache. Levels are counted from the top down.

Input Parameters

 1 ID of which to return the level
Output Parameters

 1 the level of the specified ID
Example

 $level = $cache->Level( $ID );


NextID

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.

Input Parameters

 1 ID of which to return the next ID
 2 flag: whether to not search for children
   (default: search for children)
Output Parameters

 1 next ID
   (undef = no next ID)
Example

 $nextID = $cache->NextID( $currentID );


PreviousID

Return the ID of the previous ID in the tree

Input Parameters

 1 ID of which to return the previous ID
Output Parameters

 1 previous ID
   (undef = no previous ID)
Example

 $previousID = $tree->PreviousID( $currentID );


OriginalID

Return the ID of the original ID (to which the first child was given) in the tree.

Input Parameters

 1 ID of which to return the original ID
Output Parameters

 1 original ID
   (undef = invalid ID to start with)
Example

 $originalID = $tree->OriginalID( $currentID );


ParentID

Return the parent ID of an ID

Input Parameters

 1 ID of which to obtain the parent ID
Output Parameters

 1 parent ID
   (undef: invalid ID specified)
Example

 $parentID = $tree->ParentID( $currentID );


NextThreadID

Return the first ID of the next thread. Only meaningful if the cache object was created from the top of the tree.

Input Parameters

 1 ID of which to return the next thread ID
Output Parameters

 1 next thread ID
   (undef = invalid ID to start with)
Example

 $nextthreadID = $tree->NextThreadID( $currentID );


PreviousThreadID

Return the first ID of the previous thread. Only meaningful if the cache object was created from the top of the tree.

Input Parameters

 1 ID of which to return the previous thread ID
Output Parameters

 1 previous thread ID
   (undef = invalid ID to start with)
Example

 $previousthreadID = $tree->PreviousThreadID( $currentID );


HASH METHODS

The following methods return references to hashes that are stored in the Object.


ChildrenHash

Return a reference to the hash that contains all the children ID's keyed to ID.

Output Parameters

 1 reference to the hash
Example

 $children = $cache->ChildrenHash;


FirstChildIDHash

Return a reference to the hash that contains all the first child ID's keyed to ID.

Output Parameters

 1 reference to the hash
Example

 $firstchild = $cache->FirstChildIDHash;


LevelHash

Return a reference to the hash that contains the level of an ID keyed to ID.

Output Parameters

 1 reference to the hash
Example

 $level = $cache->LevelHash;


NextIDHash

Return a reference to the hash that contains the next ID of an ID keyed to ID.

Output Parameters

 1 reference to the hash
Example

 $nextID = $cache->NextIDHash;


OriginalIDHash

Return a reference to the hash that contains the original ID of an ID keyed to ID.

Output Parameters

 1 reference to the hash
Example

 $originalID = $cache->OriginalIDHash;


ParentIDHash

Return a reference to the hash that contains the parent ID of an ID keyed to ID.

Output Parameters

 1 reference to the hash
Example

 $parentID = $cache->ParentIDHash;


PreviousIDHash

Return a reference to the hash that contains the previous ID of an ID keyed to ID.

Output Parameters

 1 reference to the hash
Example

 $previousID = $cache->PreviousIDHash;


AUTHOR

Elizabeth Mattijsen ( lizperl@INC.nl )


COPYRIGHT

(C) 1998-1999 International Network Consultants


HISTORY

Version 0.11, 30 September 1999

Now no longer puts Exporter in ISA: it was not needed.

Version 0.1, 19 January 1999

First version based on the Liz::Forum::List module.