Graph/Xmgrace/Base_Dataset_Option.pm

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