lib/NBU/Schedule.pm

filter: Statementstmt 30.3% 24 / 79 Branchbran 0.0% 0 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 35.2% 6 / 17 Podpod 0.0% 0 / 11 totaltotal 22.5% 30 / 133 CC 15 SCAR 43.5
CC
15
Cov
23%
new
182.0
pool
6.0
residence
6.0
CRAP 77.8
« lib/NBU/Robot.pm ↑ Summary lib/NBU/Pool.pm »
1 #
2 # Copyright (c) 2002 Paul Winkeler. All Rights Reserved.
3 # This program is free software; you may redistribute it and/or modify it under
4 # the same terms as Perl itself.
5 #
6 package NBU::Schedule;
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶ use AutoLoader qw(AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 $VERSION = do { my @r=(q$Revision: 1.15 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
16 1 @ISA = qw();
17 1 @EXPORT = qw();
18 1 @EXPORT_OK = qw();
19 1 %EXPORT_TAGS = qw();
20 }
21  
22 #
23 # The parent class, name and type of the schedule MUST be
24 # provided. Next comes an optional IO stream from which to read the
25 # window, residence and pool data, followed by any additional attributes
26 # for the schedule itself.
27 0 ▶sub new {
Subroutine new: not called CC=13 SCAR=52.0
Pod undocumented
28 0 my $proto = shift;
29 0 my $schedule = {
30 };
31  
32 0 bless $schedule, $proto;
33  
34 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
35 0 $schedule->{CLASS} = shift;
36 0 $schedule->{NAME} = shift;
37 0 $schedule->{TYPE} = shift;
38 }
39  
40 0 ▶ if (defined(my $pipe = shift)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $pipe = shift())) 0 0 0
41  
42 #
43 # Read in one line with 7 pairs of window start and length numbers; record them as a 7
44 # element array of arrays.
45 0 $_ = <$pipe>;
46 0 ▶ while (/^SCHEDCAL/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^SCHEDCAL/) 0 0 0
47 0 $_ = <$pipe>;
48 }
49 0 ▶ return undef if (!/^SCHEDWIN/);
Branch: 1 branch
BranchTrueFalseTotal
unless /^SCHEDWIN/ 0 0 0
50 0 my @times = split;
51 0 my @windows;
52 0 for my $d (0..6) {
53 0 $windows[$d] = [ shift @times, shift @times ];
54 }
55 0 $schedule->{WINDOWS} = \@windows;
56  
57 0 ▶ $_ = <$pipe>; return undef if (!/^SCHEDRES/);
Branch: 1 branch
BranchTrueFalseTotal
unless /^SCHEDRES/ 0 0 0
58 0 my (@residences) = split;
59 0 ▶ $schedule->{STUNIT} = NBU::StorageUnit->byLabel($residences[1]) if ($residences[1] ne "*NULL*");
Branch: 1 branch
BranchTrueFalseTotal
if $residences[1] ne "*NULL*" 0 0 0
60  
61 0 ▶ $_ = <$pipe>; return undef if (!/^SCHEDPOOL/);
Branch: 1 branch
BranchTrueFalseTotal
unless /^SCHEDPOOL/ 0 0 0
62 0 my (@pools) = split;
63 0 ▶ $schedule->{POOL} = NBU::Pool->byName($pools[0]) unless ($pools[0] eq "*NULL*");
Branch: 1 branch
BranchTrueFalseTotal
unless $pools[0] eq "*NULL*" 0 0 0
64  
65 0 $schedule->{MAXMPX} = shift;
66 0 $schedule->{FREQUENCY} = shift;
67 0 my $retentionLevel = shift;
68 0 $schedule->{RETENTION} = NBU::Retention->byLevel($retentionLevel);
69  
70 #
71 # Triggered by presence of the Fail On Error (FOE) tag in the Schedule definition
72 0 ▶ if ($_[8]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[8]) 0 0 0
73 0 ▶ $_ = <$pipe>; return undef if (!/^SCHEDRL/);
Branch: 1 branch
BranchTrueFalseTotal
unless /^SCHEDRL/ 0 0 0
74 0 ▶ $_ = <$pipe>; return undef if (!/^SCHEDFOE/);
Branch: 1 branch
BranchTrueFalseTotal
unless /^SCHEDFOE/ 0 0 0
75 }
76 }
77  
78 0 return $schedule;
79 }
80  
81 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
82 0 my $self = shift;
83  
84 0 return $self->{NAME};
85 }
86  
87 0 ▶sub policy {
Subroutine policy: not called CC=1 SCAR=6.9
Pod undocumented
88 0 my $self = shift;
89  
90 0 return $self->{CLASS};
91 }
92  
93 0 ▶sub class {
Subroutine class: not called CC=1 SCAR=6.9
Pod undocumented
94 0 my $self = shift;
95  
96 0 return $self->{CLASS};
97 }
98  
99 1 my %scheduleTypes = (
100 0 => "FULL",
101 1 => "INCR",
102 2 => "UBAK",
103 3 => "UARC",
104 4 => "CINC",
105 );
106 0 ▶sub type {
Subroutine type: not called CC=1 SCAR=6.9
Pod undocumented
107 0 my $self = shift;
108  
109 0 return $scheduleTypes{$self->{TYPE}};
110 }
111  
112 0 ▶sub frequency {
Subroutine frequency: not called CC=1 SCAR=6.9
Pod undocumented
113 0 my $self = shift;
114  
115 0 return $self->{FREQUENCY};
116 }
117  
118 0 ▶sub maximumMPX {
Subroutine maximumMPX: not called CC=1 SCAR=6.9
Pod undocumented
119 0 my $self = shift;
120  
121 0 return $self->{MAXMPX};
122 }
123  
124 0 ▶sub retention {
Subroutine retention: not called CC=1 SCAR=6.9
Pod undocumented
125 0 my $self = shift;
126  
127 0 return $self->{RETENTION};
128 }
129  
130 0 ▶sub pool {
Subroutine pool: not called CC=2 SCAR=17.9
Pod undocumented
131 0 my $self = shift;
132  
133 0 ▶ return defined($self->{POOL}) ? $self->{POOL} : $self->class->pool;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'POOL'} ? : 0 0 0
134 }
135  
136 0 ▶sub residence {
Subroutine residence: not called CC=2 SCAR=17.9
Pod undocumented
137 0 my $self = shift;
138  
139 0 ▶ return defined($self->{STUNIT}) ? $self->{STUNIT} : $self->class->storageUnit;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'STUNIT'} ? : 0 0 0
140 }
141  
142 0 ▶sub storageUnit {
Subroutine storageUnit: not called CC=1 SCAR=6.9
Pod undocumented
143 0 my $self = shift;
144  
145 0 return $self->residence(@_);
146 }
147  
148 1 1;
149  
150 __END__
« lib/NBU/Robot.pm ↑ Summary lib/NBU/Pool.pm »