lib/App/SeismicUnixGui/specs/data/suunpack2_spec.pm untested

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