NAME
SGML::AutoHash - generate visitor and accessor methods for subclasses
SYNOPSIS
use SGML::AutoHash;
package MyClass;
@ISA = qw{SGML::AutoHash};
my $fields = {
'contents' => undef, # default field for `push', `pop', etc.
'foo' => undef,
'bar' => undef,
};
sub fields {
return $fields;
}
DESCRIPTION
AutoHash
automatically generates package methods as they are needed for the following methods:
On the object itself:
accept ($visitor[, ...])
On the default field named `contents':
push ($value)
pop ()
children_accept ($visitor[, ...])
On all fields:
push_FIELD ($value)
pop_FIELD ()
children_accept_FIELD ($visitor[, ...])>
FIELD ()
FIELD ($value)
The accept
methods cause a callback to $visitor
with $self
as the first argument plus the rest of the arguments passed to accept
. This is implemented like:
sub accept {
my $self = shift; my $visitor = shift;
$visitor->visit_MyClass ($self, @_);
}
The children_accept
methods loop through the elements of the array calling accept
on each element.
push
and pop
act like their respective array functions.
FIELD ($value)
sets the value of FIELD. FIELD ()
returns the value of FIELD.
SSGML::Simple::Spec.pm
is a package that uses AutoHash
. AutoHash
is comparable to the module Class::Template
.
AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us
SEE ALSO
perl(1), Class::Template(3)
perltoot - Tom's object-oriented tutorial for perl
<http://www.perl.com/CPAN/doc/FMTEYEWTK/perltoot.html>