| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
|
2
|
|
|
|
|
|
|
# Class::DispatchToAll |
|
3
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
|
4
|
|
|
|
|
|
|
# Copyright Thomas Klausner 2001, 2002, 2006 |
|
5
|
|
|
|
|
|
|
# You may use and distribute this module according to the same terms |
|
6
|
|
|
|
|
|
|
# that Perl is distributed under. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# Thomas Klausner domm@cpan.org http://domm.plix.at |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
|
11
|
|
|
|
|
|
|
# Class::Data::DispatchToAll - dispatch a method call to all inherited methods |
|
12
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
|
13
|
|
|
|
|
|
|
package Class::DispatchToAll; |
|
14
|
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
304360
|
use 5.006; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
89
|
|
|
16
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
74
|
|
|
17
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
879
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require Exporter; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @EXPORT_OK = (qw(dispatch_to_all)); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
|
29
|
|
|
|
|
|
|
# dispatch_to_all |
|
30
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
|
31
|
|
|
|
|
|
|
sub dispatch_to_all { |
|
32
|
7
|
|
|
7
|
1
|
2062
|
my $self=shift; |
|
33
|
7
|
|
|
|
|
12
|
my $method=shift; |
|
34
|
7
|
|
|
|
|
10
|
my $attributes=shift; |
|
35
|
7
|
|
|
|
|
7
|
my @result_set; |
|
36
|
|
|
|
|
|
|
|
|
37
|
7
|
|
33
|
|
|
46
|
my $data={ |
|
38
|
|
|
|
|
|
|
self=>$self, |
|
39
|
|
|
|
|
|
|
class=>ref($self)||$self, |
|
40
|
|
|
|
|
|
|
method=>$method, |
|
41
|
|
|
|
|
|
|
attribs=>$attributes, |
|
42
|
|
|
|
|
|
|
result_set=>\@result_set, |
|
43
|
|
|
|
|
|
|
}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
7
|
|
|
|
|
17
|
_dispatcher($data,@_); |
|
46
|
7
|
100
|
|
|
|
57
|
return wantarray?@result_set:\@result_set; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
|
51
|
|
|
|
|
|
|
# dispatcher |
|
52
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
|
53
|
|
|
|
|
|
|
sub _dispatcher { |
|
54
|
70
|
|
|
70
|
|
89
|
my $data=shift; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# dispatch to own package |
|
57
|
2
|
|
|
2
|
|
12
|
no strict "refs"; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
725
|
|
|
58
|
70
|
|
|
|
|
145
|
my $call=$data->{'class'}."::".$data->{'method'}; |
|
59
|
|
|
|
|
|
|
|
|
60
|
70
|
50
|
|
|
|
283
|
if ($data->{'attrib'}{'no_collect'}) { |
|
61
|
0
|
0
|
|
|
|
0
|
$call->($data->{'self'},@_) if *$call{CODE}; |
|
62
|
|
|
|
|
|
|
} else { |
|
63
|
70
|
100
|
|
|
|
255
|
push(@{$data->{'result_set'}},$call->($data->{'self'},@_)) if *$call{CODE}; |
|
|
34
|
|
|
|
|
149
|
|
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
70
|
|
|
|
|
3308
|
my @isa=eval "@".$data->{'class'}."::ISA"; |
|
67
|
70
|
|
|
|
|
324
|
foreach my $parent (@isa) { |
|
68
|
63
|
|
|
|
|
94
|
$data->{'class'}=$parent; |
|
69
|
63
|
|
|
|
|
116
|
_dispatcher($data,@_); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |