| 1 | package UML::Sequence::Activation; | ||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | 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 | 13 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 13 | my $class = shift; | |||||||||||||||||||||||||||
| 34 | 13 | my $self = {}; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 13 | 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 | 48 | ▶ | sub starts { | ||||||||||||||||||||||||||
|
Subroutine
starts: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 48 | my $self = shift; | |||||||||||||||||||||||||||
| 47 | 48 | my $new_val = shift; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 48 | ▶ | if (defined $new_val) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 13 | $self->{STARTING} = $new_val; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 48 | 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 | 79 | ▶ | sub ends { | ||||||||||||||||||||||||||
|
Subroutine
ends: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 79 | my $self = shift; | |||||||||||||||||||||||||||
| 63 | 79 | my $new_val = shift; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 79 | ▶ | if (defined $new_val) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 13 | $self->{ENDING} = $new_val; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 79 | 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 | 26 | ▶ | sub offset { | ||||||||||||||||||||||||||
|
Subroutine
offset: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 26 | my $self = shift; | |||||||||||||||||||||||||||
| 82 | 26 | my $new_val = shift; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 26 | ▶ | if (defined $new_val) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 13 | $self->{OFFSET} = $new_val; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 26 | 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 | 25 | ▶ | sub find_offset { | ||||||||||||||||||||||||||
|
Subroutine
find_offset: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 99 | 25 | my $class = shift; # ignored | |||||||||||||||||||||||||||
| 100 | 25 | my $activations = shift; | |||||||||||||||||||||||||||
| 101 | 25 | my $offset = 0; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 25 | ▶ | return 0 unless defined $activations; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 18 | my @acts = @$activations; # make a copy so we can pop | |||||||||||||||||||||||||||
| 106 | 18 | ▶ | while (@acts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 42 | my $act = pop @acts; | |||||||||||||||||||||||||||
| 108 | 42 | ▶ | if (not defined $act->ends()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 4 | $offset++; | |||||||||||||||||||||||||||
| 110 | 4 | next; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | 18 | 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 | 4 | ▶ | sub find_bounds { | ||||||||||||||||||||||||||
|
Subroutine
find_bounds: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 124 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 125 | 4 | my $activations = shift; | |||||||||||||||||||||||||||
| 126 | 4 | my ($min, $max); | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 4 | foreach my $activation (@$activations) { | |||||||||||||||||||||||||||
| 129 | 13 | ▶ | if (not defined $min or $min > $activation->starts()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $min or $min > $activation->starts
MC/DC50%1/2
not defined $min or $min > $activation->starts
not defined $min
$min > $activation->starts
Truth table66%2/3
not(A) or B
A= not defined $minB= $min > $activation->starts
| |||||||||||||||||||||||||||||
| 130 | 4 | $min = $activation->starts(); | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 13 | ▶ | if (not defined $max or $max < $activation->starts()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $max or $max < $activation->starts
MC/DC100%2/2
not defined $max or $max < $activation->starts
not defined $max
$max < $activation->starts
Truth table100%3/3
not(A) or B
A= not defined $maxB= $max < $activation->starts
| |||||||||||||||||||||||||||||
| 133 | 11 | $max = $activation->ends(); | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 4 | return ($min, $max); | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 4 | 1; | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | Phil Crow, <philcrow2000@yahoo.com> | ||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||