NAME
dtRdr::NoteThread - an n-ary tree of notes
SYNOPSIS
my (@threads) = dtRdr::NoteThread->create(@notes);
Method Names
Most of the methods from Tree::Simple have been aliased to a lowercase+underscores, terse naming convention (e.g. 'getParent' becomes 'parent', 'getDepth' => 'depth', 'getAllChildren' => 'children', etc.)
- id
-
The thread id (getUID) is the note id.
- note
-
Returns the note object (getNodeValue.)
If possible, use the aliases to work with this package. In the case that I find time to write Tree::Simpler, the javaLike names will vanish.
Identifier Methods
A notethread needs to pretend to be an annotation (in some contexts), so we implement these identifiers.
IS_RANGE_TYPE
true
ANNOTATION_TYPE
notethread
Class Methods
create
Sorts through a pile of notes and turns them all into threads.
my (@threads) = dtRdr::NoteThread->create(@notes);
The threads will be in arbitrary order.
dummy
Creates a dummy note. Copies all of the attributes from the descendant note (in the same thread), except the id and references.
my $note = dtRdr::NoteThread->dummy($id, $descendant);
Constructor
new
See Tree::Simple.
my $thread = dtRdr::NoteThread->new($note, $parent);
Methods
rmap
Depth-first recursion. At each level, $sub is called as $sub->($node, \%ctrl).
The %ctrl hash allows you to send commands back to the dispatcher.
my $sub = sub {
my ($node, $ctrl) = @_;
if(something($node)) {
$ctrl->{prune} = 1; # do not follow children
}
};
$tree->rmap($sub);
AUTHOR
Eric Wilhelm <ewilhelm at cpan dot org>
http://scratchcomputing.com/
COPYRIGHT
Copyright (C) 2007 Eric L. Wilhelm and OSoft, All Rights Reserved.
NO WARRANTY
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
LICENSE
The dotReader(TM) is OSI Certified Open Source Software licensed under the GNU General Public License (GPL) Version 2, June 1991. Non-encrypted and encrypted packages are usable in connection with the dotReader(TM). The ability to create, edit, or otherwise modify content of such encrypted packages is self-contained within the packages, and NOT provided by the dotReader(TM), and is addressed in a separate commercial license.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.