line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
4
|
|
|
|
|
|
|
{ |
5
|
|
|
|
|
|
|
package OOP::Perlish::Class::Multiton; |
6
|
1
|
|
|
1
|
|
579
|
use OOP::Perlish::Class::Singleton; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
6
|
use base qw(OOP::Perlish::Class::Singleton); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
77
|
|
8
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw(blessed); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
145
|
|
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
0
|
|
0
|
sub _multiton_key(@) { return '___STUB___' } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _singleton(@) |
13
|
|
|
|
|
|
|
{ |
14
|
4
|
|
|
4
|
|
11
|
my ($self, %opts) = @_; |
15
|
4
|
|
33
|
|
|
11
|
my $class = ref($self) || $self; |
16
|
|
|
|
|
|
|
|
17
|
4
|
50
|
|
|
|
16
|
my $multiton_name = $opts{$self->_multiton_key()} if( exists( $opts{$self->_multiton_key()} ) ); |
18
|
4
|
50
|
|
|
|
11
|
return unless($multiton_name); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
76
|
|
22
|
4
|
100
|
66
|
|
|
6
|
${ $class . '::____MULTITON_REFS' } = {} unless(defined(${ $class . '::____MULTITON_REFS' }) && ref(${ $class . '::____MULTITON_REFS' }) eq 'HASH'); |
|
1
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
32
|
|
|
3
|
|
|
|
|
21
|
|
23
|
4
|
|
|
|
|
6
|
my $multiton_refs = ${ $class . '::____MULTITON_REFS' }; |
|
4
|
|
|
|
|
14
|
|
24
|
1
|
|
|
1
|
|
5
|
use strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
174
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
4
|
100
|
33
|
|
|
48
|
if( defined($multiton_refs) && ref($multiton_refs) eq 'HASH' && exists( $multiton_refs->{$multiton_name} ) && blessed( $multiton_refs->{$multiton_name} ) ) { |
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
28
|
2
|
50
|
|
|
|
9
|
$self->debug( 'Singleton of ' . $class . ' for key ' . $multiton_name . ' already initialized; NOT reinitialized!!' ) if( scalar keys %opts > 1 ); |
29
|
2
|
|
|
|
|
10
|
return $multiton_refs->{$multiton_name}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
2
|
|
|
|
|
16
|
$multiton_refs->{$multiton_name} = $class->new( %opts, _____oop_perlish_class__initialize_singleton => 1 ); |
33
|
2
|
|
|
|
|
11
|
return $multiton_refs->{$multiton_name}; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
=head1 VERSION |
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
=head1 EXPORT |
44
|
|
|
|
|
|
|
=head1 FUNCTIONS |
45
|
|
|
|
|
|
|
=head1 AUTHOR |
46
|
|
|
|
|
|
|
=head1 BUGS |
47
|
|
|
|
|
|
|
=head1 SUPPORT |
48
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
49
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |