line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UML::Sequence::Activation; |
2
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
114
|
|
3
|
4
|
|
|
4
|
|
55
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1653
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
UML::Sequence::Activation - a helper class to support UML::Sequence |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use UML::Sequence::Activation; |
14
|
|
|
|
|
|
|
my $activation = UML::Sequence::Activation->new(); |
15
|
|
|
|
|
|
|
$activation->starts(2); |
16
|
|
|
|
|
|
|
... |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class keeps track of the start, end, offset, and bounds for an activation |
21
|
|
|
|
|
|
|
in the sequence diagram. It is a data container (a node), so it provides |
22
|
|
|
|
|
|
|
direct access to its attributes. The constructor ignores all arguments, |
23
|
|
|
|
|
|
|
use accessors or direct access to insert and check the values. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 new |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Trivial constructor, taking nothing, returning a blessed reference to an |
28
|
|
|
|
|
|
|
empty hash. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
13
|
|
|
13
|
0
|
15
|
my $class = shift; |
34
|
13
|
|
|
|
|
20
|
my $self = {}; |
35
|
|
|
|
|
|
|
|
36
|
13
|
|
|
|
|
49
|
bless $self, $class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 starts |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Accessor to set or check the starting attribute. Always returns the value. |
42
|
|
|
|
|
|
|
This is the arrow number at the top of the activation. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
sub starts { |
46
|
48
|
|
|
48
|
0
|
54
|
my $self = shift; |
47
|
48
|
|
|
|
|
49
|
my $new_val = shift; |
48
|
|
|
|
|
|
|
|
49
|
48
|
100
|
|
|
|
93
|
if (defined $new_val) { |
50
|
13
|
|
|
|
|
31
|
$self->{STARTING} = $new_val; |
51
|
|
|
|
|
|
|
} |
52
|
48
|
|
|
|
|
142
|
return $self->{STARTING}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 ends |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Accessor to set or check the ending attribute. Always returns the value. |
58
|
|
|
|
|
|
|
This is the arrow number at the bottom of the activation. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
sub ends { |
62
|
79
|
|
|
79
|
0
|
91
|
my $self = shift; |
63
|
79
|
|
|
|
|
78
|
my $new_val = shift; |
64
|
|
|
|
|
|
|
|
65
|
79
|
100
|
|
|
|
183
|
if (defined $new_val) { |
66
|
13
|
|
|
|
|
20
|
$self->{ENDING} = $new_val; |
67
|
|
|
|
|
|
|
} |
68
|
79
|
|
|
|
|
266
|
return $self->{ENDING}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 offset |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Accessor to set or check the offset attribute. Always returns the value. |
74
|
|
|
|
|
|
|
This is the number of stacked activations. An offset of zero means the |
75
|
|
|
|
|
|
|
activation is centered over the lifelife. An offset of one means a self |
76
|
|
|
|
|
|
|
call activation is on top of the original call. The activation should |
77
|
|
|
|
|
|
|
be pushed to the right (it should be offset). |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
sub offset { |
81
|
26
|
|
|
26
|
0
|
31
|
my $self = shift; |
82
|
26
|
|
|
|
|
24
|
my $new_val = shift; |
83
|
|
|
|
|
|
|
|
84
|
26
|
100
|
|
|
|
50
|
if (defined $new_val) { |
85
|
13
|
|
|
|
|
24
|
$self->{OFFSET} = $new_val; |
86
|
|
|
|
|
|
|
} |
87
|
26
|
|
|
|
|
65
|
return $self->{OFFSET}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 find_offset |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This class method takes a reference to an array of activations and returns |
93
|
|
|
|
|
|
|
the number of them which are open (have undef ends attribute). Pass in the |
94
|
|
|
|
|
|
|
activations for your class, receive the offset number a new activation. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub find_offset { |
99
|
25
|
|
|
25
|
0
|
32
|
my $class = shift; # ignored |
100
|
25
|
|
|
|
|
33
|
my $activations = shift; |
101
|
25
|
|
|
|
|
36
|
my $offset = 0; |
102
|
|
|
|
|
|
|
|
103
|
25
|
100
|
|
|
|
101
|
return 0 unless defined $activations; |
104
|
|
|
|
|
|
|
|
105
|
18
|
|
|
|
|
34
|
my @acts = @$activations; # make a copy so we can pop |
106
|
18
|
|
|
|
|
48
|
while (@acts) { |
107
|
42
|
|
|
|
|
56
|
my $act = pop @acts; |
108
|
42
|
100
|
|
|
|
140
|
if (not defined $act->ends()) { |
109
|
4
|
|
|
|
|
5
|
$offset++; |
110
|
4
|
|
|
|
|
12
|
next; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
18
|
|
|
|
|
49
|
return $offset; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 find_bounds |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This class method takes a reference to an array of activations and returns |
119
|
|
|
|
|
|
|
the minimum starts and maximum ends attributes for the set. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub find_bounds { |
124
|
4
|
|
|
4
|
0
|
6
|
my $class = shift; |
125
|
4
|
|
|
|
|
5
|
my $activations = shift; |
126
|
4
|
|
|
|
|
5
|
my ($min, $max); |
127
|
|
|
|
|
|
|
|
128
|
4
|
|
|
|
|
7
|
foreach my $activation (@$activations) { |
129
|
13
|
100
|
66
|
|
|
76
|
if (not defined $min or $min > $activation->starts()) { |
130
|
4
|
|
|
|
|
7
|
$min = $activation->starts(); |
131
|
|
|
|
|
|
|
} |
132
|
13
|
100
|
100
|
|
|
40
|
if (not defined $max or $max < $activation->starts()) { |
133
|
11
|
|
|
|
|
21
|
$max = $activation->ends(); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
4
|
|
|
|
|
21
|
return ($min, $max); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Phil Crow, |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 COPYRIGHT |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Copyright 2003, Philip Crow, all rights reserved. You may modify and/or |
148
|
|
|
|
|
|
|
redistribute this code in the same manner as Perl itself. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |