line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of StorageDisplay |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2014-2023 by Vincent Danjean. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
1
|
|
|
1
|
|
229255
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
29
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package StorageDisplay::Data::Elem; |
13
|
|
|
|
|
|
|
# ABSTRACT: Handle something that will be displayed and can be linked |
14
|
|
|
|
|
|
|
# from/to as a tree for StorageDisplay |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '2.04'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
540
|
use Moose; |
|
1
|
|
|
|
|
461578
|
|
|
1
|
|
|
|
|
6
|
|
19
|
1
|
|
|
1
|
|
8064
|
use namespace::sweep; |
|
1
|
|
|
|
|
13178
|
|
|
1
|
|
|
|
|
6
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
633
|
use StorageDisplay::Role; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
70
|
|
22
|
1
|
|
|
1
|
|
642
|
use Object::ID; |
|
1
|
|
|
|
|
5304
|
|
|
1
|
|
|
|
|
7
|
|
23
|
1
|
|
|
1
|
|
53
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
384
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
with ( |
26
|
|
|
|
|
|
|
"StorageDisplay::Role::Iterable" |
27
|
|
|
|
|
|
|
=> { |
28
|
|
|
|
|
|
|
iterable => "StorageDisplay::Data::Elem", |
29
|
|
|
|
|
|
|
name => "Recursive", |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
"StorageDisplay::Role::Style::Base::Elem" |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'consume' => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => 'ArrayRef[StorageDisplay::Block]', |
37
|
|
|
|
|
|
|
traits => [ 'Array' ], |
38
|
|
|
|
|
|
|
default => sub { return []; }, |
39
|
|
|
|
|
|
|
lazy => 1, |
40
|
|
|
|
|
|
|
handles => { |
41
|
|
|
|
|
|
|
'consumeBlock' => 'push', |
42
|
|
|
|
|
|
|
'consumedBlocks' => 'elements', |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has 'provide' => ( |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
isa => 'ArrayRef[StorageDisplay::Block]', |
49
|
|
|
|
|
|
|
traits => [ 'Array' ], |
50
|
|
|
|
|
|
|
default => sub { return []; }, |
51
|
|
|
|
|
|
|
lazy => 1, |
52
|
|
|
|
|
|
|
handles => { |
53
|
|
|
|
|
|
|
'provideBlock' => 'push', |
54
|
|
|
|
|
|
|
'allProvidedBlocks' => 'elements', |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
init_arg => undef, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
around 'provideBlock' => sub { |
60
|
|
|
|
|
|
|
my $orig = shift; |
61
|
|
|
|
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
for my $b (@_) { |
64
|
|
|
|
|
|
|
$b->providedBy($self); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
#print STDERR "INFO ", $self->name, " : provides ", map { $_->name } (@_); |
67
|
|
|
|
|
|
|
#print STDERR "\n"; |
68
|
|
|
|
|
|
|
return $self->$orig(@_); |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#sub BUILD { |
72
|
|
|
|
|
|
|
# my $self = shift; |
73
|
|
|
|
|
|
|
# my $args = shift; |
74
|
|
|
|
|
|
|
# |
75
|
|
|
|
|
|
|
# print STDERR "INFO: ", $self->name, " : consumes ", |
76
|
|
|
|
|
|
|
# join(', ', map { $_->name } ($self->consumedBlocks)), "\n"; |
77
|
|
|
|
|
|
|
# return $self; |
78
|
|
|
|
|
|
|
#} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub has_parent { |
81
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
82
|
0
|
|
|
|
|
0
|
return $self->nb_parents == 1; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub parent { |
86
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
87
|
0
|
0
|
|
|
|
0
|
if ($self->nb_parents != 1) { |
88
|
0
|
|
|
|
|
0
|
croak "Unkown parent requested for ".$self->label; |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
0
|
return ($self->parents)[0]; |
91
|
|
|
|
|
|
|
}; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
has 'label' => ( |
94
|
|
|
|
|
|
|
is => 'rw', |
95
|
|
|
|
|
|
|
isa => 'Str', |
96
|
|
|
|
|
|
|
required => 0, |
97
|
|
|
|
|
|
|
default => "NO LABEL", |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub disp_size { |
101
|
7
|
|
|
7
|
0
|
1030
|
my $self = shift; |
102
|
7
|
|
|
|
|
15
|
my $size = shift; |
103
|
7
|
|
|
|
|
13
|
my $unit = 'B'; |
104
|
7
|
|
|
|
|
11
|
my $d=2; |
105
|
|
|
|
|
|
|
#print STDERR "\n\ninit size=$size\n"; |
106
|
|
|
|
|
|
|
{ |
107
|
1
|
|
|
1
|
|
477
|
use bigrat; |
|
1
|
|
|
|
|
2734
|
|
|
1
|
|
|
|
|
4
|
|
|
7
|
|
|
|
|
13
|
|
108
|
7
|
|
|
|
|
11
|
my $divide = 1; |
109
|
7
|
50
|
|
|
|
102
|
if ($size >= 1024) { $unit = 'kiB'; } |
|
7
|
|
|
|
|
6527
|
|
110
|
7
|
50
|
|
|
|
33
|
if ($size >= 1048576) { $unit = 'MiB'; $divide *= 1024; } |
|
7
|
|
|
|
|
5821
|
|
|
7
|
|
|
|
|
26
|
|
111
|
7
|
50
|
|
|
|
1950
|
if ($size >= 1073741824) { $unit = 'GiB'; $divide *= 1024; } |
|
7
|
|
|
|
|
5795
|
|
|
7
|
|
|
|
|
23
|
|
112
|
7
|
50
|
|
|
|
1614
|
if ($size >= 1099511627776) { $unit = 'TiB'; $divide *= 1024; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
113
|
7
|
50
|
|
|
|
5816
|
if ($size >= 1125899906842624) { $unit = 'PiB'; $divide *= 1024; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
114
|
7
|
50
|
|
|
|
5845
|
if ($size >= 1152921504606846976) { $unit = 'EiB'; $divide *= 1024; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
115
|
|
|
|
|
|
|
|
116
|
7
|
50
|
|
|
|
6177
|
if ($unit eq 'B') { |
117
|
0
|
|
|
|
|
0
|
return "$size B"; |
118
|
|
|
|
|
|
|
} else { |
119
|
7
|
|
|
|
|
28
|
$size /= $divide; |
120
|
|
|
|
|
|
|
} |
121
|
7
|
|
|
|
|
8013
|
$size = $size * 1000 / 1024; |
122
|
7
|
100
|
|
|
|
5923
|
if ($size >= 10000) { $d = 1;} |
|
3
|
|
|
|
|
295
|
|
123
|
7
|
50
|
|
|
|
351
|
if ($size >= 100000) { $d = 0;} |
|
0
|
|
|
|
|
0
|
|
124
|
|
|
|
|
|
|
#print STDERR "size=$size ", ref($size), "\n"; |
125
|
7
|
|
|
|
|
538
|
$size=int($size/10**(3-$d)+0.5)*10**(3-$d); |
126
|
|
|
|
|
|
|
#print STDERR "size=$size ", ref($size), "\n"; |
127
|
7
|
|
|
|
|
22645
|
$size = $size->numify(); |
128
|
|
|
|
|
|
|
} |
129
|
7
|
|
|
|
|
286
|
return sprintf("%.$d"."f $unit", $size/1000); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub statecolor { |
133
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
134
|
0
|
|
|
|
|
|
my $state = shift; |
135
|
|
|
|
|
|
|
|
136
|
0
|
0
|
|
|
|
|
if ($state eq "free") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
return "green"; |
138
|
|
|
|
|
|
|
} elsif ($state eq "ok") { |
139
|
0
|
|
|
|
|
|
return "green"; |
140
|
|
|
|
|
|
|
} elsif ($state eq "used") { |
141
|
0
|
|
|
|
|
|
return "yellow"; |
142
|
|
|
|
|
|
|
} elsif ($state eq "busy") { |
143
|
0
|
|
|
|
|
|
return "pink"; |
144
|
|
|
|
|
|
|
} elsif ($state eq "unused") { |
145
|
0
|
|
|
|
|
|
return "white"; |
146
|
|
|
|
|
|
|
} elsif ($state eq "unknown") { |
147
|
0
|
|
|
|
|
|
return "lightgrey"; |
148
|
|
|
|
|
|
|
} elsif ($state eq "special") { |
149
|
0
|
|
|
|
|
|
return "mediumorchid1"; |
150
|
|
|
|
|
|
|
} elsif ($state eq "warning") { |
151
|
0
|
|
|
|
|
|
return "orange"; |
152
|
|
|
|
|
|
|
} elsif ($state eq "error") { |
153
|
0
|
|
|
|
|
|
return "red"; |
154
|
|
|
|
|
|
|
} else { |
155
|
0
|
|
|
|
|
|
return "red"; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub dname { |
160
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
161
|
0
|
|
|
|
|
|
return $self->name; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
has 'linkkind' => ( |
165
|
|
|
|
|
|
|
is => 'ro', |
166
|
|
|
|
|
|
|
isa => 'Str', |
167
|
|
|
|
|
|
|
required => 1, |
168
|
|
|
|
|
|
|
lazy => 1, |
169
|
|
|
|
|
|
|
default => sub { |
170
|
|
|
|
|
|
|
my $self = shift; |
171
|
|
|
|
|
|
|
my $kind = ref($self); |
172
|
|
|
|
|
|
|
$kind =~ s/^StorageDisplay::Data:://; |
173
|
|
|
|
|
|
|
if ($self->has_parent) { |
174
|
|
|
|
|
|
|
my $pkind = ref($self->parent); |
175
|
|
|
|
|
|
|
$pkind =~ s/^StorageDisplay::Data:://; |
176
|
|
|
|
|
|
|
$kind =~ s/^$pkind//; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
return $kind; |
179
|
|
|
|
|
|
|
}, |
180
|
|
|
|
|
|
|
); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub rawlinkname { |
183
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
184
|
0
|
|
|
|
|
|
return $self->fullname; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub linkname { |
188
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
189
|
0
|
|
|
|
|
|
return '"'.$self->rawlinkname.'"'; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub newElem { |
193
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
194
|
0
|
|
|
|
|
|
my $baseclass = shift; |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
my $class = 'StorageDisplay::Data::'.$baseclass; |
197
|
0
|
|
|
|
|
|
return $class->new(@_); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub newChild { |
201
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
202
|
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
|
my $child = $self->newElem(@_); |
204
|
0
|
|
|
|
|
|
$self->addChild($child); |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
|
return $child; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub pushDotText { |
210
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
211
|
0
|
|
|
|
|
|
my $text = shift; |
212
|
0
|
|
0
|
|
|
|
my $t = shift // "\t"; |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
my @pushed = map { $t.$_ } @_; |
|
0
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
push @{$text}, @pushed; |
|
0
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub dotSubNodes { |
219
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
220
|
0
|
|
0
|
|
|
|
my $t = shift // "\t"; |
221
|
0
|
|
|
|
|
|
my @text=(); |
222
|
0
|
|
|
|
|
|
my $it = $self->iterator(recurse => 0); |
223
|
0
|
|
|
|
|
|
while (defined(my $e=$it->next)) { |
224
|
0
|
|
|
|
|
|
push @text, $e->dotNode($t); |
225
|
|
|
|
|
|
|
} |
226
|
0
|
|
|
|
|
|
return @text; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub dotLinks { |
230
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
231
|
0
|
|
|
|
|
|
return (); |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
1; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
__END__ |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=pod |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=encoding UTF-8 |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 NAME |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
StorageDisplay::Data::Elem - Handle something that will be displayed and can be linked |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 VERSION |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
version 2.04 |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 AUTHOR |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Vincent Danjean <Vincent.Danjean@ens-lyon.org> |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
This software is copyright (c) 2014-2023 by Vincent Danjean. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
259
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=cut |