.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "ObjectTemplate 3pm" .TH ObjectTemplate 3pm "2022-06-11" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Class::ObjectTemplate \- Perl extension for an optimized template builder base class. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& package Foo; \& use Class::ObjectTemplate; \& require Exporter; \& @ISA = qw(Class::ObjectTemplate Exporter); \& \& attributes(\*(Aqone\*(Aq, \*(Aqtwo\*(Aq, \*(Aqthree\*(Aq); \& \& # initialize will be called by new() \& sub initialize { \& my $self = shift; \& $self\->three(1) unless defined $self\->three(); \& } \& \& use Foo; \& $foo = Foo\->new(); \& \& # store 27 in the \*(Aqone\*(Aq attribute \& $foo\->one(27); \& \& # check the value in the \*(Aqtwo\*(Aq attribute \& die "should be undefined" if defined $foo\->two(); \& \& # set using the utility method \& $foo\->set_attribute(\*(Aqone\*(Aq,27); \& \& # check using the utility method \& $two = $foo\->get_attribute(\*(Aqtwo\*(Aq); \& \& # set more than one attribute using the named parameter style \& $foo\->set_attributes(\*(Aqone\*(Aq=>27, \*(Aqtwo\*(Aq=>42); \& \& # or using array references \& $foo\->set_attributes([\*(Aqone\*(Aq,\*(Aqtwo\*(Aq],[27,42]); \& \& # get more than one attribute \& @list = $foo\->get_attributes(\*(Aqone\*(Aq, \*(Aqtwo\*(Aq); \& \& # get a list of all attributes known by an object \& @attrs = $foo\->get_attribute_names(); \& \& # check that initialize() is called properly \& die "initialize didn\*(Aqt set three()" unless $foo\->three(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Class::ObjectTemplate is a utility class to assist in the building of other Object Oriented Perl classes. .PP It was described in detail in the O\e'Reilly book, \*(L"Advanced Perl Programming\*(R" by Sriram Srinivasam. .SS "\s-1EXPORT\s0" .IX Subsection "EXPORT" attributes(@name_list) .PP This method creates a shared setter and getter methods for every name in the list. The method also creates the class constructor, \f(CW\*(C`new()\*(C'\fR. .PP \&\fB\s-1WARNING\s0\fR: This method \fImust\fR be invoked within the module for every class that inherits from Class::ObjectTemplate, even if that class defines no attributes. For a class defining no new attributes, it should invoke \f(CW\*(C`attributes()\*(C'\fR with no arguments. .SH "AUTHOR" .IX Header "AUTHOR" Original code by Sriram Srinivasam. .PP Fixes and \s-1CPAN\s0 module by Jason E. Stewart (jason@openinformatics.com) .SH "SEE ALSO" .IX Header "SEE ALSO" http://www.oreilly.com/catalog/advperl/ .PP \&\fBperl\fR\|(1). .PP Class::ObjectTemplate::DB