annotate Lib/IMPL/Object/Singleton.pm @ 46:75148ccd732d

Upgrading resources
author Sergey
date Tue, 02 Feb 2010 17:09:49 +0300
parents 1b1fb9d54f55
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
1 package IMPL::Object::Singleton;
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
2 use strict;
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
3 use warnings;
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
4
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
5 my %instances;
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
6
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
7 sub instance {
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
8 my $self = shift;
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
9
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
10 $instances{$self} || ($instances{$self} = $self->new(@_));
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
11 }
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
12
46
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
13 1;
45
1b1fb9d54f55 Starting web-application concept
Sergey
parents:
diff changeset
14
46
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
15 __END__
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
16
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
17 =pod
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
18
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
19 =head1 SYNOPSIS
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
20
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
21 package Foo;
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
22
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
23 use base qw(IMPL::Object IMPL::Object::Singleton);
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
24
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
25 #....
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
26
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
27 Foo->isnatnce->some_work();
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
28
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
29 Foo->isnatnce->get_result();
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
30
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
31 =head1 DESCRIPTION
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
32
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
33 Реализует шаблон Singleton
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
34
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
35 =head1 MEMBERS
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
36
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
37 =head2 OPERATORS
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
38
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
39 =list
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
40
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
41 =item C<instance CLASS(@params)>
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
42
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
43 Создает или возвращает экземпляр класса, если экземляр не существует, то он создается с параметрами C<@params>.
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
44
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
45 =over
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
46
75148ccd732d Upgrading resources
Sergey
parents: 45
diff changeset
47 =cut