line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gnuplot::Builder::Dataset; |
2
|
27
|
|
|
27
|
|
442085
|
use strict; |
|
27
|
|
|
|
|
62
|
|
|
27
|
|
|
|
|
742
|
|
3
|
27
|
|
|
27
|
|
146
|
use warnings; |
|
27
|
|
|
|
|
50
|
|
|
27
|
|
|
|
|
721
|
|
4
|
27
|
|
|
27
|
|
11505
|
use Gnuplot::Builder::PrototypedData; |
|
27
|
|
|
|
|
62
|
|
|
27
|
|
|
|
|
833
|
|
5
|
27
|
|
|
27
|
|
162
|
use Scalar::Util qw(weaken blessed); |
|
27
|
|
|
|
|
50
|
|
|
27
|
|
|
|
|
1692
|
|
6
|
27
|
|
|
27
|
|
142
|
use Carp; |
|
27
|
|
|
|
|
51
|
|
|
27
|
|
|
|
|
1527
|
|
7
|
27
|
|
|
27
|
|
30922
|
use overload '""' => 'to_string'; |
|
27
|
|
|
|
|
21710
|
|
|
27
|
|
|
|
|
165
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
124
|
|
|
124
|
1
|
41213
|
my ($class, $source, @set_option_args) = @_; |
11
|
124
|
|
|
|
|
521
|
my $self = bless { |
12
|
|
|
|
|
|
|
pdata => undef, |
13
|
|
|
|
|
|
|
pdata_join => undef, ## deprecated. should be removed in the future. |
14
|
|
|
|
|
|
|
parent => undef, |
15
|
|
|
|
|
|
|
}, $class; |
16
|
124
|
|
|
|
|
367
|
$self->_init_pdata(); |
17
|
124
|
100
|
|
|
|
330
|
if(defined $source) { |
18
|
33
|
|
|
|
|
102
|
$self->set_source($source); |
19
|
|
|
|
|
|
|
} |
20
|
124
|
100
|
|
|
|
348
|
if(@set_option_args) { |
21
|
7
|
|
|
|
|
32
|
$self->set_option(@set_option_args); |
22
|
|
|
|
|
|
|
} |
23
|
124
|
|
|
|
|
373
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new_file { |
27
|
18
|
|
|
18
|
1
|
6535
|
my ($class, $filename, @set_option_args) = @_; |
28
|
18
|
|
|
|
|
73
|
return $class->new->set_file($filename)->set_option(@set_option_args); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new_data { |
32
|
10
|
|
|
10
|
1
|
2078
|
my ($class, $data_provider, @set_option_args) = @_; |
33
|
10
|
|
|
|
|
29
|
return $class->new->set_file('-')->set_data($data_provider)->set_option(@set_option_args); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _init_pdata { |
37
|
124
|
|
|
124
|
|
206
|
my ($self) = @_; |
38
|
124
|
|
|
|
|
368
|
weaken $self; |
39
|
|
|
|
|
|
|
$self->{pdata} = Gnuplot::Builder::PrototypedData->new( |
40
|
|
|
|
|
|
|
entry_evaluator => sub { |
41
|
49
|
|
|
49
|
|
87
|
my ($key, $coderef) = @_; |
42
|
49
|
|
|
|
|
124
|
return $coderef->($self, $key); |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
attribute_evaluator => { source => sub { |
45
|
11
|
|
|
11
|
|
20
|
my ($key, $coderef) = @_; |
46
|
11
|
|
|
|
|
27
|
return $coderef->($self); |
47
|
|
|
|
|
|
|
} }, |
48
|
124
|
|
|
|
|
1138
|
); |
49
|
124
|
|
|
|
|
417
|
$self->{pdata_join} = Gnuplot::Builder::PrototypedData->new(); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub to_string { |
53
|
119
|
|
|
119
|
1
|
4324
|
my ($self) = @_; |
54
|
119
|
|
|
|
|
234
|
my @words = (); |
55
|
119
|
|
|
|
|
311
|
push @words, $self->get_source; |
56
|
|
|
|
|
|
|
$self->{pdata}->each_resolved_entry(sub { |
57
|
198
|
|
|
198
|
|
1763
|
my ($name, $values_arrayref) = @_; |
58
|
198
|
|
|
|
|
401
|
my @values = grep { defined($_) } @$values_arrayref; |
|
259
|
|
|
|
|
697
|
|
59
|
198
|
100
|
|
|
|
573
|
return if !@values; |
60
|
170
|
|
|
|
|
562
|
my $join = $self->{pdata_join}->get_resolved_attribute($name); |
61
|
170
|
100
|
|
|
|
441
|
if(defined $join) { |
62
|
22
|
|
|
|
|
152
|
push @words, $name, join($join, @values); |
63
|
|
|
|
|
|
|
}else { |
64
|
148
|
|
|
|
|
1040
|
push @words, $name, @values; |
65
|
|
|
|
|
|
|
} |
66
|
119
|
|
|
|
|
803
|
}); |
67
|
119
|
100
|
|
|
|
879
|
return join " ", grep { defined($_) && "$_" ne "" } @words; |
|
492
|
|
|
|
|
2617
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
*params_string = *to_string; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub set_source { |
73
|
42
|
|
|
42
|
1
|
107
|
my ($self, $source) = @_; |
74
|
|
|
|
|
|
|
$self->{pdata}->set_attribute( |
75
|
42
|
|
|
|
|
158
|
key => "source", value => $source |
76
|
|
|
|
|
|
|
); |
77
|
42
|
|
|
|
|
89
|
return $self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub setq_source { |
81
|
36
|
|
|
36
|
1
|
93
|
my ($self, $source) = @_; |
82
|
|
|
|
|
|
|
$self->{pdata}->set_attribute( |
83
|
36
|
|
|
|
|
152
|
key => "source", value => $source, quote => 1, |
84
|
|
|
|
|
|
|
); |
85
|
36
|
|
|
|
|
119
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
*set_file = *setq_source; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub get_source { |
91
|
138
|
|
|
138
|
1
|
923
|
my ($self) = @_; |
92
|
138
|
|
|
|
|
532
|
return $self->{pdata}->get_resolved_attribute("source"); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub delete_source { |
96
|
5
|
|
|
5
|
1
|
12
|
my ($self) = @_; |
97
|
5
|
|
|
|
|
17
|
$self->{pdata}->delete_attribute("source"); |
98
|
5
|
|
|
|
|
20
|
return $self; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub set_option { |
102
|
93
|
|
|
93
|
1
|
347
|
my ($self, @options) = @_; |
103
|
|
|
|
|
|
|
$self->{pdata}->set_entry( |
104
|
93
|
|
|
|
|
405
|
entries => \@options, |
105
|
|
|
|
|
|
|
quote => 0, |
106
|
|
|
|
|
|
|
); |
107
|
93
|
|
|
|
|
618
|
return $self; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
*set = *set_option; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub setq_option { |
113
|
25
|
|
|
25
|
1
|
152
|
my ($self, @options) = @_; |
114
|
|
|
|
|
|
|
$self->{pdata}->set_entry( |
115
|
25
|
|
|
|
|
101
|
entries => \@options, |
116
|
|
|
|
|
|
|
quote => 1, |
117
|
|
|
|
|
|
|
); |
118
|
25
|
|
|
|
|
192
|
return $self; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
*setq = *setq_option; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub unset { |
124
|
2
|
|
|
2
|
1
|
10
|
my ($self, @opt_names) = @_; |
125
|
2
|
|
|
|
|
5
|
return $self->set_option(map {$_ => undef} @opt_names); |
|
3
|
|
|
|
|
9
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub get_option { |
129
|
92
|
|
|
92
|
1
|
5806
|
my ($self, $name) = @_; |
130
|
92
|
|
|
|
|
344
|
return $self->{pdata}->get_resolved_entry($name); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub delete_option { |
134
|
2
|
|
|
2
|
1
|
18
|
my ($self, @names) = @_; |
135
|
2
|
|
|
|
|
16
|
foreach my $name (@names) { |
136
|
2
|
|
|
|
|
27
|
$self->{pdata}->delete_entry($name); |
137
|
|
|
|
|
|
|
} |
138
|
2
|
|
|
|
|
36
|
return $self; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub set_parent { |
142
|
13
|
|
|
13
|
1
|
1825
|
my ($self, $parent) = @_; |
143
|
13
|
50
|
|
|
|
49
|
if(!defined($parent)) { |
144
|
0
|
|
|
|
|
0
|
$self->{parent} = undef; |
145
|
0
|
|
|
|
|
0
|
$self->{pdata}->set_parent(undef); |
146
|
0
|
|
|
|
|
0
|
$self->{pdata_join}->set_parent(undef); |
147
|
0
|
|
|
|
|
0
|
return $self; |
148
|
|
|
|
|
|
|
} |
149
|
13
|
50
|
33
|
|
|
172
|
if(!blessed($parent) || !$parent->isa("Gnuplot::Builder::Dataset")) { |
150
|
0
|
|
|
|
|
0
|
croak "parent must be a Gnuplot::Builder::Dataset"; |
151
|
|
|
|
|
|
|
} |
152
|
13
|
|
|
|
|
31
|
$self->{parent} = $parent; |
153
|
13
|
|
|
|
|
63
|
$self->{pdata}->set_parent($parent->{pdata}); |
154
|
13
|
|
|
|
|
46
|
$self->{pdata_join}->set_parent($parent->{pdata_join}); |
155
|
13
|
|
|
|
|
34
|
return $self; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
5
|
|
|
5
|
1
|
37
|
sub get_parent { return $_[0]->{parent} } |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
*parent = *get_parent; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub new_child { |
163
|
11
|
|
|
11
|
1
|
44
|
my ($self) = @_; |
164
|
11
|
|
|
|
|
36
|
return Gnuplot::Builder::Dataset->new->set_parent($self); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub set_data { |
168
|
24
|
|
|
24
|
1
|
3139
|
my ($self, $data_provider) = @_; |
169
|
|
|
|
|
|
|
$self->{pdata}->set_attribute( |
170
|
24
|
|
|
|
|
96
|
key => "data", value => $data_provider |
171
|
|
|
|
|
|
|
); |
172
|
24
|
|
|
|
|
84
|
return $self; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub write_data_to { |
176
|
41
|
|
|
41
|
1
|
1880
|
my ($self, $writer) = @_; |
177
|
41
|
|
|
|
|
141
|
my $data_provider = $self->{pdata}->get_resolved_attribute("data"); |
178
|
41
|
100
|
|
|
|
127
|
return $self if not defined $data_provider; |
179
|
24
|
100
|
|
|
|
76
|
if(ref($data_provider) eq "CODE") { |
180
|
10
|
|
|
|
|
32
|
$data_provider->($self, $writer); |
181
|
|
|
|
|
|
|
}else { |
182
|
14
|
|
|
|
|
43
|
$writer->($data_provider); |
183
|
|
|
|
|
|
|
} |
184
|
24
|
|
|
|
|
1143
|
return $self; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub delete_data { |
188
|
6
|
|
|
6
|
1
|
5523
|
my ($self) = @_; |
189
|
6
|
|
|
|
|
23
|
$self->{pdata}->delete_attribute("data"); |
190
|
6
|
|
|
|
|
29
|
return $self; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub _deprecated { |
194
|
26
|
|
|
26
|
|
38
|
my ($msg) = @_; |
195
|
26
|
|
|
|
|
165
|
my $method = (caller(1))[3]; |
196
|
26
|
|
|
|
|
2859
|
carp "$method is deprecated. $msg"; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub set_join { |
200
|
24
|
|
|
24
|
0
|
128
|
my ($self, %joins) = @_; |
201
|
24
|
|
|
|
|
45
|
_deprecated("Use Gnuplot::Builder::JoinDict."); |
202
|
24
|
|
|
|
|
1215
|
foreach my $name (keys %joins) { |
203
|
|
|
|
|
|
|
$self->{pdata_join}->set_attribute( |
204
|
28
|
|
|
|
|
110
|
key => $name, value => $joins{$name}, quote => 0 |
205
|
|
|
|
|
|
|
); |
206
|
|
|
|
|
|
|
} |
207
|
24
|
|
|
|
|
101
|
return $self; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub delete_join { |
211
|
2
|
|
|
2
|
0
|
5
|
my ($self, @names) = @_; |
212
|
2
|
|
|
|
|
5
|
_deprecated("Use Gnuplot::Builder::JoinDict."); |
213
|
2
|
|
|
|
|
87
|
foreach my $name (@names) { |
214
|
2
|
|
|
|
|
10
|
$self->{pdata_join}->delete_attribute($name); |
215
|
|
|
|
|
|
|
} |
216
|
2
|
|
|
|
|
10
|
return $self; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub Lens { |
220
|
0
|
|
|
0
|
0
|
|
my ($self, $key) = @_; |
221
|
0
|
|
|
|
|
|
require Gnuplot::Builder::Lens; |
222
|
0
|
|
|
|
|
|
return Gnuplot::Builder::Lens->new( |
223
|
|
|
|
|
|
|
"get_option", "set_option", $key |
224
|
|
|
|
|
|
|
); |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
1; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
__END__ |