Mercurial > pub > Impl
view Lib/IMPL/Object/Singleton.pm @ 144:b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
minor speed improvements to the object CTOR caching
Added support for a secure processing (and 'laundering' ) a CGI parameters
Many minor fixes
author | wizard |
---|---|
date | Tue, 13 Jul 2010 02:05:38 +0400 |
parents | d9dd3500ead3 |
children | 4267a2ac3d46 |
line wrap: on
line source
package IMPL::Object::Singleton; use strict; use warnings; my %instances; sub CTOR { die new IMPL::InvalidOperationException("Only one instance of the singleton can be created",ref $_[0], $instances{ref $_[0]}) if $instances{ref $_[0]}; $instances{ref $_[0]} = $_[0]; } sub instance { $instances{$_[0]} } 1; __END__ =pod =head1 SYNOPSIS =begin code package Foo; use base qw(IMPL::Object IMPL::Object::Singleton); #.... Foo->isnatnce->some_work(); Foo->isnatnce->get_result(); =end code =head1 DESCRIPTION Реализует шаблон Singleton =head1 MEMBERS =head2 OPERATORS =list =item C<instance CLASS(@params)> Создает или возвращает экземпляр класса, если экземляр не существует, то он создается с параметрами C<@params>. =over =cut