line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
###################### |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Copyright (C) 2011 TU Clausthal, Institut fuer Maschinenwesen, Joachim Langenbach |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify |
7
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
8
|
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
|
|
|
|
# (at your option) any later version. |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
12
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
|
|
|
|
# GNU General Public License for more details. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
17
|
|
|
|
|
|
|
# along with this program. If not, see . |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
###################### |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
22
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
47
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Pod::Weaver infos |
25
|
|
|
|
|
|
|
# ABSTRACT: Object to represant the changes of an option |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package CAD::Firemen::Change; |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
$CAD::Firemen::Change::VERSION = '0.7.0'; |
30
|
|
|
|
|
|
|
} |
31
|
1
|
|
|
1
|
|
4
|
use Exporter 'import'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
|
499
|
use CAD::Firemen::Common qw(strip); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
82
|
|
34
|
1
|
|
|
1
|
|
582
|
use CAD::Firemen::Change::Type; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1326
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new { |
37
|
0
|
|
|
0
|
1
|
|
my ($class) = shift; |
38
|
0
|
|
|
|
|
|
my (%params) = @_; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# check parameters |
41
|
0
|
0
|
|
|
|
|
if(!exists($params{"name"})){ |
42
|
0
|
|
|
|
|
|
$params{"name"} = ""; |
43
|
|
|
|
|
|
|
} |
44
|
0
|
0
|
|
|
|
|
if(!exists($params{"valueOld"})){ |
45
|
0
|
|
|
|
|
|
$params{"valueOld"} = ""; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
0
|
|
|
|
|
if(!exists($params{"valueNew"})){ |
48
|
0
|
|
|
|
|
|
$params{"valueNew"} = ""; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $self = { |
52
|
|
|
|
|
|
|
'_option' => $params{"name"}, |
53
|
|
|
|
|
|
|
'_valueOld' => $params{"valueOld"}, |
54
|
0
|
|
|
|
|
|
'_valueNew' => $params{"valueNew"}, |
55
|
|
|
|
|
|
|
'_changeType' => {}, |
56
|
|
|
|
|
|
|
'_changeDescription' => "", |
57
|
|
|
|
|
|
|
'_possibleValuesOld' => [], |
58
|
|
|
|
|
|
|
'_possibleValuesNew' => [], |
59
|
|
|
|
|
|
|
'_defaultValueOld' => "", |
60
|
|
|
|
|
|
|
'_defaultValueNew' => "" |
61
|
|
|
|
|
|
|
}; |
62
|
0
|
|
|
|
|
|
bless $self, $class; |
63
|
0
|
|
|
|
|
|
$self->evalChange(); |
64
|
0
|
|
|
|
|
|
return $self; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub setOption { |
68
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
my $name = shift; |
70
|
0
|
0
|
|
|
|
|
if(!defined($name)){ |
71
|
0
|
|
|
|
|
|
return 0; |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
|
$self->{'_option'} = $name; |
74
|
0
|
|
|
|
|
|
return 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub option { |
78
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
79
|
0
|
|
|
|
|
|
return $self->{'_option'}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub setValueOld { |
83
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
84
|
0
|
|
|
|
|
|
my $value = shift; |
85
|
0
|
0
|
|
|
|
|
if(!defined($value)){ |
86
|
0
|
|
|
|
|
|
return 0; |
87
|
|
|
|
|
|
|
} |
88
|
0
|
|
|
|
|
|
$self->{'_valueOld'} = $value; |
89
|
0
|
|
|
|
|
|
return 1; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub valueOld { |
93
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
94
|
0
|
|
|
|
|
|
return $self->{'_valueOld'}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub setValueNew { |
98
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
99
|
0
|
|
|
|
|
|
my $value = shift; |
100
|
0
|
0
|
|
|
|
|
if(!defined($value)){ |
101
|
0
|
|
|
|
|
|
return 0; |
102
|
|
|
|
|
|
|
} |
103
|
0
|
|
|
|
|
|
$self->{'_valueNew'} = $value; |
104
|
0
|
|
|
|
|
|
return 1; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub valueNew { |
108
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
109
|
0
|
|
|
|
|
|
return $self->{'_valueNew'}; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub setPossibleValuesOld { |
113
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
114
|
0
|
|
|
|
|
|
my $valuesRef = shift; |
115
|
0
|
0
|
0
|
|
|
|
if(!defined($valuesRef) || (ref($valuesRef) ne "ARRAY")){ |
116
|
0
|
|
|
|
|
|
return 0; |
117
|
|
|
|
|
|
|
} |
118
|
0
|
|
|
|
|
|
$self->{'_possibleValuesOld'} = $valuesRef; |
119
|
0
|
|
|
|
|
|
return 1; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub possibleValuesOld { |
123
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
124
|
0
|
|
|
|
|
|
return $self->{'_possibleValuesOld'}; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub setPossibleValuesNew { |
128
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
129
|
0
|
|
|
|
|
|
my $valuesRef = shift; |
130
|
0
|
0
|
0
|
|
|
|
if(!defined($valuesRef) || (ref($valuesRef) ne "ARRAY")){ |
131
|
0
|
|
|
|
|
|
return 0; |
132
|
|
|
|
|
|
|
} |
133
|
0
|
|
|
|
|
|
$self->{'_possibleValuesNew'} = $valuesRef; |
134
|
0
|
|
|
|
|
|
return 1; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub possibleValuesNew { |
138
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
139
|
0
|
|
|
|
|
|
return $self->{'_possibleValuesNew'}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub setDefaultValueOld { |
144
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
145
|
0
|
|
|
|
|
|
my $value = shift; |
146
|
0
|
0
|
|
|
|
|
if(!defined($value)){ |
147
|
0
|
|
|
|
|
|
return 0; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
# default value must be an possible value |
150
|
0
|
|
|
|
|
|
my $found = 0; |
151
|
0
|
|
|
|
|
|
foreach my $posValue (@{$self->possibleValuesOld()}){ |
|
0
|
|
|
|
|
|
|
152
|
0
|
0
|
|
|
|
|
if($value eq $posValue){ |
153
|
0
|
|
|
|
|
|
$found = 1; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
0
|
0
|
|
|
|
|
if(!$found){ |
157
|
0
|
|
|
|
|
|
return 0; |
158
|
|
|
|
|
|
|
} |
159
|
0
|
|
|
|
|
|
$self->{'_defaultValueOld'} = $value; |
160
|
0
|
|
|
|
|
|
return 1; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub defaultValueOld { |
164
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
165
|
0
|
|
|
|
|
|
return $self->{'_defaultValueOld'}; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub setDefaultValueNew { |
169
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
170
|
0
|
|
|
|
|
|
my $value = shift; |
171
|
0
|
0
|
|
|
|
|
if(!defined($value)){ |
172
|
0
|
|
|
|
|
|
return 0; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
# default value must be an possible value |
175
|
0
|
|
|
|
|
|
my $found = 0; |
176
|
0
|
|
|
|
|
|
foreach my $posValue (@{$self->possibleValuesNew()}){ |
|
0
|
|
|
|
|
|
|
177
|
0
|
0
|
|
|
|
|
if($value eq $posValue){ |
178
|
0
|
|
|
|
|
|
$found = 1; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
} |
181
|
0
|
0
|
|
|
|
|
if(!$found){ |
182
|
0
|
|
|
|
|
|
return 0; |
183
|
|
|
|
|
|
|
} |
184
|
0
|
|
|
|
|
|
$self->{'_defaultValueNew'} = $value; |
185
|
0
|
|
|
|
|
|
return 1; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub defaultValueNew { |
189
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
190
|
0
|
|
|
|
|
|
return $self->{'_defaultValueNew'}; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub setChangeDescription { |
194
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
195
|
0
|
|
|
|
|
|
my $value = shift; |
196
|
0
|
0
|
|
|
|
|
if(!defined($value)){ |
197
|
0
|
|
|
|
|
|
return 0; |
198
|
|
|
|
|
|
|
} |
199
|
0
|
|
|
|
|
|
$self->{'_changeDescription'} = strip($value); |
200
|
0
|
|
|
|
|
|
return 1; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub changeDescription { |
204
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
205
|
0
|
|
|
|
|
|
return $self->{'_changeDescription'}; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub evalChange { |
209
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# reset change type |
212
|
0
|
|
|
|
|
|
$self->_setChangeType(CAD::Firemen::Change::Type->NoChange); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# determine whether values or default values have changed |
215
|
0
|
|
|
|
|
|
my $valuesChanged = 0; |
216
|
0
|
|
|
|
|
|
my $defaultChanged = 0; |
217
|
|
|
|
|
|
|
# check for removed options |
218
|
0
|
|
|
|
|
|
foreach my $value (@{$self->possibleValuesOld()}){ |
|
0
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
my $exist = 0; |
220
|
0
|
|
|
|
|
|
foreach my $newValue (@{$self->possibleValuesNew()}){ |
|
0
|
|
|
|
|
|
|
221
|
0
|
0
|
|
|
|
|
if($value eq $newValue){ |
222
|
0
|
|
|
|
|
|
$exist = 1; |
223
|
0
|
|
|
|
|
|
last; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
} |
226
|
0
|
0
|
|
|
|
|
if(!$exist){ |
227
|
0
|
|
|
|
|
|
$self->setChangeDescription($self->changeDescription() ."\nRemoved ". $value); |
228
|
0
|
|
|
|
|
|
$valuesChanged = 1; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
# check for added options |
233
|
0
|
|
|
|
|
|
foreach my $value (@{$self->possibleValuesNew()}){ |
|
0
|
|
|
|
|
|
|
234
|
0
|
|
|
|
|
|
my $exist = 0; |
235
|
0
|
|
|
|
|
|
foreach my $oldValue (@{$self->possibleValuesOld()}){ |
|
0
|
|
|
|
|
|
|
236
|
0
|
0
|
|
|
|
|
if($value eq $oldValue){ |
237
|
0
|
|
|
|
|
|
$exist = 1; |
238
|
0
|
|
|
|
|
|
last; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
} |
241
|
0
|
0
|
|
|
|
|
if(!$exist){ |
242
|
0
|
|
|
|
|
|
$self->setChangeDescription($self->changeDescription() ."\nAdded ". $value); |
243
|
0
|
|
|
|
|
|
$valuesChanged = 1; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
# check for changed default value |
248
|
0
|
0
|
|
|
|
|
if($self->defaultValueNew() ne $self->defaultValueOld()){ |
249
|
0
|
|
|
|
|
|
$self->setChangeDescription($self->changeDescription() ."\nDefault value changed from ". $self->defaultValueOld() ." to ". $self->defaultValueNew()); |
250
|
0
|
|
|
|
|
|
$defaultChanged = 1; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
# evaluate results |
254
|
0
|
0
|
0
|
|
|
|
if(($self->valueOld() ne $self->valueNew()) && (uc($self->valueOld()) eq uc($self->valueNew()))){ |
255
|
0
|
|
|
|
|
|
$self->_addChangeType(CAD::Firemen::Change::Type->Case); |
256
|
|
|
|
|
|
|
} |
257
|
0
|
0
|
0
|
|
|
|
if(($self->valueOld() =~ m/^[A-Za-z]:[\\\/]/) && ($self->valueNew() =~ m/^[A-Za-z]:[\\\/]/)){ |
258
|
0
|
|
|
|
|
|
$self->_addChangeType(CAD::Firemen::Change::Type->Path); |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
# NoSpecial means only valueOld and valueNew have changed |
261
|
|
|
|
|
|
|
# therefore it is NoSpecial, if values are not equal and it is not Case or Path |
262
|
0
|
0
|
0
|
|
|
|
if(($self->valueOld() ne $self->valueNew()) && !$self->changeType(CAD::Firemen::Change::Type->Case) && !$self->changeType(CAD::Firemen::Change::Type->Case)){ |
|
|
|
0
|
|
|
|
|
263
|
0
|
|
|
|
|
|
$self->_addChangeType(CAD::Firemen::Change::Type->NoSpecial); |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
0
|
0
|
|
|
|
|
if($valuesChanged){ |
267
|
0
|
|
|
|
|
|
$self->_addChangeType(CAD::Firemen::Change::Type->ValuesChanged); |
268
|
|
|
|
|
|
|
} |
269
|
0
|
0
|
|
|
|
|
if($defaultChanged){ |
270
|
0
|
|
|
|
|
|
$self->_addChangeType(CAD::Firemen::Change::Type->DefaultValueChanged); |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
0
|
|
|
|
|
|
return 1; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub _setChangeType { |
277
|
0
|
|
|
0
|
|
|
my $self = shift; |
278
|
0
|
|
|
|
|
|
my $value = shift; |
279
|
0
|
0
|
|
|
|
|
if(!defined($value)){ |
280
|
0
|
|
|
|
|
|
return 0; |
281
|
|
|
|
|
|
|
} |
282
|
0
|
|
|
|
|
|
delete($self->{'_changeType'}); |
283
|
0
|
|
|
|
|
|
$self->{'_changeType'} = {}; |
284
|
0
|
|
|
|
|
|
return $self->_addChangeType($value); |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub _addChangeType { |
288
|
0
|
|
|
0
|
|
|
my $self = shift; |
289
|
0
|
|
|
|
|
|
my $value = shift; |
290
|
0
|
0
|
|
|
|
|
if(!defined($value)){ |
291
|
0
|
|
|
|
|
|
return 0; |
292
|
|
|
|
|
|
|
} |
293
|
0
|
|
|
|
|
|
$self->{'_changeType'}->{$value} = 1; |
294
|
|
|
|
|
|
|
# if we have a change now, remove NoChange |
295
|
0
|
0
|
|
|
|
|
if($value ne CAD::Firemen::Change::Type->NoChange){ |
296
|
0
|
0
|
|
|
|
|
if(exists($self->{'_changeType'}->{CAD::Firemen::Change::Type->NoChange})){ |
297
|
0
|
|
|
|
|
|
delete($self->{'_changeType'}->{CAD::Firemen::Change::Type->NoChange}); |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
} |
300
|
0
|
|
|
|
|
|
return 1; |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
sub changeType { |
304
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
305
|
0
|
|
|
|
|
|
my $type = shift; |
306
|
0
|
0
|
|
|
|
|
if(!defined($type)){ |
307
|
0
|
|
|
|
|
|
return 0; |
308
|
|
|
|
|
|
|
} |
309
|
0
|
0
|
|
|
|
|
if(exists($self->{'_changeType'}->{$type})){ |
310
|
0
|
|
|
|
|
|
return 1; |
311
|
|
|
|
|
|
|
} |
312
|
0
|
|
|
|
|
|
return 0; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub highlightColor { |
316
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
317
|
0
|
0
|
|
|
|
|
if($self->changeType(CAD::Firemen::Change::Type->Case)){ |
|
|
0
|
|
|
|
|
|
318
|
0
|
|
|
|
|
|
return "CYAN"; |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
elsif($self->changeType(CAD::Firemen::Change::Type->Path)){ |
321
|
0
|
|
|
|
|
|
return "MAGENTA"; |
322
|
|
|
|
|
|
|
} |
323
|
0
|
|
|
|
|
|
return "YELLOW"; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
1; |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
__END__ |