.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" 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 "Class::Adapter 3pm" .TH Class::Adapter 3pm "2022-12-04" "perl v5.36.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::Adapter \- Perl implementation of the "Adapter" Design Pattern .SH "VERSION" .IX Header "VERSION" version 1.09 .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`Class::Adapter\*(C'\fR class is intended as an abstract base class for creating any sort of class or object that follows the \fIAdapter\fR pattern. .SS "What is an Adapter?" .IX Subsection "What is an Adapter?" The term \fIAdapter\fR refers to a \fI\*(L"Design Pattern\*(R"\fR of the same name, from the famous \fI\*(L"Gang of Four\*(R"\fR book \fI\*(L"Design Patterns\*(R"\fR. Although their original implementation was designed for Java and similar single-inheritance strictly-typed language, the situation for which it applies is still valid. .PP An \fIAdapter\fR in this Perl sense of the term is when a class is created to achieve by composition (objects containing other object) something that can't be achieved by inheritance (sub-classing). .PP This is similar to the \fIDecorator\fR pattern, but is intended to be applied on a class-by-class basis, as opposed to being able to be applied one object at a time, as is the case with the \fIDecorator\fR pattern. .PP The \f(CW\*(C`Class::Adapter\*(C'\fR object holds a parent object that it \*(L"wraps\*(R", and when a method is called on the \f(CW\*(C`Class::Adapter\*(C'\fR, it manually calls the same (or different) method with the same (or different) parameters on the parent object contained within it. .PP Instead of these custom methods being hooked in on an object-by-object basis, they are defined at the class level. .PP Basically, a \f(CW\*(C`Class::Adapter\*(C'\fR is one of your fall-back positions when Perl's inheritance model fails you, or is no longer good enough, and you need to do something twisty in order to make several APIs play nicely with each other. .SS "What can I do with the actual Class::Adapter class" .IX Subsection "What can I do with the actual Class::Adapter class" Well... nothing really. It exist to provide some extremely low level fundamental methods, and to provide a common base for inheritance of Adapter classes. .PP The base \f(CW\*(C`Class::Adapter\*(C'\fR class doesn't even implement a way to push method calls through to the underlying object, since the way in which \&\fBthat\fR happens is the bit that changes from case to case. .PP To actually \s-1DO\s0 something, you probably want to go take a look at Class::Adapter::Builder, which makes the creation of \fIAdapter\fR classes relatively quick and easy. .SH "METHODS" .IX Header "METHODS" The \f(CW\*(C`Class::Adapter\*(C'\fR class itself supplies only the two most common methods, a default constructor and a private method to access the underlying object. .ie n .SS "new $object" .el .SS "new \f(CW$object\fP" .IX Subsection "new $object" The default \f(CW\*(C`new\*(C'\fR constructor takes a single object as argument and creates a new object which holds the passed object. .PP Returns a new \f(CW\*(C`Class::Adapter\*(C'\fR object, or \f(CW\*(C`undef\*(C'\fR if you do not pass in an object. .SS "_OBJECT_" .IX Subsection "_OBJECT_" The \f(CW\*(C`_OBJECT_\*(C'\fR method is provided primarily as a convenience, and a tool for people implementing sub-classes, and allows the \f(CW\*(C`Class::Adapter\*(C'\fR interface to provide a guaranteed correct way of getting to the underlying object, should you need to do so. .SH "TO DO" .IX Header "TO DO" \&\- Write more comprehensive tests .SH "SEE ALSO" .IX Header "SEE ALSO" Class::Adapter::Clear, Class::Adapter::Builder, Class::Decorator .SH "SUPPORT" .IX Header "SUPPORT" Bugs may be submitted through the \s-1RT\s0 bug tracker (or bug\-Class\-Adapter@rt.cpan.org ). .SH "AUTHOR" .IX Header "AUTHOR" Adam Kennedy .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" .IP "\(bu" 4 Adam Kennedy .IP "\(bu" 4 Karen Etheridge .IP "\(bu" 4 gregor herrmann .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2005 by Adam Kennedy. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.