lib/App/SeismicUnixGui/specs/shapeNcut/suflip_spec.pm untested

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