1Tree::Simple::Visitor::ULsoeardCCloanstsrHiibeuTrtraeerdec:hP:yeS(ri3lm)pDloec:u:mVeinstiattoiro:n:LoadClassHierarchy(3)
2
3
4
6 Tree::Simple::Visitor::LoadClassHierarchy - A Visitor for loading class
7 hierarchies into a Tree::Simple hierarchy
8
10 use Tree::Simple::Visitor::LoadClassHierarchy;
11
12 # create an visitor
13 my $visitor = Tree::Simple::Visitor::LoadClassHierarchy->new();
14
15 # set class as an instance, or
16 $visitor->setClass($class);
17
18 # as a package name
19 $visitor->setClass("My::Class");
20
21 # pass our visitor to the tree
22 $tree->accept($visitor);
23
24 # the $tree now mirrors the inheritance hierarchy of the $class
25
27 This visitor will traverse a class's inheritance hierarchy (through the
28 @ISA arrays) and create a Tree::Simple hierarchy which mirrors it.
29
31 new There are no arguments to the constructor the object will be in its
32 default state. You can use the "setNodeFilter" method to customize
33 its behavior.
34
35 includeTrunk ($boolean)
36 Setting the $boolean value to true (1) will cause the node value of
37 the $tree object passed into "visit" to be set with the root value
38 found in the class heirarchy. Setting it to false (0), or not set‐
39 ting it, will result in the first value in the class heirarchy cre‐
40 ating a new node level.
41
42 includeMethods ($boolean)
43 Setting the $boolean value to true (1) will cause methods to be
44 added as a children of the class node. Setting it to false (0), or
45 not setting it, will result in this not happening.
46
47 NOTE: Methods are sorted ascii-betically before they are added to
48 the tree. This allows a more predictable heirarchy.
49
50 setClass ($class)
51 The argument $class should be either a class name or an instance,
52 it is then used as the root from which to determine the class hier‐
53 archy.
54
55 setNodeFilter ($filter_function)
56 This method accepts a CODE reference as its $filter_function argu‐
57 ment and throws an exception if it is not a code reference. This
58 code reference is used to filter the tree nodes as they are cre‐
59 ated, the $filter_function is passed the node value extracted from
60 the hash prior to it being inserted into the tree being built. The
61 $filter_function is expected to return the value desired for inclu‐
62 sion into the tree.
63
64 visit ($tree)
65 This is the method that is used by Tree::Simple's "accept" method.
66 It can also be used on its own, it requires the $tree argument to
67 be a Tree::Simple object (or derived from a Tree::Simple object),
68 and will throw and exception otherwise.
69
70 The $tree argument which is passed to "visit" must be a leaf node.
71 This is because this Visitor will create all the sub-nodes for this
72 tree. If the tree is not a leaf, an exception is thrown. We do not
73 require the tree to be a root though, and this Visitor will not
74 affect any nodes above the $tree argument.
75
77 Improve the "includeMethods" functionality
78 I am not sure the tree this creates is the optimal tree for this
79 situation. It is sufficient for now, until I have more of an actual
80 need for this functionality.
81
82 Add "includeFullSymbolTable" functionality
83 This would traverse the full symbol tables and produce a detailed
84 tree of everything it finds. This takes a lot more work, and as I
85 have no current need for it, it remains in the TO DO list.
86
88 None that I am aware of. Of course, if you find a bug, let me know, and
89 I will be sure to fix it.
90
92 See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more
93 inforamtion.
94
96 These Visitor classes are all subclasses of Tree::Simple::Visitor,
97 which can be found in the Tree::Simple module, you should refer to that
98 module for more information.
99
101 stevan little, <stevan@iinteractive.com>
102
104 Copyright 2004, 2005 by Infinity Interactive, Inc.
105
106 <http://www.iinteractive.com>
107
108 This library is free software; you can redistribute it and/or modify it
109 under the same terms as Perl itself.
110
111
112
113perl v5.8.8 2T0r0e5e-:0:7S-i1m3ple::Visitor::LoadClassHierarchy(3)