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