| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package OOP::Perlish::Class::Multiton; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use OOP::Perlish::Class::Singleton; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use base qw(OOP::Perlish::Class::Singleton); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | sub _multiton_key(@) { return '___STUB___' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_multiton_key: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | sub _singleton(@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_singleton: called CC=11 SCAR=25.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | my $multiton_name = $opts{$self->_multiton_key()} if( exists( $opts{$self->_multiton_key()} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | return unless($multiton_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | ${ $class . '::____MULTITON_REFS' } = {} unless(defined(${ $class . '::____MULTITON_REFS' }) && ref(${ $class . '::____MULTITON_REFS' }) eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined ${$class . '::____MULTITON_REFS';} and ref ${$class . '::____MULTITON_REFS';} eq "HASH"
MC/DC50%1/2
defined ${$class . '::____MULTITON_REFS';} and ref ${$class . '::____MULTITON_REFS';} eq "HASH"
defined ${$class . '::____MULTITON_REFS';}
ref ${$class . '::____MULTITON_REFS';} eq "HASH"
Truth table66%2/3
A and B
A= defined ${$class . '::____MULTITON_REFS';}B= ref ${$class . '::____MULTITON_REFS';} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | my $multiton_refs = ${ $class . '::____MULTITON_REFS' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | if( defined($multiton_refs) && ref($multiton_refs) eq 'HASH' && exists( $multiton_refs->{$multiton_name} ) && blessed( $multiton_refs->{$multiton_name} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
defined $multiton_refs and ref $multiton_refs eq "HASH" and exists $multiton_refs->{$multiton_name} and builtin::blessed($multiton_refs->{$multiton_name})
defined $multiton_refs and ref $multiton_refs eq "HASH" and exists $multiton_refs->{$multiton_name}
defined $multiton_refs and ref $multiton_refs eq "HASH"
MC/DC25%1/4
defined $multiton_refs and ref $multiton_refs eq "HASH" and exists $multiton_refs->{$multiton_name} and builtin::blessed($multiton_refs->{$multiton_name})
defined $multiton_refs
ref $multiton_refs eq "HASH"
exists $multiton_refs->{$multiton_name}
builtin::blessed($multiton_refs->{$multiton_name})
Truth table40%2/5
A and B and C and D
A= defined $multiton_refsB= ref $multiton_refs eq "HASH"C= exists $multiton_refs->{$multiton_name}D= builtin::blessed($multiton_refs->{$multiton_name})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | $self->debug( 'Singleton of ' . $class . ' for key ' . $multiton_name . ' already initialized; NOT reinitialized!!' ) if( scalar keys %opts > 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | return $multiton_refs->{$multiton_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | $multiton_refs->{$multiton_name} = $class->new( %opts, _____oop_perlish_class__initialize_singleton => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | return $multiton_refs->{$multiton_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||