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

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