lib/App/SeismicUnixGui/specs/model/sufdmod1_spec.pm untested

filter: Statementstmt 0.0% 0 / 141 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 / 185 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::model::sufdmod1_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  
9  
10 my $get = L_SU_global_constants->new();
11 my $Project = Project_config->new();
12  
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(); # input data directory
23 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); # output data directory
24 my $PL_SEISMIC = $Project->PL_SEISMIC();
25 my $max_index = 17; #$sufdmod1->get_max_index() mystery error
26  
27 my $sufdmod1_spec = {
28 _CONFIG => $PL_SEISMIC,
29 _DATA_DIR_IN => $DATA_SEISMIC_BIN,
30 _DATA_DIR_OUT => $DATA_SEISMIC_SU,
31 _binding_index_aref => '',
32 _suffix_type_in => $su, # TODO should be bin ???
33 _data_suffix_in => $suffix_bin,
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 dfile, sfile,vfile (item indices =1,9,14)
63 is bound to binary directory DATA_SEISMIC_BIN
64  
65 =cut
66  
67 sub binding_index_aref {
68  
69 my ($self) = @_;
70  
71 my @index;
72  
73 $index[0] = 1;
74 $index[1] = 9;
75 $index[2] = 14;
76  
77 $sufdmod1_spec->{_binding_index_aref} = \@index;
78 return ();
79  
80 }
81  
82 =head2 sub flow_type_aref
83  
84 =cut
85  
86 sub flow_type_aref {
87  
88 my ($self) = @_;
89  
90 my @type;
91  
92 $type[0] = $flow_type->{_user_built};
93  
94 $sufdmod1_spec->{_flow_type_aref} = \@type;
95 return ();
96  
97 }
98  
99 =head2 sub get_binding_index_aref
100  
101 =cut
102  
103 sub get_binding_index_aref {
104  
105 my ($self) = @_;
106 my @index;
107  
108 if ( $sufdmod1_spec->{_binding_index_aref} ) {
109  
110 my $index_aref = $sufdmod1_spec->{_binding_index_aref};
111 return ($index_aref);
112  
113 }
114 else {
115 print(
116 "sufdmod1_spec, get_binding_index_aref, missing binding_index_aref\n"
117 );
118 return ();
119 }
120  
121 my $index_aref = $sufdmod1_spec->{_binding_index_aref};
122 }
123  
124 =head2 sub file_dialog_type_aref
125  
126 type of dialog (Data, Flow, SaveAs) is needed by binding
127 one type of dialog for each index
128  
129 =cut
130  
131 sub file_dialog_type_aref {
132  
133 my ($self) = @_;
134  
135 my @type;
136
137 my $index_aref = get_binding_index_aref();
138 my @index = @$index_aref;
139  
140 $type[$index[0]] = $file_dialog_type->{_Data};
141 $type[$index[1]] = $file_dialog_type->{_Data};
142 $type[$index[2]] = $file_dialog_type->{_Data};
143  
144 $sufdmod1_spec->{_file_dialog_type_aref} = \@type;
145 return ();
146  
147 }
148  
149 =head2 sub get_binding_length
150  
151 =cut
152  
153 sub get_binding_length {
154  
155 my ($self) = @_;
156  
157 if ( $sufdmod1_spec->{_binding_index_aref} ) {
158  
159 my $binding_length = scalar @{ $sufdmod1_spec->{_binding_index_aref} };
160  
161 # print("sufdmod1_spec, get_binding_length: $binding_length\n");
162 return ($binding_length);
163  
164 }
165 else {
166 print("sufdmod1_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 ( $sufdmod1_spec->{_file_dialog_type_aref} ) {
181  
182 my $index_aref = $sufdmod1_spec->{_file_dialog_type_aref};
183 return ($index_aref);
184  
185 }
186 else {
187 print(
188 "sufdmod1_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 ( $sufdmod1_spec->{_flow_type_aref} ) {
205  
206 my $index_aref = $sufdmod1_spec->{_flow_type_aref};
207 return ($index_aref);
208  
209 }
210 else {
211 print("sufdmod1_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 "sufdmod1, 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 ( $sufdmod1_spec->{_prefix_aref} ) {
276  
277 my $prefix_aref = $sufdmod1_spec->{_prefix_aref};
278 return ($prefix_aref);
279  
280 }
281 else {
282 print("sufdmod1_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 ( $sufdmod1_spec->{_suffix_aref} ) {
298  
299 my $suffix_aref = $sufdmod1_spec->{_suffix_aref};
300 return ($suffix_aref);
301  
302 }
303 else {
304 print("$sufdmod1_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 on writing out.
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 $prefix[ $index[0] ] = '$DATA_SEISMIC_BIN' . ".'/'.";
336 $prefix[ $index[1] ] = '$DATA_SEISMIC_SU' . ".'/'.";
337 $prefix[ $index[2] ] = '$DATA_SEISMIC_BIN' . ".'/'.";
338  
339 $sufdmod1_spec->{_prefix_aref} = \@prefix;
340 return ();
341  
342 }
343  
344 =head2 sub suffix_aref
345  
346 Initialize suffixes as empty
347 Assign specific suffixes to parameter
348 values
349  
350 set data type in to binary
351 set data type out to su
352 for writing out to perl script
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 $suffix[ $index[0] ] = ''.'' . '$suffix_bin';
371 $suffix[ $index[1] ] = ''.''. '$suffix_su';
372 $suffix[ $index[2] ] = ''.''. '$suffix_bin';
373  
374 $sufdmod1_spec->{_suffix_aref} = \@suffix;
375 return ();
376  
377 }
378  
379 =head2 sub variables
380  
381 return a hash array
382 with definitions
383
384 =cut
385  
386 sub variables {
387 my $self = @_;
388 my $hash_ref = $sufdmod1_spec;
389 return ($hash_ref);
390 }
391  
392 1;