1Tree::Simple::VisitorFaUcsteorryC(o3n)tributed Perl DocuTmreenet:a:tSiiomnple::VisitorFactory(3)
2
3
4

NAME

6       Tree::Simple::VisitorFactory - A factory object for dispensing Visitor
7       objects
8

SYNOPSIS

10         use Tree::Simple::VisitorFactory;
11
12         my $tf = Tree::Simple::VisitorFactory->new();
13
14         my $visitor = $tf->get("PathToRoot");
15
16         # or call it as a class method
17         my $visitor = Tree::Simple::VisitorFactory->getVisitor("PathToRoot");
18

DESCRIPTION

20       This object is really just a factory for dispensing Tree::Simple::Visi‐
21       tor::* objects. It is not required to use this package in order to use
22       all the Visitors, it is just a somewhat convienient way to avoid having
23       to type thier long class names.
24
25       I considered making this a Singleton, but I did not because I thought
26       that some people might not want that. I know that I am very picky about
27       using Singletons, especially in multiprocess environments like
28       mod_perl, so I implemented the smallest instance I knew how to, and
29       made sure all other methods could be called as class methods too.
30

METHODS

32       new Returns an minimal instance of this object, basically just a refer‐
33           ence back to the package (literally, see the source if you care).
34
35       get ($visitor_type)
36           Attempts to load the $visitor_type and returns an instance of it if
37           successfull. If no $visitor_type is specified an exception is
38           thrown, if $visitor_type fails to load, and exception is thrown.
39
40       getVisitor ($visitor_type)
41           This is an alias of "get".
42

AVAILABLE VISITORS

44       This distibution provides a number of Visitor objects which can be
45       loaded just by giving their name. Below is a description of the avail‐
46       able Visitors and a sort description of what they do. I have attempted
47       to classify the Visitors into groups which are related to their use.
48
49       This factory will load any module contained inside the Tree::Sim‐
50       ple::Visitor::* namespace. Given a name, it will attempt to "require"
51       the module Tree::Simple::Visitor::<Name>.pm. This allows others to cre‐
52       ate Visitors which can be accessed with this factory, without needed to
53       include them in this distrobution.
54
55       Search/Path Related Visitors
56
57       PathToRoot
58           Given a Tree::Simple object, this Visitor will find the path back
59           to the tree's root node.
60
61       FindByPath
62           Given a path and Tree::Simple hierarchy, this Visitor will attempt
63           to find the node specified by the path.
64
65       FindByUID
66           Given a UID and Tree::Simple hierarchy, this Visitor will attempt
67           to find the node with the same UID.
68
69       FindByNodeValue
70           Given a node value and Tree::Simple hierarchy, this Visitor will
71           attempt to find the node with the same node value.
72
73       Traversal Visitors
74
75       BreadthFirstTraversal
76           This implements a breadth-first traversal of a Tree::Simple hierar‐
77           chy.
78
79       PostOrderTraversal
80           Post-order traversal is a variation of the depth-first traversal in
81           which the sub-tree's are processed before the parent.
82
83       PreOrderTraversal
84           Pre-order traversal is a depth-first traversal method in which the
85           sub-tree's are processed after the parent.
86
87       FileSystem Visitors
88
89       LoadDirectoryTree
90           This visitor can be used to load a directory tree into a Tree::Sim‐
91           ple hierarchy.
92
93       CreateDirectoryTree
94           This visitor can be used to create a set of directories and files
95           from a Tree::Simple object hierarchy.
96
97       Conversion Visitors
98
99       FromNestedArray
100           Given a tree constructed from nested arrays, this Visitor will cre‐
101           ate the equivalent Tree::Simple heirarchy.
102
103       ToNestedArray
104           Given a Tree::Simple heirarchy, this Visitor will create the equiv‐
105           alent tree constructed from nested arrays.
106
107       FromNestedHash
108           Given a tree constructed from nested hashs, this Visitor will cre‐
109           ate the equivalent Tree::Simple heirarchy.
110
111       ToNestedHash
112           Given a Tree::Simple heirarchy, this Visitor will create the equiv‐
113           alent tree constructed from nested hashes.
114
115       Reflective Visitors
116
117       LoadClassHierarchy
118           Given a class name or instance, this Visitor will create a
119           Tree::Simple hierarchy which models the classes inheritance heirar‐
120           chy.
121
122       Misc. Visitors
123
124       GetAllDescendents
125           Given a Tree::Simple instance this Visitor will return all the
126           descendents recursively on down the hierarchy.
127
128       Sort
129           This implements a multi-level sort of a Tree::Simple heirarchy.
130
131       VariableDepthClone
132           A Visitor for cloning parts of Tree::Simple hierarchy
133

BUGS

135       None that I am aware of. Of course, if you find a bug, let me know, and
136       I will be sure to fix it.
137

CODE COVERAGE

139       I use Devel::Cover to test the code coverage of my tests, below is the
140       Devel::Cover report on this module test suite.
141
142        -------------------------------------------- ------ ------ ------ ------ ------ ------ ------
143        File                                           stmt branch   cond    sub    pod   time  total
144        -------------------------------------------- ------ ------ ------ ------ ------ ------ ------
145        Tree/Simple/VisitorFactory.pm                 100.0  100.0    n/a  100.0  100.0    0.4  100.0
146        Tree/Simple/Visitor/BreadthFirstTraversal.pm  100.0  100.0   66.7  100.0  100.0    2.5   96.3
147        Tree/Simple/Visitor/PostOrderTraversal.pm     100.0  100.0   77.8  100.0  100.0    1.7   96.3
148        Tree/Simple/Visitor/PreOrderTraversal.pm      100.0    n/a   33.3  100.0  100.0    0.7   90.5
149        Tree/Simple/Visitor/CreateDirectoryTree.pm    100.0   85.7   86.7  100.0  100.0    3.4   95.8
150        Tree/Simple/Visitor/LoadClassHierarchy.pm     100.0   73.1   33.3  100.0  100.0    4.9   89.2
151        Tree/Simple/Visitor/LoadDirectoryTree.pm      100.0   89.3   85.2  100.0  100.0   26.1   94.7
152        Tree/Simple/Visitor/FindByNodeValue.pm        100.0  100.0   86.7  100.0  100.0    3.1   98.3
153        Tree/Simple/Visitor/FindByPath.pm             100.0  100.0   66.7  100.0  100.0    1.2   97.9
154        Tree/Simple/Visitor/FindByUID.pm              100.0  100.0   86.7  100.0  100.0    2.9   98.3
155        Tree/Simple/Visitor/GetAllDescendents.pm      100.0  100.0   77.8  100.0  100.0    2.3   97.1
156        Tree/Simple/Visitor/PathToRoot.pm             100.0   87.5   75.0  100.0  100.0    0.8   95.1
157        Tree/Simple/Visitor/Sort.pm                   100.0  100.0   77.8  100.0  100.0    8.8   98.1
158        Tree/Simple/Visitor/ToNestedArray.pm          100.0  100.0   66.7  100.0  100.0    1.5   96.5
159        Tree/Simple/Visitor/ToNestedHash.pm           100.0  100.0   66.7  100.0  100.0    1.4   96.5
160        Tree/Simple/Visitor/FromNestedArray.pm        100.0   94.4   81.8  100.0  100.0    8.1   96.6
161        Tree/Simple/Visitor/FromNestedHash.pm         100.0   91.7   77.8  100.0  100.0    4.8   95.9
162        Tree/Simple/Visitor/VariableDepthClone.pm     100.0  100.0   66.7  100.0  100.0   25.5   97.3
163        -------------------------------------------- ------ ------ ------ ------ ------ ------ ------
164        Total                                         100.0   93.8   76.3  100.0  100.0  100.0   96.1
165        -------------------------------------------- ------ ------ ------ ------ ------ ------ ------
166

SEE ALSO

168       These Visitor classes are meant to work with Tree::Simple hierarchies,
169       you should refer to that module for more information.
170

AUTHOR

172       stevan little, <stevan@iinteractive.com>
173
175       Copyright 2004, 2005 by Infinity Interactive, Inc.
176
177       <http://www.iinteractive.com>
178
179       This library is free software; you can redistribute it and/or modify it
180       under the same terms as Perl itself.
181
182
183
184perl v5.8.8                       2005-07-13   Tree::Simple::VisitorFactory(3)
Impressum