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

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