1Data::Grove(3) User Contributed Perl Documentation Data::Grove(3)
2
3
4
6 Data::Grove -- support for deeply nested structures
7
9 use Data::Grove;
10
11 $object = MyPackage->new;
12
13 package MyPackage;
14 @ISA = qw{Data::Grove};
15
17 "Data::Grove" provides support for deeply nested tree or graph struc‐
18 tures. "Data::Grove" is intended primarily for Perl module authors
19 writing modules with many types or classes of objects that need to be
20 manipulated and extended in a consistent and flexible way.
21
22 "Data::Grove" is best used by creating a core set of ``data'' classes
23 and then incrementally adding functionality to the core data classes by
24 using ``extension'' modules. One reason for this design is so that the
25 data classes can be swapped out and the extension modules can work with
26 new data sources. For example, these other data sources could be
27 disk-based, network-based or built on top of a relational database.
28
29 Two extension modules that come with "Data::Grove" are
30 "Data::Grove::Parent" and "Data::Grove::Visitor". "Data::Grove::Par‐
31 ent" adds a `"Parent"' property to grove objects and implements a
32 `"root"' method to grove objects to return the root node of the tree
33 from anywhere in the tree and a `"rootpath"' method to return a list of
34 nodes between the root node and ``this'' node. "Data::Grove::Visitor"
35 adds callback methods `"accept"' and `"accept_name"' that call your
36 handler or receiver module back by object type name or the object's
37 name.
38
39 "Data::Grove" objects do not contain parent references, Perl garbage
40 collection will delete them when no longer referenced and sub-struc‐
41 tures can be shared among several structures. "Data::Grove::Parent" is
42 used to create temporary objects with parent pointers.
43
44 Properties of data classes are accessed directly using Perl's hash
45 functions (i.e. `"$object->{Property}"'). Extension modules may also
46 define properties that they support or use, for example
47 Data::Grove::Parent adds `"Parent"' and `"Raw"' properties and Visitor
48 depends on `"Name"' and `"Content"' properties.
49
50 See the module "XML::Grove" for an example implementation of
51 "Data::Grove".
52
54 new( PROPERTIES )
55 Return a new object blessed into the SubClass, with the given prop‐
56 erties. PROPERTIES may either be a list of key/value pairs, a sin‐
57 gle hash containing key/value pairs, or an existing "Data::Grove"
58 object. If an existing "Data::Grove" is passed to `"new()"', a
59 shallow copy of that object will be returned. A shallow copy means
60 that you are returned a new object, but all of the objects under‐
61 neath still refer to the original objects.
62
64 Ken MacLeod, ken@bitsko.slc.ut.us
65
67 perl(1)
68
69
70
71perl v5.8.8 2003-10-21 Data::Grove(3)