| 1 | package Lingua::Ogmios::Annotations::LogProcessing; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use Lingua::Ogmios::Annotations::Element; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 16 | our @ISA = qw(Lingua::Ogmios::Annotations::Element); | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 97 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 97 | my ($class, $fields) = @_; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 97 | my @refTypes = ('list_modified_level'); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # warn join(":", keys %$fields) . "\n"; | ||||||||||||||||||||||||||||
| 15 | # warn join(":", values %$fields) . "\n"; | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 97 | ▶ | if (!defined $fields->{'log_id'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 87 | $fields->{'log_id'} = -1; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | my $log_processing = { | ||||||||||||||||||||||||||||
| 22 | 97 | 'log_id' => $fields->{'log_id'}, | |||||||||||||||||||||||||||
| 23 | 'next' => undef, | ||||||||||||||||||||||||||||
| 24 | 'previous' => undef, | ||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 97 | bless ($log_processing, $class); | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | ######################################################################## | ||||||||||||||||||||||||||||
| 30 | # my $i = 0; | ||||||||||||||||||||||||||||
| 31 | # my $reference_name; | ||||||||||||||||||||||||||||
| 32 | # my $ref; | ||||||||||||||||||||||||||||
| 33 | # foreach $ref (@refTypes) { | ||||||||||||||||||||||||||||
| 34 | # if (exists $fields->{$ref}) { | ||||||||||||||||||||||||||||
| 35 | # $reference_name = $ref; | ||||||||||||||||||||||||||||
| 36 | # last; | ||||||||||||||||||||||||||||
| 37 | # } | ||||||||||||||||||||||||||||
| 38 | # $i++; | ||||||||||||||||||||||||||||
| 39 | # } | ||||||||||||||||||||||||||||
| 40 | # if ($i == scalar(@refTypes)) { | ||||||||||||||||||||||||||||
| 41 | # warn ("reference (list) is not defined"); | ||||||||||||||||||||||||||||
| 42 | # } else { | ||||||||||||||||||||||||||||
| 43 | # $log_processing->list_modified_level($reference_name, $fields->{$reference_name}); | ||||||||||||||||||||||||||||
| 44 | # } | ||||||||||||||||||||||||||||
| 45 | ######################################################################## | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 97 | ▶ | if (defined $fields->{'software_name'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 39 | $log_processing->setSoftwareName($fields->{'software_name'}); | |||||||||||||||||||||||||||
| 50 | } else { | ||||||||||||||||||||||||||||
| 51 | 58 | $log_processing->{'software_name'} = undef; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 97 | ▶ | if (defined $fields->{'command_line'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 28 | $log_processing->setCommandLine($fields->{'command_line'}); | |||||||||||||||||||||||||||
| 55 | } else { | ||||||||||||||||||||||||||||
| 56 | 69 | $log_processing->{'command_line'} = undef; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 97 | ▶ | if (defined $fields->{'stamp'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | $log_processing->setStamp($fields->{'stamp'}); | |||||||||||||||||||||||||||
| 60 | } else { | ||||||||||||||||||||||||||||
| 61 | 97 | $log_processing->{'stamp'} = undef; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 97 | ▶ | if (defined $fields->{'tagset'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $log_processing->setTagset($fields->{'tagset'}); | |||||||||||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||||||||||
| 66 | 97 | $log_processing->{'tagset'} = undef; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 97 | ▶ | if (defined $fields->{'comments'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 96 | $log_processing->setComments($fields->{'comments'}); | |||||||||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||||||||||
| 71 | 1 | $log_processing->{'comments'} = undef; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | 97 | ▶ | if (defined $fields->{'list_modified_level'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 60 | $log_processing->list_modified_level('list_modified_level', $fields->{'list_modified_level'}); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 97 | return($log_processing); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 60 | ▶ | sub list_modified_level { | ||||||||||||||||||||||||||
|
Subroutine
list_modified_level: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 60 | my $self = shift; | |||||||||||||||||||||||||||
| 82 | 60 | my $ref; | |||||||||||||||||||||||||||
| 83 | my $elt; | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 60 | ▶ | if ((@_) && (scalar @_ == 2)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and scalar @_ == 2
MC/DC0%0/2
@_ and scalar @_ == 2
@_
scalar @_ == 2
Truth table33%1/3
A and B
A= @_B= scalar @_ == 2
| |||||||||||||||||||||||||||||
| 86 | 60 | $self->{'reference'} = shift; | |||||||||||||||||||||||||||
| 87 | 60 | $self->{$self->{'reference'}} = []; | |||||||||||||||||||||||||||
| 88 | 60 | $ref = shift; | |||||||||||||||||||||||||||
| 89 | 60 | foreach $elt (@$ref) { | |||||||||||||||||||||||||||
| 90 | 69 | push @{$self->{$self->{'reference'}}}, $elt; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | 60 | return($self->{$self->{'reference'}}); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 85 | ▶ | sub next { | ||||||||||||||||||||||||||
|
Subroutine
next: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 97 | 85 | my $self = shift; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 85 | ▶ | $self->{'next'} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 85 | return($self->{'next'}); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 85 | ▶ | sub previous { | ||||||||||||||||||||||||||
|
Subroutine
previous: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 104 | 85 | my $self = shift; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 85 | ▶ | $self->{'previous'} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 85 | return($self->{'previous'}); | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 96 | ▶ | sub setId { | ||||||||||||||||||||||||||
|
Subroutine
setId: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 111 | 96 | my($self, $id) = @_; | |||||||||||||||||||||||||||
| 112 | # $id is a reference of an array | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 96 | $self->{'log_id'} = $id; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 192 | ▶ | sub getId { | ||||||||||||||||||||||||||
|
Subroutine
getId: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 118 | 192 | my($self) = @_; | |||||||||||||||||||||||||||
| 119 | # id field is a reference of an array | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 192 | return($self->{'log_id'}); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 96 | ▶ | sub setComments { | ||||||||||||||||||||||||||
|
Subroutine
setComments: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 125 | 96 | my($self, $Comments) = @_; | |||||||||||||||||||||||||||
| 126 | # $Comments is a reference of an array | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 96 | $self->{'comments'} = $Comments; | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub getComments { | ||||||||||||||||||||||||||
|
Subroutine
getComments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 132 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 133 | # comments field is a reference of an array | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 0 | return($self->{'comments'}); | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 0 | ▶ | sub setTagset { | ||||||||||||||||||||||||||
|
Subroutine
setTagset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 139 | 0 | my($self, $Tagset) = @_; | |||||||||||||||||||||||||||
| 140 | # $Tagset is a reference of an array | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | $self->{'tagset'} = $Tagset; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub getTagset { | ||||||||||||||||||||||||||
|
Subroutine
getTagset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 145 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 146 | # tagset field is a reference of an array | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | return($self->{'tagset'}); | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub setStamp { | ||||||||||||||||||||||||||
|
Subroutine
setStamp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 152 | 0 | my($self, $Stamp) = @_; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | $self->{'stamp'} = $Stamp; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub getStamp { | ||||||||||||||||||||||||||
|
Subroutine
getStamp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 158 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | return($self->{'stamp'}); | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 28 | ▶ | sub setCommandLine { | ||||||||||||||||||||||||||
|
Subroutine
setCommandLine: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 164 | 28 | my($self, $CommandLine) = @_; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 28 | $self->{'command_line'} = $CommandLine; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub getCommandLine { | ||||||||||||||||||||||||||
|
Subroutine
getCommandLine: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 170 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | return($self->{'command_line'}); | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 39 | ▶ | sub setSoftwareName { | ||||||||||||||||||||||||||
|
Subroutine
setSoftwareName: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 176 | 39 | my($self, $SoftwareName) = @_; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 39 | $self->{'software_name'} = $SoftwareName; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub getSoftwareName { | ||||||||||||||||||||||||||
|
Subroutine
getSoftwareName: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 182 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | return($self->{'software_name'}); | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 1 | ▶ | sub print { | ||||||||||||||||||||||||||
|
Subroutine
print: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 188 | 1 | my ($self, $fh) = @_; | |||||||||||||||||||||||||||
| 189 | 1 | ▶ | if (!defined $fh) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | $fh = \*STDERR | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 1 | my $field; | |||||||||||||||||||||||||||
| 193 | 1 | foreach $field (keys %$self) { | |||||||||||||||||||||||||||
| 194 | 8 | ▶ | if (defined $self->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 3 | print $fh "$field => " . $self->{$field} . "\n"; | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | 1 | return(0); | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 147 | ▶ | sub _getField { | ||||||||||||||||||||||||||
|
Subroutine
_getField: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 202 | 147 | my ($self, $field) = @_; | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 147 | return($self->{$field}); | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub _xmldecode { # to be optimized | ||||||||||||||||||||||||||
|
Subroutine
_xmldecode: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 209 | 0 | my ($self, $string) = @_; | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | $string =~ s/&/&/go; | |||||||||||||||||||||||||||
| 212 | 0 | $string =~ s/"/\"/og; | |||||||||||||||||||||||||||
| 213 | 0 | $string =~ s/'/\'/og; | |||||||||||||||||||||||||||
| 214 | 0 | $string =~ s/</</og; | |||||||||||||||||||||||||||
| 215 | 0 | $string =~ s/>/>/og; | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | return($string); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 7 | ▶ | sub _xmlencode { # to be optimized | ||||||||||||||||||||||||||
|
Subroutine
_xmlencode: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 221 | 7 | my ($self, $string) = @_; | |||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 7 | $string =~ s/&/&/og; | |||||||||||||||||||||||||||
| 224 | 7 | $string =~ s/\"/"/og; | |||||||||||||||||||||||||||
| 225 | 7 | $string =~ s/\'/'/og; | |||||||||||||||||||||||||||
| 226 | 7 | $string =~ s/</</og; | |||||||||||||||||||||||||||
| 227 | 7 | $string =~ s/>/>/og; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 7 | return($string); | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 3 | ▶ | sub XMLout { | ||||||||||||||||||||||||||
|
Subroutine
XMLout: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 234 | 3 | my ($self, $order) = @_; | |||||||||||||||||||||||||||
| 235 | # my $field; | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 3 | return($self->SUPER::XMLout("log_processing", $order)); | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | # my $str; | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | # $str = "\t<log_processing>\n"; | ||||||||||||||||||||||||||||
| 242 | # foreach $field (@$order) { | ||||||||||||||||||||||||||||
| 243 | # if (defined $self->_getField($field)) { | ||||||||||||||||||||||||||||
| 244 | # $str .= "\t\t<$field>" . $self->_xmlencode($self->_getField($field)) . "</$field>\n"; | ||||||||||||||||||||||||||||
| 245 | # } | ||||||||||||||||||||||||||||
| 246 | # } | ||||||||||||||||||||||||||||
| 247 | # $str .= "\t</log_processing>\n"; | ||||||||||||||||||||||||||||
| 248 | # return($str); | ||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 96 | ▶ | sub reference { | ||||||||||||||||||||||||||
|
Subroutine
reference: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 252 | 96 | my ($self) = @_; | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 96 | return([]); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 16 | 1; | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | __END__ | ||||||||||||||||||||||||||||