man Data::Grove () - Data::Grove -- support for deeply nested structures

NAME

Data::Grove -- support for deeply nested structures

SYNOPSIS

 use Data::Grove;

 $object = MyPackage->new;

 package MyPackage;
 @ISA = qw{Data::Grove};

DESCRIPTION

CWData::Grove provides support for deeply nested tree or graph structures. CWData::Grove is intended primarily for Perl module authors writing modules with many types or classes of objects that need to be manipulated and extended in a consistent and flexible way.

CWData::Grove is best used by creating a core set of ``data'' classes and then incrementally adding functionality to the core data classes by using ``extension'' modules. One reason for this design is so that the data classes can be swapped out and the extension modules can work with new data sources. For example, these other data sources could be disk-based, network-based or built on top of a relational database.

Two extension modules that come with CWData::Grove are CWData::Grove::Parent and CWData::Grove::Visitor. CWData::Grove::Parent adds a `CWParent' property to grove objects and implements a `CWroot' method to grove objects to return the root node of the tree from anywhere in the tree and a `CWrootpath' method to return a list of nodes between the root node and ``this'' node. CWData::Grove::Visitor adds callback methods `CWaccept' and `CWaccept_name' that call your handler or receiver module back by object type name or the object's name.

CWData::Grove objects do not contain parent references, Perl garbage collection will delete them when no longer referenced and sub-structures can be shared among several structures. CWData::Grove::Parent is used to create temporary objects with parent pointers.

Properties of data classes are accessed directly using Perl's hash functions (i.e. `CW$object->{Property}'). Extension modules may also define properties that they support or use, for example Data::Grove::Parent adds `CWParent' and `CWRaw' properties and Visitor depends on `CWName' and `CWContent' properties.

See the module CWXML::Grove for an example implementation of CWData::Grove.

METHODS

new( PROPERTIES )
Return a new object blessed into the SubClass, with the given properties. PROPERTIES may either be a list of key/value pairs, a single hash containing key/value pairs, or an existing CWData::Grove object. If an existing CWData::Grove is passed to `CWnew()', a shallow copy of that object will be returned. A shallow copy means that you are returned a new object, but all of the objects underneath still refer to the original objects.

AUTHOR

Ken MacLeod, ken@bitsko.slc.ut.us

SEE ALSO