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

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