| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################# |
|
2
|
|
|
|
|
|
|
# A baseclass for Graph::Easy objects like nodes, edges etc. |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
############################################################################# |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Graph::Easy::Base; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.75'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
50
|
|
|
50
|
|
26799
|
use strict; |
|
|
50
|
|
|
|
|
101
|
|
|
|
50
|
|
|
|
|
2109
|
|
|
11
|
50
|
|
|
50
|
|
362
|
use warnings; |
|
|
50
|
|
|
|
|
97
|
|
|
|
50
|
|
|
|
|
1191022
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
############################################################################# |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
{ |
|
16
|
|
|
|
|
|
|
# protected vars |
|
17
|
|
|
|
|
|
|
my $id = 0; |
|
18
|
8261
|
|
|
8261
|
|
46191
|
sub _new_id { $id++; } |
|
19
|
809
|
|
|
809
|
|
5033
|
sub _reset_id { $id = 0; } |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
############################################################################# |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
|
|
|
|
|
|
# Create a new object. This is a generic routine that is inherited |
|
27
|
|
|
|
|
|
|
# by many other things like Edge, Cell etc. |
|
28
|
8261
|
|
|
8261
|
1
|
53243
|
my $self = bless { id => _new_id() }, shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
8261
|
|
|
|
|
16632
|
my $args = $_[0]; |
|
31
|
8261
|
100
|
100
|
|
|
58608
|
$args = { name => $_[0] } if ref($args) ne 'HASH' && @_ == 1; |
|
32
|
8261
|
100
|
100
|
|
|
67024
|
$args = { @_ } if ref($args) ne 'HASH' && @_ > 1; |
|
33
|
|
|
|
|
|
|
|
|
34
|
8261
|
|
|
|
|
41221
|
$self->_init($args); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _init |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
|
|
|
|
|
|
# Generic init routine, to be overriden in subclasses. |
|
40
|
1
|
|
|
1
|
|
2
|
my ($self,$args) = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
3
|
$self; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub self |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
$self; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
############################################################################# |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub no_fatal_errors |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
7
|
|
|
7
|
1
|
36
|
my $self = shift; |
|
57
|
|
|
|
|
|
|
|
|
58
|
7
|
50
|
|
|
|
45
|
$self->{fatal_errors} = ($_[1] ? 1 : 0) if @_ > 0; |
|
|
|
50
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
7
|
|
50
|
|
|
45
|
~ ($self->{fatal_errors} || 0); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub fatal_errors |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
440
|
|
|
440
|
1
|
1084
|
my $self = shift; |
|
66
|
|
|
|
|
|
|
|
|
67
|
440
|
50
|
|
|
|
2667
|
$self->{fatal_errors} = ($_[1] ? 0 : 1) if @_ > 0; |
|
|
|
100
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
440
|
50
|
|
|
|
1881
|
$self->{fatal_errors} || 0; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub error |
|
73
|
|
|
|
|
|
|
{ |
|
74
|
660
|
|
|
660
|
1
|
36511
|
my $self = shift; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# If we switched to a temp. Graphviz parser, then set the error on the |
|
77
|
|
|
|
|
|
|
# original parser object, too: |
|
78
|
660
|
100
|
|
|
|
2027
|
$self->{_old_self}->error(@_) if ref($self->{_old_self}); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# if called on a member on a graph, call error() on the graph itself: |
|
81
|
660
|
100
|
|
|
|
1740
|
return $self->{graph}->error(@_) if ref($self->{graph}); |
|
82
|
|
|
|
|
|
|
|
|
83
|
653
|
100
|
|
|
|
1625
|
if (defined $_[0]) |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
115
|
|
|
|
|
188
|
$self->{error} = $_[0]; |
|
86
|
115
|
100
|
|
|
|
226
|
if ($self->{_catch_errors}) |
|
87
|
|
|
|
|
|
|
{ |
|
88
|
1
|
|
|
|
|
3
|
push @{$self->{_errors}}, $self->{error}; |
|
|
1
|
|
|
|
|
3
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
else |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
114
|
50
|
33
|
|
|
310
|
$self->_croak($self->{error}, 2) |
|
93
|
|
|
|
|
|
|
if ($self->{fatal_errors}) && $self->{error} ne ''; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
653
|
100
|
|
|
|
5728
|
$self->{error} || ''; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub error_as_html |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
|
|
|
|
|
|
# return error() properly escaped |
|
102
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
my $msg = $self->{error}; |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
0
|
$msg =~ s/&/&/g; |
|
107
|
0
|
|
|
|
|
0
|
$msg =~ s/</g; |
|
108
|
0
|
|
|
|
|
0
|
$msg =~ s/>/>/g; |
|
109
|
0
|
|
|
|
|
0
|
$msg =~ s/"/"/g; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
0
|
$msg; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub catch_messages |
|
115
|
|
|
|
|
|
|
{ |
|
116
|
|
|
|
|
|
|
# Catch all warnings (and errors if no_fatal_errors() was used) |
|
117
|
|
|
|
|
|
|
# these can later be retrieved with warnings() and errors(): |
|
118
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
119
|
|
|
|
|
|
|
|
|
120
|
1
|
50
|
|
|
|
6
|
if (@_ > 0) |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
1
|
50
|
|
|
|
6
|
if ($_[0]) |
|
123
|
|
|
|
|
|
|
{ |
|
124
|
1
|
|
|
|
|
3
|
$self->{_catch_warnings} = 1; |
|
125
|
1
|
|
|
|
|
3
|
$self->{_catch_errors} = 1; |
|
126
|
1
|
|
|
|
|
3
|
$self->{_warnings} = []; |
|
127
|
1
|
|
|
|
|
3
|
$self->{_errors} = []; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
else |
|
130
|
|
|
|
|
|
|
{ |
|
131
|
0
|
|
|
|
|
0
|
$self->{_catch_warnings} = 0; |
|
132
|
0
|
|
|
|
|
0
|
$self->{_catch_errors} = 0; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
} |
|
135
|
1
|
|
|
|
|
4
|
$self; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub catch_warnings |
|
139
|
|
|
|
|
|
|
{ |
|
140
|
|
|
|
|
|
|
# Catch all warnings |
|
141
|
|
|
|
|
|
|
# these can later be retrieved with warnings(): |
|
142
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
143
|
|
|
|
|
|
|
|
|
144
|
1
|
50
|
|
|
|
340
|
if (@_ > 0) |
|
145
|
|
|
|
|
|
|
{ |
|
146
|
1
|
50
|
|
|
|
5
|
if ($_[0]) |
|
147
|
|
|
|
|
|
|
{ |
|
148
|
1
|
|
|
|
|
3
|
$self->{_catch_warnings} = 1; |
|
149
|
1
|
|
|
|
|
5
|
$self->{_warnings} = []; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
else |
|
152
|
|
|
|
|
|
|
{ |
|
153
|
0
|
|
|
|
|
0
|
$self->{_catch_warnings} = 0; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
} |
|
156
|
1
|
|
|
|
|
3
|
$self->{_catch_warnings}; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub catch_errors |
|
160
|
|
|
|
|
|
|
{ |
|
161
|
|
|
|
|
|
|
# Catch all errors |
|
162
|
|
|
|
|
|
|
# these can later be retrieved with errors(): |
|
163
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
164
|
|
|
|
|
|
|
|
|
165
|
1
|
50
|
|
|
|
5
|
if (@_ > 0) |
|
166
|
|
|
|
|
|
|
{ |
|
167
|
1
|
50
|
|
|
|
3
|
if ($_[0]) |
|
168
|
|
|
|
|
|
|
{ |
|
169
|
1
|
|
|
|
|
4
|
$self->{_catch_errors} = 1; |
|
170
|
1
|
|
|
|
|
4
|
$self->{_errors} = []; |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
else |
|
173
|
|
|
|
|
|
|
{ |
|
174
|
0
|
|
|
|
|
0
|
$self->{_catch_errors} = 0; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
} |
|
177
|
1
|
|
|
|
|
456
|
$self->{_catch_errors}; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub warnings |
|
181
|
|
|
|
|
|
|
{ |
|
182
|
|
|
|
|
|
|
# return all warnings that occured after catch_messages(1) |
|
183
|
2
|
|
|
2
|
1
|
9
|
my $self = shift; |
|
184
|
|
|
|
|
|
|
|
|
185
|
2
|
|
|
|
|
3
|
@{$self->{_warnings}}; |
|
|
2
|
|
|
|
|
10
|
|
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub errors |
|
189
|
|
|
|
|
|
|
{ |
|
190
|
|
|
|
|
|
|
# return all errors that occured after catch_messages(1) |
|
191
|
2
|
|
|
2
|
1
|
5
|
my $self = shift; |
|
192
|
|
|
|
|
|
|
|
|
193
|
2
|
|
|
|
|
4
|
@{$self->{_errors}}; |
|
|
2
|
|
|
|
|
8
|
|
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub warn |
|
197
|
|
|
|
|
|
|
{ |
|
198
|
4
|
|
|
4
|
1
|
1417
|
my ($self, $msg) = @_; |
|
199
|
|
|
|
|
|
|
|
|
200
|
4
|
100
|
|
|
|
19
|
if ($self->{_catch_warnings}) |
|
201
|
|
|
|
|
|
|
{ |
|
202
|
1
|
|
|
|
|
2
|
push @{$self->{_warnings}}, $msg; |
|
|
1
|
|
|
|
|
4
|
|
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
else |
|
205
|
|
|
|
|
|
|
{ |
|
206
|
3
|
|
|
|
|
39
|
require Carp; |
|
207
|
3
|
|
|
|
|
1248
|
Carp::carp('Warning: ' . $msg); |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub _croak |
|
212
|
|
|
|
|
|
|
{ |
|
213
|
0
|
|
|
0
|
|
0
|
my ($self, $msg, $level) = @_; |
|
214
|
0
|
0
|
|
|
|
0
|
$level = 1 unless defined $level; |
|
215
|
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
0
|
require Carp; |
|
217
|
0
|
0
|
0
|
|
|
0
|
if (ref($self) && $self->{debug}) |
|
218
|
|
|
|
|
|
|
{ |
|
219
|
0
|
|
|
|
|
0
|
$Carp::CarpLevel = $level; # don't report Base itself |
|
220
|
0
|
|
|
|
|
0
|
Carp::confess($msg); |
|
221
|
|
|
|
|
|
|
} |
|
222
|
|
|
|
|
|
|
else |
|
223
|
|
|
|
|
|
|
{ |
|
224
|
0
|
|
|
|
|
0
|
Carp::croak($msg); |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
############################################################################# |
|
229
|
|
|
|
|
|
|
# class management |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub sub_class |
|
232
|
|
|
|
|
|
|
{ |
|
233
|
|
|
|
|
|
|
# get/set the subclass |
|
234
|
59
|
|
|
59
|
1
|
108
|
my $self = shift; |
|
235
|
|
|
|
|
|
|
|
|
236
|
59
|
100
|
|
|
|
189
|
if (defined $_[0]) |
|
237
|
|
|
|
|
|
|
{ |
|
238
|
46
|
|
|
|
|
146
|
$self->{class} =~ s/\..*//; # nix subclass |
|
239
|
46
|
|
|
|
|
142
|
$self->{class} .= '.' . $_[0]; # append new one |
|
240
|
46
|
|
|
|
|
106
|
delete $self->{cache}; |
|
241
|
46
|
|
|
|
|
163
|
$self->{cache}->{subclass} = $_[0]; |
|
242
|
46
|
|
|
|
|
131
|
$self->{cache}->{class} = $self->{class}; |
|
243
|
46
|
|
|
|
|
157
|
return; |
|
244
|
|
|
|
|
|
|
} |
|
245
|
13
|
|
|
|
|
40
|
$self->{class} =~ /\.(.*)/; |
|
246
|
|
|
|
|
|
|
|
|
247
|
13
|
100
|
|
|
|
56
|
return $1 if defined $1; |
|
248
|
|
|
|
|
|
|
|
|
249
|
10
|
100
|
|
|
|
43
|
return $self->{cache}->{subclass} if defined $self->{cache}->{subclass}; |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# Subclass not defined, so check our base class for a possible set class |
|
252
|
|
|
|
|
|
|
# attribute and return this: |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
# take a shortcut |
|
255
|
5
|
|
|
|
|
10
|
my $g = $self->{graph}; |
|
256
|
5
|
50
|
|
|
|
14
|
if (defined $g) |
|
257
|
|
|
|
|
|
|
{ |
|
258
|
5
|
|
|
|
|
16
|
my $subclass = $g->{att}->{$self->{class}}->{class}; |
|
259
|
5
|
50
|
|
|
|
16
|
$subclass = '' unless defined $subclass; |
|
260
|
5
|
|
|
|
|
12
|
$self->{cache}->{subclass} = $subclass; |
|
261
|
5
|
|
|
|
|
14
|
$self->{cache}->{class} = $self->{class}; |
|
262
|
5
|
|
|
|
|
14
|
return $subclass; |
|
263
|
|
|
|
|
|
|
} |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
# not part of a graph? |
|
266
|
0
|
|
|
|
|
0
|
$self->{cache}->{subclass} = $self->attribute('class'); |
|
267
|
|
|
|
|
|
|
} |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
sub class |
|
270
|
|
|
|
|
|
|
{ |
|
271
|
|
|
|
|
|
|
# return our full class name like "node.subclass" or "node" |
|
272
|
41851
|
|
|
41851
|
1
|
72117
|
my $self = shift; |
|
273
|
|
|
|
|
|
|
|
|
274
|
41851
|
50
|
|
|
|
118622
|
$self->error("class() method does not take arguments") if @_ > 0; |
|
275
|
|
|
|
|
|
|
|
|
276
|
41851
|
|
|
|
|
88533
|
$self->{class} =~ /\.(.*)/; |
|
277
|
|
|
|
|
|
|
|
|
278
|
41851
|
100
|
|
|
|
253651
|
return $self->{class} if defined $1; |
|
279
|
|
|
|
|
|
|
|
|
280
|
3665
|
100
|
|
|
|
15678
|
return $self->{cache}->{class} if defined $self->{cache}->{class}; |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# Subclass not defined, so check our base class for a possible set class |
|
283
|
|
|
|
|
|
|
# attribute and return this: |
|
284
|
|
|
|
|
|
|
|
|
285
|
2529
|
|
|
|
|
3670
|
my $subclass; |
|
286
|
|
|
|
|
|
|
# take a shortcut: |
|
287
|
2529
|
|
|
|
|
5526
|
my $g = $self->{graph}; |
|
288
|
2529
|
100
|
|
|
|
7949
|
if (defined $g) |
|
289
|
|
|
|
|
|
|
{ |
|
290
|
2360
|
|
|
|
|
6322
|
$subclass = $g->{att}->{$self->{class}}->{class}; |
|
291
|
2360
|
50
|
|
|
|
6791
|
$subclass = '' unless defined $subclass; |
|
292
|
|
|
|
|
|
|
} |
|
293
|
|
|
|
|
|
|
|
|
294
|
2529
|
100
|
|
|
|
6186
|
$subclass = $self->{att}->{class} unless defined $subclass; |
|
295
|
2529
|
100
|
|
|
|
5421
|
$subclass = '' unless defined $subclass; |
|
296
|
2529
|
|
|
|
|
7022
|
$self->{cache}->{subclass} = $subclass; |
|
297
|
2529
|
50
|
|
|
|
7984
|
$subclass = '.' . $subclass if $subclass ne ''; |
|
298
|
|
|
|
|
|
|
|
|
299
|
2529
|
|
|
|
|
18237
|
$self->{cache}->{class} = $self->{class} . $subclass; |
|
300
|
|
|
|
|
|
|
} |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub main_class |
|
303
|
|
|
|
|
|
|
{ |
|
304
|
1035
|
|
|
1035
|
1
|
4744
|
my $self = shift; |
|
305
|
|
|
|
|
|
|
|
|
306
|
1035
|
|
|
|
|
5609
|
$self->{class} =~ /^(.+?)(\.|\z)/; # extract first part |
|
307
|
|
|
|
|
|
|
|
|
308
|
1035
|
|
|
|
|
5317
|
$1; |
|
309
|
|
|
|
|
|
|
} |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
1; |
|
312
|
|
|
|
|
|
|
__END__ |