lib/App/SeismicUnixGui/specs/header/sustrip_spec.pm untested

filter: Statementstmt 0.0% 0 / 153 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 19 Podpod 0.0% 0 / 14 totaltotal 0.0% 0 / 202 CC 9 SCAR 14.7
CC
9
Cov
0%
get_binding_index_aref
6.0
get_binding_length
6.0
get_file_dialog_type_aref
6.0
CRAP 4.4
1 package App::SeismicUnixGui::specs::header::sustrip_spec;
2 use Moose;
3 our $VERSION = '0.0.1';
4  
5 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
6 use App::SeismicUnixGui::misc::SeismicUnix qw($bin $suffix_txt $suffix_bin $su $suffix_su $txt);
7 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
8 use aliased 'App::SeismicUnixGui::sunix::header::sustrip';
9  
10 my $get = L_SU_global_constants->new();
11 my $Project = Project_config->new();
12 my $sustrip = sustrip->new();
13  
14 my $var = $get->var();
15  
16 my $empty_string = $var->{_empty_string};
17 my $true = $var->{_true};
18 my $false = $var->{_false};
19 my $file_dialog_type = $get->file_dialog_type_href();
20 my $flow_type = $get->flow_type_href();
21  
22 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); # input data directory
23 my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN(); # output data directory
24 my $PL_SEISMIC = $Project->PL_SEISMIC();
25 my $max_index = $sustrip->get_max_index();
26  
27 my $sustrip_spec = {
28 _CONFIG => $PL_SEISMIC,
29 _DATA_DIR_IN => $DATA_SEISMIC_SU,
30 _DATA_DIR_OUT => $DATA_SEISMIC_BIN,
31 _binding_index_aref => '',
32 _suffix_type_in => $su,
33 _data_suffix_in => $suffix_su,
34 _suffix_type_out => $bin,
35 _data_suffix_out => $suffix_bin,
36 _file_dialog_type_aref => '',
37 _flow_type_aref => '',
38 _has_infile => $true,
39 _has_outpar => $false,
40 _has_pipe_in => $true,
41 _has_pipe_out => $false,
42 _has_redirect_in => $true,
43 _has_redirect_out => $true,
44 _has_subin_in => $false,
45 _has_subin_out => $true,
46 _is_data => $false,
47 _is_first_of_2 => $true,
48 _is_first_of_3or_more => $true,
49 _is_first_of_4or_more => $true,
50 _is_last_of_2 => $false,
51 _is_last_of_3or_more => $false,
52 _is_last_of_4or_more => $false,
53 _is_suprog => $true,
54 _is_superflow => $false,
55 _max_index => $max_index,
56 };
57  
58 my $incompatibles = { clip => [ 'mbal', 'pbal' ], };
59  
60 =head2 sub _sub_binding_index_aref
61  
62 =cut
63  
64 sub binding_index_aref {
65  
66 my ($self) = @_;
67  
68 my @index;
69  
70 $index[0] = 0;
71  
72 # first binding index (index=0)
73 # connects to second item (index=1)
74 # in the parameter list
75 $index[0] = 0; # outbound item is bound
76 $index[1] = 1; # outbound item is bound
77  
78 $sustrip_spec->{_binding_index_aref} = \@index;
79 return ();
80  
81 }
82  
83 =head2 sub file_dialog_type_aref
84  
85 type of dialog (Data, Flow, SaveAs) is needed by binding
86 one type of dialog for each index
87 =cut
88  
89 sub file_dialog_type_aref {
90 my ($self) = @_;
91  
92 my @type;
93  
94 my $index_aref = get_binding_index_aref();
95 my @index = @$index_aref;
96  
97 # bound index will look for data
98  
99 $type[ $index[0] ] = $file_dialog_type->{_Data};
100 $type[ $index[1] ] = $file_dialog_type->{_Data};
101  
102 $sustrip_spec->{_file_dialog_type_aref} = \@type;
103  
104 return ();
105  
106 }
107  
108 =head2 sub flow_type_aref
109  
110 =cut
111  
112 sub flow_type_aref {
113  
114 my ($self) = @_;
115  
116 my @type;
117
118 my $index_aref = get_binding_index_aref();
119 my @index = @$index_aref;
120  
121 # bound index will look for data
122  
123 $type[ $index[0] ] = $file_dialog_type->{_Data};
124 $type[ $index[1] ] = $file_dialog_type->{_Data};
125
126 $sustrip_spec->{_flow_type_aref} = \@type;
127  
128 return ();
129  
130 }
131  
132 =head2 sub get_binding_index_aref
133  
134 =cut
135  
136 sub get_binding_index_aref {
137  
138 my ($self) = @_;
139 my @index;
140  
141 if ( $sustrip_spec->{_binding_index_aref} ) {
142  
143 my $index_aref = $sustrip_spec->{_binding_index_aref};
144 return ($index_aref);
145  
146 }
147 else {
148 print(
149 "sustrip_spec, get_binding_index_aref, missing binding_index_aref\n"
150 );
151 return ();
152 }
153  
154 my $index_aref = $sustrip_spec->{_binding_index_aref};
155  
156 }
157  
158 =head2 sub get_binding_length
159  
160 =cut
161  
162 sub get_binding_length {
163 my ($self) = @_;
164  
165 if ( $sustrip_spec->{_binding_index_aref} ) {
166  
167 my $length;
168  
169 $length = scalar @{ $sustrip_spec->{_binding_index_aref} };
170  
171 return ($length);
172  
173 }
174 else {
175 print("sustrip_spec, get_binding_length, missing length \n");
176 return ();
177 }
178  
179 }
180  
181 =head2 sub get_file_dialog_type_aref
182  
183 =cut
184  
185 sub get_file_dialog_type_aref {
186  
187 my ($self) = @_;
188 if ( $sustrip_spec->{_file_dialog_type_aref} ) {
189  
190 my @type = @{ $sustrip_spec->{_file_dialog_type_aref} };
191  
192 return ( \@type );
193  
194 }
195 else {
196 print(
197 "sustrip_spec,get_file_dialog_type_aref, missing file_dialog_type_aref\n"
198 );
199 return ();
200 }
201  
202 }
203  
204 =head2 sub get_flow_type_aref
205  
206 =cut
207  
208 sub get_flow_type_aref {
209 my ($self) = @_;
210 if ( $sustrip_spec->{_flow_type_aref} ) {
211  
212 my $type_aref = $sustrip_spec->{_flow_type_aref};
213  
214 return ($type_aref);
215  
216 }
217 else {
218 print("sustrip_spec, get_flow_type_aref, missing flow_type_aref \n");
219 return ();
220 }
221 }
222  
223 =head2 sub get_max_index
224  
225 =cut
226  
227 sub get_max_index {
228  
229 my ($self) = @_;
230  
231 if ( $sustrip_spec->{_max_index} ) {
232  
233 my $max_idx = $sustrip->get_max_index();
234 return ($max_idx);
235  
236 }
237 else {
238 print("sustrip_spec, get_max_index, missing max_index\n");
239 return ();
240 }
241 }
242  
243 =head2 sub get_incompatibles
244  
245 =cut
246  
247 sub get_incompatibles {
248  
249 my ($self) = @_;
250 my @needed;
251  
252 my @_need_both;
253  
254 my @_need_only_1;
255  
256 my @_none_needed;
257  
258 my @_all_needed;
259  
260 my $params = {
261  
262 _need_both => \@_need_both,
263 _need_only_1 => \@_need_only_1,
264 _none_needed => \@_none_needed,
265 _all_needed => \@_all_needed,
266  
267 };
268  
269 my @of_two = ( 'xx', 'yy' );
270 push @{ $params->{_need_only_1} }, \@of_two;
271  
272 my $len_1_needed = scalar @{ $params->{_need_only_1} };
273  
274 if ( $len_1_needed >= 1 ) {
275  
276 for ( my $i = 0 ; $i < $len_1_needed ; $i++ ) {
277  
278 print(
279 "sustrip, get_incompatibles,need_only_1: @{@{$params->{_need_only_1}}[$i]}\n"
280 );
281  
282 }
283  
284 }
285 else {
286 print("get_incompatibles, no incompatibles\n");
287 }
288  
289 return ($params);
290  
291 }
292  
293 =head2 sub get_prefix_aref
294  
295 =cut
296  
297 sub get_prefix_aref {
298  
299 my ($self) = @_;
300  
301 if ( $sustrip_spec->{_prefix_aref} ) {
302  
303 my $prefix_aref = $sustrip_spec->{_prefix_aref};
304 return ($prefix_aref);
305  
306 }
307 else {
308 print("sustrip_spec, get_prefix_aref, missing prefix_aref\n");
309 return ();
310 }
311  
312 return ();
313 }
314  
315 =head2 sub get_suffix_aref
316  
317 =cut
318  
319 sub get_suffix_aref {
320  
321 my ($self) = @_;
322  
323 if ( $sustrip_spec->{_suffix_aref} ) {
324  
325 my $suffix_aref = $sustrip_spec->{_suffix_aref};
326 return ($suffix_aref);
327  
328 }
329 else {
330 print("sustrip_spec, get_suffix_aref, missing suffix_aref\n");
331 return ();
332 }
333  
334 return ();
335 }
336  
337 =head2 sub prefix_aref
338  
339 Include in the Set up
340 sections of an output Poop flow.
341  
342 prefixes and suffixes to parameter labels
343 are filtered by sunix_pl
344  
345 =cut
346  
347 sub prefix_aref {
348  
349 my ($self) = @_;
350  
351 my @prefix;
352  
353 for ( my $i = 0 ; $i < $max_index ; $i++ ) {
354  
355 $prefix[$i] = $empty_string;
356  
357 }
358  
359 my $index_aref = get_binding_index_aref();
360 my @index = @$index_aref;
361  
362 # label 1 in GUI is output xx_file and needs a home directory
363 $prefix[ $index[0] ] = '$DATA_SEISMIC_BIN' . ".'/'.";
364  
365 # label 2 in GUI is output yy_file and needs a home directory
366 $prefix[ $index[1] ] = '$DATA_SEISMIC_TXT' . ".'/'.";
367  
368 $sustrip_spec->{_prefix_aref} = \@prefix;
369 return ();
370  
371 }
372  
373 =head2 sub suffix_aref
374  
375 Initialize suffixes as empty
376 Assign specific suffixes to parameter
377 values
378  
379 =cut
380  
381 sub suffix_aref {
382  
383 my ($self) = @_;
384  
385 my @suffix;
386  
387 for ( my $i = 0 ; $i < $max_index ; $i++ ) {
388  
389 $suffix[$i] = $empty_string;
390  
391 }
392  
393 my $index_aref = get_binding_index_aref();
394 my @index = @$index_aref;
395  
396 # label 1 in GUI is output xx_file and needs a home directory
397 $suffix[ $index[0] ] = '' . '' . '$suffix_bin';
398
399 # label 2 in GUI is output xx_file and needs a home directory
400 $suffix[ $index[1] ] = '' . '' . '$suffix_txt';
401  
402 $sustrip_spec->{_suffix_aref} = \@suffix;
403 return ();
404  
405 }
406  
407 =head2 sub variables
408 return a hash array
409 with definitions
410  
411 =cut
412  
413 sub variables {
414  
415 my ($self) = @_;
416  
417 my $hash_ref = $sustrip_spec;
418  
419 return ($hash_ref);
420  
421 }
422  
423 1;