Graph/Xmgrace/Base_Option.pm

filter: Statementstmt 92.3% 48 / 52 Branchbran 85.7% 12 / 14 Conditioncond 54.5% 6 / 11 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 79.1% 72 / 91 CC 13 SCAR 17.5
CC
13
Cov
86%
print
8.1
AUTOLOAD
5.3
new
2.0
CRAP 5.7
« Graph/Xmgrace/Axis_Options.pm ↑ Summary Graph/Xmgrace/Axis_Option.pm »
1 #
2 # Base_Option.pm is the base class option object used by Graph_Options.pm
3 #
4 ## This software product is developed by Esmond Lee and David Moore,
5 ## and copyrighted(C) 1998 by the University of California, San Diego
6 ## (UCSD), with all rights reserved. UCSD administers the CAIDA grant,
7 ## NCR-9711092, under which part of this code was developed.
8 ##
9 ## There is no charge for this software. You can redistribute it and/or
10 ## modify it under the terms of the GNU General Public License, v. 2 dated
11 ## June 1991 which is incorporated by reference herein. This software is
12 ## distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF MERCHANTABILITY
13 ## OR FITNESS FOR A PARTICULAR PURPOSE or that the use of it will not
14 ## infringe on any third party's intellectual property rights.
15 ##
16 ## You should have received a copy of the GNU GPL along with this program.
17 ##
18 ##
19 ## IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
20 ## PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
21 ## DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS
22 ## SOFTWARE, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF
23 ## THE POSSIBILITY OF SUCH DAMAGE.
24 ##
25 ## THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE
26 ## UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
27 ## SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. THE UNIVERSITY
28 ## OF CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES
29 ## OF ANY KIND, EITHER IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED
30 ## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
31 ## PARTICULAR PURPOSE, OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE
32 ## ANY PATENT, TRADEMARK OR OTHER RIGHTS.
33 ##
34 ##
35 ## Contact: graph-dev@caida.org
36 ##
37 ##
38  
39 4 $VERSION = 3.2;
40  
41 package Chart::Graph::Xmgrace::Base_Option;
42 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 51 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
45 51 my $this = shift;
46 51 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0510
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
47 51 my $self = {};
48 51 bless $self, $class;
49 51 $self->_init(@_);
50 51 return $self;
51 }
52  
53 #
54 #
55 # Subroutine: _printline()
56 #
57 # Description: this function will print out a line that can be
58 # read with xmgrace (with the prepended @)
59 #
60 #
61 #
62
63 71 ▶sub _printline ($$$$ ) {
Subroutine _printline: called CC=1 SCAR=0.0
64 71 my $self = shift;
65 71 my ($handle, $string, $length) = @_;
66  
67 71 print $handle "@";
68 71 print $handle ' ' x $length;
69 71 print $handle "$string";
70  
71 71 return 1; # just for fun
72 }
73  
74 8 ▶sub print($$ ) {
Subroutine print: called CC=8 SCAR=21.0
Pod undocumented
75 8 my $self = shift;
76 8 my $handle = shift;
77 8 my $string = "";
78 8 my $substr = ""; # for making arrays into a string
79  
80 8 foreach $option (@{ $self->{"print_order"} }) {
81 45 my $option_ref = $self->{"options"};
82  
83 45 ▶ if ($option eq "status" or $option eq "in_out_status") {
Branch: 1 branch
BranchTrueFalseTotal
if ($option eq 'status' or $option eq 'in_out_status') { } 1 44 45
Condition66%2/3
$option eq "status" or $option eq "in_out_status"
l!l&&r!l&&!r
1044
MC/DC50%1/2
$option eq "status" or $option eq "in_out_status"
$option eq "status" $option eq "in_out_status"
Truth table66%2/3
A or B
A= $option eq "status"B= $option eq "in_out_status"
ABresult
1X1
011
000
84
85 # we first check the status of the option, whether it's on/off
86 # if it's off, we don't print it out
87 1 ▶ if ($option_ref->{"status"} eq "off") {
Branch: 1 branch
BranchTrueFalseTotal
if ($option_ref->{"status"} eq "off") 0 1 1
88 0 $string = "$self->{name} $option_ref->{$option}\n";
89 0 $self->_printline($handle, $string, $self->{"length"});
90 0 last;
91 }
92 1 $string = "$self->{name} $option_ref->{$option}\n";
93 1 $self->_printline($handle, $string, $self->{"length"});
94  
95 } else {
96  
97 # print function handles both scalars and lists
98 44 ▶ if ($self->{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'name'}) { } 36 8 44
99 36 ▶ if (ref($option_ref->{$option}) eq ARRAY) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $option_ref->{$option} eq 'ARRAY') { } 1 35 36
100 1 $substr = join (", ", (@{ $option_ref->{$option} }));
101 1 $string = "$self->{name} $option $substr\n";
102 } else {
103 35 $string = "$self->{name} $option $option_ref->{$option}\n";
104 }
105 } else { # global options don't have a name field
106 8 ▶ if (ref($option_ref->{$option}) eq ARRAY) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $option_ref->{$option} eq 'ARRAY') { } 1 7 8
107 1 $substr = join (", ", (@{ $option_ref->{$option} }));
108 1 $string = "$option $substr\n";
109 } else {
110 7 $string = "$option $option_ref->{$option}\n";
111 }
112 }
113
114 44 $self->_printline($handle, $string, $self->{"length"});
115 }
116 }
117 }
118  
119 60 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=5 SCAR=16.6
120 60 my $self = shift;
121 60 ▶ my $type = ref($self) || croak "$self is not an object";
Condition50%1/2
ref $self || croak("$self is not an object")
l!l
600
MC/DC0%0/1
ref $self || croak("$self is not an object")
ref $self
Truth table50%1/2
A
A= ref $self
Aresult
11
00
122 60 my $name = $AUTOLOAD;
123 60 $name =~ s/.*://; #strip fully-qualified portion
124 60 ▶ unless (($name eq "DESTROY") or (exists $self->{options}->{$name})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name eq "DESTROY" or exists $self->{"options"}{$name}) 0 60 60
Condition66%2/3
$name eq "DESTROY" or exists $self->{"options"}{$name}
l!l&&r!l&&!r
50100
MC/DC0%0/2
$name eq "DESTROY" or exists $self->{"options"}{$name}
$name eq "DESTROY" exists $self->{"options"}{$name}
Truth table66%2/3
A or B
A= $name eq "DESTROY"B= exists $self->{"options"}{$name}
ABresult
1X1
011
000
125 0 croak "Can't access '$name' field in object of class $type";
126 }
127  
128 60 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 10 50 60
129 10 return $self->{options}->{$name} = shift;
130 } else {
131 50 return $self->{options}->{$name};
132 }
133 }
134  
135 4 1;
« Graph/Xmgrace/Axis_Options.pm ↑ Summary Graph/Xmgrace/Axis_Option.pm »