line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Eixo::Base::Singleton; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
32
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
120
|
|
4
|
4
|
|
|
4
|
|
21
|
use Eixo::Base::Clase; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub make_singleton{ |
7
|
11
|
|
|
11
|
0
|
96
|
my ($clase, %args) = @_; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
27
|
no strict 'refs'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
135
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
23
|
no warnings 'redefine'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1778
|
|
12
|
|
|
|
|
|
|
|
13
|
11
|
100
|
|
|
|
16
|
return if(defined(&{$clase . '::SINGLETON'})); |
|
11
|
|
|
|
|
87
|
|
14
|
|
|
|
|
|
|
|
15
|
8
|
|
|
|
|
44
|
my $instance = $clase->new(%args); |
16
|
|
|
|
|
|
|
|
17
|
8
|
|
|
|
|
28
|
*{$clase . '::SINGLETON'} = sub { |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
5
|
return $instance; |
20
|
|
|
|
|
|
|
|
21
|
8
|
|
|
|
|
35
|
}; |
22
|
|
|
|
|
|
|
|
23
|
8
|
|
|
|
|
37
|
*{$clase . '::AUTOLOAD'} = sub { |
24
|
|
|
|
|
|
|
|
25
|
28
|
|
|
28
|
|
1625
|
my ($attribute) = our $AUTOLOAD =~ /\:(\w+)$/; |
26
|
|
|
|
|
|
|
|
27
|
28
|
50
|
|
|
|
151
|
if(my $method = $instance->can('__' . $attribute)){ |
28
|
|
|
|
|
|
|
|
29
|
28
|
|
|
|
|
104
|
$instance->$method(@_[1..$#_]); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else{ |
33
|
0
|
|
|
|
|
0
|
die($AUTOLOAD . ' method not found'); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
|
|
31
|
}; |
37
|
|
|
|
|
|
|
|
38
|
8
|
50
|
|
|
|
88
|
if($instance->can('initialize')){ |
39
|
|
|
|
|
|
|
|
40
|
8
|
|
|
|
|
31
|
$instance->initialize(); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
8
|
100
|
|
|
|
63
|
if( ! $instance->can("DESTROY")){ |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
0
|
|
18
|
*{$clase . '::DESTROY'} = sub {} |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
15
|
} |
48
|
|
|
|
|
|
|
|
49
|
8
|
|
|
|
|
26
|
$instance; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new{ |
53
|
10
|
|
|
10
|
0
|
26
|
my ($class, @args) = @_; |
54
|
|
|
|
|
|
|
|
55
|
10
|
100
|
|
|
|
84
|
my $self = ($class->can('SINGLETON')) ? $class->SINGLETON : undef; |
56
|
|
|
|
|
|
|
|
57
|
10
|
100
|
|
|
|
27
|
if($self){ |
58
|
2
|
|
|
|
|
7
|
$self->__chainInitialize; |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
6
|
$self->initialize(@args); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else{ |
63
|
8
|
|
|
|
|
20
|
$self = bless({}, $class); |
64
|
|
|
|
|
|
|
|
65
|
8
|
|
|
|
|
49
|
$self->__chainInitialize; |
66
|
|
|
|
|
|
|
|
67
|
8
|
50
|
|
|
|
61
|
$self->__initialize if($self->can('__initialize')); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
10
|
|
|
|
|
37
|
$self; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub __createSetterGetter{ |
79
|
21
|
|
|
21
|
|
48
|
my ($class, $attribute, $value) = @_; |
80
|
|
|
|
|
|
|
|
81
|
4
|
|
|
4
|
|
31
|
no strict 'refs'; |
|
4
|
|
|
|
|
23
|
|
|
4
|
|
|
|
|
498
|
|
82
|
|
|
|
|
|
|
|
83
|
21
|
50
|
|
|
|
30
|
unless(defined(&{$class . '::__' . $attribute})){ |
|
21
|
|
|
|
|
126
|
|
84
|
|
|
|
|
|
|
|
85
|
21
|
|
|
|
|
107
|
*{$class . '::__' . $attribute} = sub { |
86
|
|
|
|
|
|
|
|
87
|
28
|
|
|
28
|
|
53
|
my ($self, $value) = @_; |
88
|
|
|
|
|
|
|
|
89
|
28
|
100
|
|
|
|
65
|
if(defined($value)){ |
90
|
|
|
|
|
|
|
|
91
|
7
|
|
|
|
|
20
|
$self->{$attribute} = $value; |
92
|
|
|
|
|
|
|
|
93
|
7
|
|
|
|
|
19
|
$self; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
else{ |
96
|
|
|
|
|
|
|
|
97
|
21
|
|
|
|
|
156
|
$self->{$attribute}; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
21
|
|
|
|
|
83
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |