« lib/App/SeismicUnixGui/misc/old_data.pm
↑ Summary
lib/App/SeismicUnixGui/developer/code/sunix/update.pm »
| 1 | package App::SeismicUnixGui::misc::oop_text; | ||
| 2 | |||
| 3 | =head2 for writing object-oriented perl lines of text | ||
| 4 | 2018 V 0.0.2 | ||
| 5 | |||
| 6 | V 0.0.3 July 24 2018 includes data_in and data_out | ||
| 7 | add \t to pod_prog_param | ||
| 8 | V0.04 April 4 2019 | ||
| 9 | does not repeat program declaration | ||
| 10 | |||
| 11 | =head1 DOCUMENTATION | ||
| 12 | |||
| 13 | |||
| 14 | =head2 SYNOPSIS | ||
| 15 | |||
| 16 | PERL PROGRAM NAME: oop_text | ||
| 17 | AUTHOR: Juan Lorenzo | ||
| 18 | DATE: V 0.0.1 June 22 2017 | ||
| 19 | |||
| 20 | DESCRIPTION | ||
| 21 | |||
| 22 | |||
| 23 | BASED ON: | ||
| 24 | |||
| 25 | |||
| 26 | =cut | ||
| 27 | |||
| 28 | =head2 USE | ||
| 29 | |||
| 30 | =head3 NOTES | ||
| 31 | |||
| 32 | =head4 Examples | ||
| 33 | |||
| 34 | =head3 SEISMIC UNIX NOTES | ||
| 35 | |||
| 36 | =head2 CHANGES and their DATES | ||
| 37 | |||
| 38 | =cut | ||
| 39 | |||
| 40 | use Moose; | ||
| 41 | our $VERSION = '0.0.4'; | ||
| 42 | use aliased 'App::SeismicUnixGui::misc::manage_files_by2'; | ||
| 43 | use aliased 'App::SeismicUnixGui::misc::dirs'; | ||
| 44 | use aliased 'App::SeismicUnixGui::misc::oop_declare_data_in'; | ||
| 45 | use aliased 'App::SeismicUnixGui::misc::oop_declare_data_out'; | ||
| 46 | use aliased 'App::SeismicUnixGui::misc::oop_declare_pkg'; | ||
| 47 | use aliased 'App::SeismicUnixGui::misc::oop_declaration_defaults'; | ||
| 48 | use aliased 'App::SeismicUnixGui::misc::oop_flows' | ||
| 49 | ; # corrects data-program order for seismic unix; | ||
| 50 | use aliased 'App::SeismicUnixGui::misc::oop_pod_header'; | ||
| 51 | use aliased 'App::SeismicUnixGui::misc::oop_instantiation_defaults'; | ||
| 52 | use aliased 'App::SeismicUnixGui::misc::oop_log_flows'; | ||
| 53 | use aliased 'App::SeismicUnixGui::misc::oop_use_pkg'; | ||
| 54 | use aliased 'App::SeismicUnixGui::misc::pod_declare'; | ||
| 55 | use aliased 'App::SeismicUnixGui::misc::pod_flows'; | ||
| 56 | use aliased 'App::SeismicUnixGui::misc::pod_log_flows'; | ||
| 57 | use aliased 'App::SeismicUnixGui::misc::pod_prog_param_setup'; | ||
| 58 | use aliased 'App::SeismicUnixGui::misc::pod_run_flows'; | ||
| 59 | use aliased 'App::SeismicUnixGui::misc::oop_print_flows'; | ||
| 60 | use aliased 'App::SeismicUnixGui::misc::oop_prog_params'; | ||
| 61 | use aliased 'App::SeismicUnixGui::misc::oop_run_flows'; | ||
| 62 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 63 | |||
| 64 | use Carp; | ||
| 65 | |||
| 66 | my $file_out; | ||
| 67 | my $file_in; | ||
| 68 | my $get = L_SU_global_constants->new(); | ||
| 69 | my $dirs = dirs->new(); | ||
| 70 | my $declare_data_in = oop_declare_data_in->new(); | ||
| 71 | my $declare_data_out = oop_declare_data_out->new(); | ||
| 72 | my $oop_flows = oop_flows->new(); | ||
| 73 | my $oop_declare_pkg = oop_declare_pkg->new(); | ||
| 74 | my $oop_pod_header = oop_pod_header->new(); | ||
| 75 | my $oop_declaration_defaults = oop_declaration_defaults->new(); | ||
| 76 | my $oop_instantiation_defaults = oop_instantiation_defaults->new(); | ||
| 77 | my $oop_run_flows = oop_run_flows->new(); | ||
| 78 | my $oop_log_flows = oop_log_flows->new(); | ||
| 79 | my $pod_declare = pod_declare->new(); | ||
| 80 | my $pod_flows = pod_flows->new(); | ||
| 81 | my $pod_log_flows = pod_log_flows->new(); | ||
| 82 | my $pod_run_flows = pod_run_flows->new(); | ||
| 83 | my $pod_prog_param_setup = pod_prog_param_setup->new(); | ||
| 84 | my $print_flows = oop_print_flows->new(); | ||
| 85 | my $prog_params = oop_prog_params->new(); | ||
| 86 | my $oop_use_pkg = oop_use_pkg->new(); | ||
| 87 | my @lines = (); | ||
| 88 | my $self; | ||
| 89 | |||
| 90 | my $var = $get->var(); | ||
| 91 | my $true = $var->{_true}; | ||
| 92 | my $false = $var->{_false}; | ||
| 93 | |||
| 94 | =head2 private hash | ||
| 95 | |||
| 96 | =cut | ||
| 97 | |||
| 98 | my $oop_text = { | ||
| 99 | _suffix_type => '', | ||
| 100 | _suffix_type_in => '', | ||
| 101 | _suffix_type_out => '', | ||
| 102 | _filehandle => '', | ||
| 103 | _file_name_in => '', | ||
| 104 | _is_config => $false, | ||
| 105 | _is_data => $false, | ||
| 106 | _is_data_in => $false, | ||
| 107 | _is_data_out => $false, | ||
| 108 | _message_w => '', | ||
| 109 | _num_progs4flow => '', | ||
| 110 | _prog_name => '', | ||
| 111 | _prog_names_aref => '', | ||
| 112 | _prog_param_labels_aref => '', | ||
| 113 | _prog_param_values_aref => '', | ||
| 114 | _prog_version => '', | ||
| 115 | _prog_version_aref => '', | ||
| 116 | }; | ||
| 117 | |||
| 118 | # normally filehandle is undefined | ||
| 119 | # unless overwritten with another filehandle | ||
| 120 | # before use | ||
| 121 | $oop_text->{_filehandle} = undef; # for future use perhaps | ||
| 122 | |||
| 123 | =head2 sub set_data_io_LSU | ||
| 124 | |||
| 125 | =cut | ||
| 126 | |||
| 127 | sub set_data_io_L_SU { | ||
| 128 | |||
| 129 | my ( $self, $hash_ref ) = @_; | ||
| 130 | use App::SeismicUnixGui::misc::SeismicUnix | ||
| 131 | qw($segb $segd $segy $sgd $sgy $su $txt $text $bin); | ||
| 132 | |||
| 133 | $oop_text->{_suffix_type_in} = $hash_ref->{_suffix_type_in}; | ||
| 134 | $oop_text->{_suffix_type_out} = $hash_ref->{_suffix_type_out}; | ||
| 135 | $oop_text->{_is_data_in} = $hash_ref->{_is_data_in}; | ||
| 136 | $oop_text->{_is_data_out} = $hash_ref->{_is_data_out}; | ||
| 137 | |||
| 138 | # foreach my $key (keys %$hash_ref) { | ||
| 139 | # print("oop_text,set_data_io_L_SU $key is $hash_ref->{$key}\n"); | ||
| 140 | # } | ||
| 141 | # print("oop_text,set_data_io_L_SU made it\n"); | ||
| 142 | |||
| 143 | my $suffix_type_in = $oop_text->{_suffix_type_in}; | ||
| 144 | my $suffix_type_out = $oop_text->{_suffix_type_out}; | ||
| 145 | my $is_data_out = $oop_text->{_is_data_out}; | ||
| 146 | my $is_data_in = $oop_text->{_is_data_in}; | ||
| 147 | |||
| 148 | if ($is_data_in) { | ||
| 149 | |||
| 150 | if ( $suffix_type_in eq $segb ) { | ||
| 151 | |||
| 152 | print( | ||
| 153 | "oop_text,set_data_io_L_SU, is data_in suffix_type eq $segb\n"); | ||
| 154 | $declare_data_in->set_suffix_type_in($segb); | ||
| 155 | $declare_data_in->set_segb_in(); | ||
| 156 | |||
| 157 | } | ||
| 158 | elsif ( $suffix_type_in eq $segd or $suffix_type_in eq $sgd ) { | ||
| 159 | |||
| 160 | print( | ||
| 161 | "oop_text,set_data_io_L_SU, is data_in suffix_type eq $segd\n"); | ||
| 162 | $declare_data_in->set_suffix_type_in($segd); | ||
| 163 | $declare_data_in->set_segd_in(); | ||
| 164 | |||
| 165 | } | ||
| 166 | elsif ( $suffix_type_in eq $segy or $suffix_type_in eq $sgy ) { | ||
| 167 | |||
| 168 | print("oop_text,set_data_io_L_SU, is data_in suffix_type eq $su\n"); | ||
| 169 | $declare_data_in->set_suffix_type_in($sgy); | ||
| 170 | $declare_data_in->set_segy_in(); | ||
| 171 | |||
| 172 | } | ||
| 173 | elsif ( $suffix_type_in eq $su ) { | ||
| 174 | |||
| 175 | # print("oop_text,set_data_io_L_SU, is data_in suffix_type eq $su\n"); | ||
| 176 | $declare_data_in->set_suffix_type_in($su); | ||
| 177 | $declare_data_in->set_su_in(); | ||
| 178 | |||
| 179 | } | ||
| 180 | elsif ( $suffix_type_in eq $bin ) { | ||
| 181 | |||
| 182 | # print("oop_text,set_data_io_L_SU_in type eq $suffix_bin\n"); | ||
| 183 | $declare_data_in->set_suffix_type_in($bin); | ||
| 184 | $declare_data_in->set_bin_in(); | ||
| 185 | |||
| 186 | } | ||
| 187 | elsif ( $suffix_type_in eq $txt || $suffix_type_in eq $text ) { | ||
| 188 | |||
| 189 | # print("oop_text,set_data_io_L_SU_in suffix_type eq $txt\n"); | ||
| 190 | $declare_data_in->set_suffix_type_in($txt); | ||
| 191 | $declare_data_in->set_text_in(); | ||
| 192 | |||
| 193 | } | ||
| 194 | else { | ||
| 195 | print("oope_text,set_data_io_L_SU, unexpected suffix type \n"); | ||
| 196 | } | ||
| 197 | |||
| 198 | } | ||
| 199 | elsif ($is_data_out) { | ||
| 200 | |||
| 201 | # print("oop_text,set_data_io_L_SU out\n"); | ||
| 202 | # print("oop_text,set_data_io_L_SU suffix_type_out=$suffix_type_out\n"); | ||
| 203 | # do not repeat delarations | ||
| 204 | if ( $suffix_type_in ne $suffix_type_out ) { | ||
| 205 | |||
| 206 | # print("oop_text,in and out data different suffix_types\n"); | ||
| 207 | |||
| 208 | if ( $suffix_type_out eq $segb ) { | ||
| 209 | |||
| 210 | # print("oop_text,set_data_io_L_SU,out suffix_type eq $segb\n"); | ||
| 211 | $declare_data_out->set_suffix_type_out($segb); | ||
| 212 | $declare_data_out->set_segb_out(); | ||
| 213 | } | ||
| 214 | |||
| 215 | if ( $suffix_type_out eq $segd ) { | ||
| 216 | |||
| 217 | # print("oop_text,set_data_io_L_SU,out suffix_type eq $segd\n"); | ||
| 218 | $declare_data_out->set_suffix_type_out($segd); | ||
| 219 | $declare_data_out->set_segd_out(); | ||
| 220 | } | ||
| 221 | |||
| 222 | if ( $suffix_type_out eq $su ) { | ||
| 223 | |||
| 224 | # print("oop_text,set_data_io_L_SU,out suffix_type eq $su\n"); | ||
| 225 | $declare_data_out->set_suffix_type_out($su); | ||
| 226 | $declare_data_out->set_su_out(); | ||
| 227 | |||
| 228 | } | ||
| 229 | elsif ( $suffix_type_out eq $bin ) { | ||
| 230 | |||
| 231 | # print("oop_text,set_data_io_L_SU out type eq $bin\n"); | ||
| 232 | $declare_data_out->set_suffix_type_out($bin); | ||
| 233 | $declare_data_out->set_bin_out(); | ||
| 234 | |||
| 235 | } | ||
| 236 | elsif ( $suffix_type_out eq $text || $suffix_type_out eq $txt ) { | ||
| 237 | |||
| 238 | # print("oop_text,set_data_io_L_SU out suffix_type eq 'txt'\n"); | ||
| 239 | $declare_data_out->set_suffix_type_out($txt); | ||
| 240 | $declare_data_out->set_text_out(); | ||
| 241 | |||
| 242 | } | ||
| 243 | elsif ( $suffix_type_out eq $sgy ) { | ||
| 244 | |||
| 245 | print("oop_text,set_data_io_L_SU out suffix_type eq $sgy\n"); | ||
| 246 | $declare_data_out->set_suffix_type_out($sgy); | ||
| 247 | $declare_data_out->set_segy_out(); | ||
| 248 | |||
| 249 | } | ||
| 250 | else { | ||
| 251 | print("oop_text,set_data_io_L_SU out suffix_type missing \n"); | ||
| 252 | } | ||
| 253 | |||
| 254 | # when input and output formats are the same | ||
| 255 | } | ||
| 256 | elsif ( $suffix_type_in eq $suffix_type_out ) { | ||
| 257 | |||
| 258 | if ( $suffix_type_out eq $segy ) { | ||
| 259 | |||
| 260 | $declare_data_out->empty(); | ||
| 261 | $declare_data_out->set_bin_out(); | ||
| 262 | |||
| 263 | } | ||
| 264 | elsif ( $suffix_type_out eq $segb ) { | ||
| 265 | |||
| 266 | $declare_data_out->empty(); | ||
| 267 | $declare_data_out->set_segb_out(); | ||
| 268 | |||
| 269 | # print("oop_text,in and out data same suffix_types\n"); | ||
| 270 | } | ||
| 271 | elsif ( $suffix_type_out eq $segd ) { | ||
| 272 | |||
| 273 | $declare_data_out->empty(); | ||
| 274 | $declare_data_out->set_segd_out(); | ||
| 275 | |||
| 276 | # print("oop_text,in and out data same suffix_types\n"); | ||
| 277 | } | ||
| 278 | elsif ( $suffix_type_out eq $su ) { | ||
| 279 | |||
| 280 | $declare_data_out->empty(); | ||
| 281 | $declare_data_out->set_su_out(); | ||
| 282 | |||
| 283 | } | ||
| 284 | elsif ( $suffix_type_out eq $bin ) { | ||
| 285 | |||
| 286 | $declare_data_out->empty(); | ||
| 287 | $declare_data_out->set_bin_out(); | ||
| 288 | |||
| 289 | } | ||
| 290 | elsif ($suffix_type_out eq $text | ||
| 291 | || $suffix_type_out eq $txt ) | ||
| 292 | { | ||
| 293 | |||
| 294 | $declare_data_out->empty(); | ||
| 295 | $declare_data_out->set_text_out(); | ||
| 296 | |||
| 297 | } | ||
| 298 | else { | ||
| 299 | print( | ||
| 300 | "oop_text,in and out data same suffix_types, missing suffix_type_out\n" | ||
| 301 | ); | ||
| 302 | |||
| 303 | } | ||
| 304 | |||
| 305 | } | ||
| 306 | else { | ||
| 307 | print( | ||
| 308 | "oop_text,in and out data suffix_types are neight the same or different\n" | ||
| 309 | ); | ||
| 310 | } | ||
| 311 | } | ||
| 312 | else { | ||
| 313 | # print("oop_text,neither data_in nor data_out\n"); | ||
| 314 | } | ||
| 315 | |||
| 316 | return (); | ||
| 317 | } | ||
| 318 | |||
| 319 | sub set_file_name_in { | ||
| 320 | my ( $self, $file_name ) = @_; | ||
| 321 | if ($file_name) { | ||
| 322 | |||
| 323 | # print("oop_text,set_file_name_in = $file_name\n"); | ||
| 324 | $oop_text->{_file_name_in} = $file_name; | ||
| 325 | } | ||
| 326 | |||
| 327 | return (); | ||
| 328 | } | ||
| 329 | |||
| 330 | sub set_file_name_out { | ||
| 331 | my ( $self, $file_name ) = @_; | ||
| 332 | if ($file_name) { | ||
| 333 | |||
| 334 | # print("oop_text,set_file_name_out = $file_name\n"); | ||
| 335 | $oop_text->{_file_name_out} = $file_name; | ||
| 336 | } | ||
| 337 | |||
| 338 | return (); | ||
| 339 | } | ||
| 340 | |||
| 341 | =pod sub declare_data_in | ||
| 342 | |||
| 343 | write declare_data_in | ||
| 344 | data can be indifferent formats, | ||
| 345 | e.g. su, text, binary etc. | ||
| 346 | |||
| 347 | data can be for input or output | ||
| 348 | |||
| 349 | =cut | ||
| 350 | |||
| 351 | sub declare_data_in { | ||
| 352 | my ($self) = @_; | ||
| 353 | |||
| 354 | #print("oop_text,declare_data_in\n"); | ||
| 355 | |||
| 356 | my $ref_array = $declare_data_in->inbound_section(); | ||
| 357 | my @array = @$ref_array; | ||
| 358 | my $filehandle = $oop_text->{_filehandle}; | ||
| 359 | my $length = scalar @array; | ||
| 360 | |||
| 361 | print $filehandle $array[0] . "\n"; | ||
| 362 | print $filehandle $array[1] . "\n"; | ||
| 363 | |||
| 364 | print $filehandle "\t" | ||
| 365 | . '$file_in[1]' . "\t" . '= ' . "'" | ||
| 366 | . $oop_text->{_file_name_in} . "'" . ';' . "\n"; | ||
| 367 | |||
| 368 | for ( my $i = 2 ; $i < $length ; $i++ ) { | ||
| 369 | print $filehandle $array[$i] . "\n"; | ||
| 370 | } | ||
| 371 | |||
| 372 | return (); | ||
| 373 | } | ||
| 374 | |||
| 375 | =pod sub declare_data_out | ||
| 376 | |||
| 377 | write declare_data_out | ||
| 378 | data can be in different formats, | ||
| 379 | e.g. su, text, binary etc. | ||
| 380 | |||
| 381 | data can be for input or output | ||
| 382 | |||
| 383 | =cut | ||
| 384 | |||
| 385 | sub declare_data_out { | ||
| 386 | my ($self) = @_; | ||
| 387 | print("oop_text,declare_data_out\n"); | ||
| 388 | my $ref_array = $declare_data_out->outbound_section(); | ||
| 389 | my $filehandle = $oop_text->{_filehandle}; | ||
| 390 | |||
| 391 | foreach (@$ref_array) { | ||
| 392 | print $filehandle "$_\n"; | ||
| 393 | } | ||
| 394 | |||
| 395 | return (); | ||
| 396 | } | ||
| 397 | |||
| 398 | =pod sub get_declare_pkg | ||
| 399 | |||
| 400 | write get_declare_pkgs | ||
| 401 | V0.0.2 July 24 2018, includes data_out and data_in | ||
| 402 | |||
| 403 | =cut | ||
| 404 | |||
| 405 | sub get_declare_pkg { | ||
| 406 | my ($self) = @_; | ||
| 407 | |||
| 408 | my $ref_array = $oop_declare_pkg->section(); | ||
| 409 | my $filehandle = $oop_text->{_filehandle}; | ||
| 410 | |||
| 411 | foreach (@$ref_array) { | ||
| 412 | print $filehandle "$_\n"; | ||
| 413 | } | ||
| 414 | |||
| 415 | # print("1. oop_text,get_declare_pkg: prog_names= @{$oop_text->{_prog_names_aref}}\n"); | ||
| 416 | $oop_declaration_defaults->set_prog_names_aref($oop_text); | ||
| 417 | my $non_duplicate_aref = $oop_declaration_defaults->section(); | ||
| 418 | my $num_progs4flow = scalar @$non_duplicate_aref; | ||
| 419 | |||
| 420 | for ( my $j = 0 ; $j < $num_progs4flow ; $j++ ) { | ||
| 421 | |||
| 422 | # exclude declaring data files here | ||
| 423 | # data file declarations are handled by declare_data | ||
| 424 | my $prog_name = @{$non_duplicate_aref}[$j]; | ||
| 425 | |||
| 426 | print $filehandle "\t" . 'my (@' . $prog_name . ');' . "\n"; | ||
| 427 | |||
| 428 | # print "\t" . 'my (@' . $prog_name . ');' . "\n"; | ||
| 429 | |||
| 430 | } | ||
| 431 | |||
| 432 | return (); | ||
| 433 | } | ||
| 434 | |||
| 435 | =pod sub get_define_flows | ||
| 436 | |||
| 437 | write built flows | ||
| 438 | print("oop_text,flows,prog_version_aref=@{$oop_text->{_prog_version_aref}}\n"); | ||
| 439 | |||
| 440 | =cut | ||
| 441 | |||
| 442 | sub get_define_flows { | ||
| 443 | my ($self) = @_; | ||
| 444 | |||
| 445 | $oop_flows->set_message($oop_text); | ||
| 446 | $oop_flows->set_prog_version_aref($oop_text); | ||
| 447 | $oop_flows->set_num_progs4flow($oop_text); | ||
| 448 | $oop_flows->set_prog_names_aref($oop_text); | ||
| 449 | $oop_flows->set_specs(); | ||
| 450 | |||
| 451 | my $ref_array = $oop_flows->get_section(); | ||
| 452 | my $filehandle = $oop_text->{_filehandle}; | ||
| 453 | |||
| 454 | foreach (@$ref_array) { | ||
| 455 | print $filehandle "$_\n"; | ||
| 456 | |||
| 457 | # print "oop_text, get_define_flows$_\n"; | ||
| 458 | } | ||
| 459 | |||
| 460 | return (); | ||
| 461 | } | ||
| 462 | |||
| 463 | =pod sub get_pod_header | ||
| 464 | |||
| 465 | import standard perl | ||
| 466 | pod_headers | ||
| 467 | and write to output file | ||
| 468 | |||
| 469 | =cut | ||
| 470 | |||
| 471 | sub get_pod_header { | ||
| 472 | my ($self) = @_; | ||
| 473 | |||
| 474 | my $ref_array = $oop_pod_header->section(); | ||
| 475 | my $filehandle = $oop_text->{_filehandle}; | ||
| 476 | |||
| 477 | # my $length = scalar @$ref_array; | ||
| 478 | |||
| 479 | foreach (@$ref_array) { | ||
| 480 | print $filehandle "$_\n"; | ||
| 481 | } | ||
| 482 | |||
| 483 | return (); | ||
| 484 | } | ||
| 485 | |||
| 486 | =head2 sub instantiation | ||
| 487 | |||
| 488 | oop_instantiation_defaults removes duplicate file names | ||
| 489 | |||
| 490 | =cut | ||
| 491 | |||
| 492 | sub instantiation { | ||
| 493 | my ($self) = @_; | ||
| 494 | |||
| 495 | # print("1. oop_text,instantiation: prog_names= @{$oop_text->{_prog_names_aref}}\n"); | ||
| 496 | $oop_instantiation_defaults->set_prog_names_aref($oop_text); | ||
| 497 | my $ref_array = $oop_instantiation_defaults->section(); | ||
| 498 | |||
| 499 | # print("2. oop_text,instantiation: prog_names= @$ref_array\n"); | ||
| 500 | my $filehandle = $oop_text->{_filehandle}; | ||
| 501 | |||
| 502 | foreach (@$ref_array) { | ||
| 503 | print $filehandle "$_\n"; | ||
| 504 | |||
| 505 | # print "oop_text,instantiation, $_\n"; | ||
| 506 | } | ||
| 507 | |||
| 508 | return (); | ||
| 509 | } | ||
| 510 | |||
| 511 | =head2 sub get_log_flows | ||
| 512 | |||
| 513 | =cut | ||
| 514 | |||
| 515 | sub get_log_flows { | ||
| 516 | my ($self) = @_; | ||
| 517 | |||
| 518 | my $ref_array = $oop_log_flows->section(); | ||
| 519 | my $filehandle = $oop_text->{_filehandle}; | ||
| 520 | |||
| 521 | foreach (@$ref_array) { | ||
| 522 | print $filehandle "$_\n"; | ||
| 523 | } | ||
| 524 | return (); | ||
| 525 | |||
| 526 | } | ||
| 527 | |||
| 528 | =head2 sub get_pod_declare | ||
| 529 | |||
| 530 | =cut | ||
| 531 | |||
| 532 | sub get_pod_declare { | ||
| 533 | my ($self) = @_; | ||
| 534 | |||
| 535 | my $ref_array = $pod_declare->section(); | ||
| 536 | my $filehandle = $oop_text->{_filehandle}; | ||
| 537 | |||
| 538 | foreach (@$ref_array) { | ||
| 539 | print $filehandle "$_\n"; | ||
| 540 | } | ||
| 541 | return (); | ||
| 542 | } | ||
| 543 | |||
| 544 | =head2 sub pod_flows | ||
| 545 | |||
| 546 | =cut | ||
| 547 | |||
| 548 | sub get_pod_flows { | ||
| 549 | my ($self) = @_; | ||
| 550 | |||
| 551 | my $ref_array = $pod_flows->section(); | ||
| 552 | my $filehandle = $oop_text->{_filehandle}; | ||
| 553 | |||
| 554 | foreach (@$ref_array) { | ||
| 555 | print $filehandle "$_\n"; | ||
| 556 | } | ||
| 557 | return (); | ||
| 558 | } | ||
| 559 | |||
| 560 | =head2 sub get_pod_log_flows | ||
| 561 | |||
| 562 | =cut | ||
| 563 | |||
| 564 | sub get_pod_log_flows { | ||
| 565 | my ($self) = @_; | ||
| 566 | |||
| 567 | my $ref_array = $pod_log_flows->section(); | ||
| 568 | my $filehandle = $oop_text->{_filehandle}; | ||
| 569 | |||
| 570 | foreach (@$ref_array) { | ||
| 571 | print $filehandle "$_\n"; | ||
| 572 | } | ||
| 573 | return (); | ||
| 574 | } | ||
| 575 | |||
| 576 | =head2 sub set_pod_prog_param_setup | ||
| 577 | |||
| 578 | write pod on | ||
| 579 | Setup | ||
| 580 | |||
| 581 | =cut | ||
| 582 | |||
| 583 | sub set_pod_prog_param_setup { | ||
| 584 | my ($self) = @_; | ||
| 585 | my $program_name = $oop_text->{_prog_name}; | ||
| 586 | |||
| 587 | my $ref_array = $pod_prog_param_setup->section(); | ||
| 588 | my @array = @$ref_array; | ||
| 589 | my $filehandle = $oop_text->{_filehandle}; | ||
| 590 | my $length = scalar @$ref_array; | ||
| 591 | my $i; | ||
| 592 | |||
| 593 | for ( $i = 0 ; $i < ( $length - 1 ) ; $i++ ) { | ||
| 594 | print $filehandle $array[$i] . "\n"; | ||
| 595 | } | ||
| 596 | print $filehandle "\t" . $program_name . ' parameter values' . "\n"; | ||
| 597 | print $filehandle $array[$i]; | ||
| 598 | return (); | ||
| 599 | } | ||
| 600 | |||
| 601 | =head2 sub get_pod_run_flows | ||
| 602 | |||
| 603 | =cut | ||
| 604 | |||
| 605 | sub get_pod_run_flows { | ||
| 606 | |||
| 607 | my ($self) = @_; | ||
| 608 | |||
| 609 | my $ref_array = $pod_run_flows->section(); | ||
| 610 | my $filehandle = $oop_text->{_filehandle}; | ||
| 611 | |||
| 612 | foreach (@$ref_array) { | ||
| 613 | print $filehandle "$_\n"; | ||
| 614 | } | ||
| 615 | |||
| 616 | # return(); | ||
| 617 | } | ||
| 618 | |||
| 619 | =head2 sub get_print_flows | ||
| 620 | |||
| 621 | =cut | ||
| 622 | |||
| 623 | sub get_print_flows { | ||
| 624 | my ($self) = @_; | ||
| 625 | |||
| 626 | my $ref_array = $print_flows->section(); | ||
| 627 | my $filehandle = $oop_text->{_filehandle}; | ||
| 628 | |||
| 629 | foreach (@$ref_array) { | ||
| 630 | print $filehandle "$_\n"; | ||
| 631 | } | ||
| 632 | return (); | ||
| 633 | |||
| 634 | } | ||
| 635 | |||
| 636 | =head2 sub get_program_params | ||
| 637 | |||
| 638 | Sets labels and their values | ||
| 639 | print("oop_text,get_program_params,version=$oop_text->{_prog_version}\n"); | ||
| 640 | print("oop_text,get_program_params,labels=@{$oop_text->{_prog_param_labels_aref}}\n"); | ||
| 641 | print("oop_text,get_program_params,values=@{$oop_text->{_prog_param_values_aref}}\n"); | ||
| 642 | print("oop_text,get_program_params,prog_name=$oop_text->{_prog_name}\n"); | ||
| 643 | |||
| 644 | =cut | ||
| 645 | |||
| 646 | sub get_program_params { | ||
| 647 | my ($self) = @_; | ||
| 648 | |||
| 649 | my $filehandle = $oop_text->{_filehandle}; | ||
| 650 | |||
| 651 | $prog_params->set_a_prog_name($oop_text); | ||
| 652 | $prog_params->set_a_prog_version($oop_text); | ||
| 653 | $prog_params->set_many_param_labels($oop_text); | ||
| 654 | $prog_params->set_many_param_values($oop_text); | ||
| 655 | |||
| 656 | my $ref_array = $prog_params->get_a_section(); | ||
| 657 | |||
| 658 | if ( ( @$ref_array[0] ) ) { # refuse an empty case | ||
| 659 | |||
| 660 | # print("1. oop_text,prog_params, flow item detected \n"); | ||
| 661 | foreach (@$ref_array) { | ||
| 662 | print $filehandle "$_\n"; # NOT FORMATTED | ||
| 663 | } | ||
| 664 | } | ||
| 665 | else { | ||
| 666 | print("Warning: oop_text,prog_params, no flow item detected\n"); | ||
| 667 | } | ||
| 668 | return (); | ||
| 669 | |||
| 670 | } | ||
| 671 | |||
| 672 | =head2 sub get_run_flows | ||
| 673 | |||
| 674 | =cut | ||
| 675 | |||
| 676 | sub get_run_flows { | ||
| 677 | my ($self) = @_; | ||
| 678 | |||
| 679 | my $ref_array = $oop_run_flows->section(); | ||
| 680 | my $filehandle = $oop_text->{_filehandle}; | ||
| 681 | |||
| 682 | foreach (@$ref_array) { | ||
| 683 | print $filehandle "$_\n"; | ||
| 684 | } | ||
| 685 | |||
| 686 | return (); | ||
| 687 | } | ||
| 688 | |||
| 689 | =head2 sub set_message | ||
| 690 | |||
| 691 | =cut | ||
| 692 | |||
| 693 | sub set_message { | ||
| 694 | my ( $self, $hash_ref ) = @_; | ||
| 695 | |||
| 696 | if ($hash_ref) { | ||
| 697 | $oop_text->{_message_w} = $hash_ref->{_message_w}; | ||
| 698 | |||
| 699 | # my $message_w = $oop_text->{_message_w}; | ||
| 700 | # my $m = "oop_text,set_message,$message_w\n"; | ||
| 701 | # $message_w->delete("1.0",'end'); | ||
| 702 | # $message_w->insert('end', $m); | ||
| 703 | # print("oop_text,set_message, message=$oop_text->{_message}\n"); | ||
| 704 | } | ||
| 705 | return (); | ||
| 706 | } | ||
| 707 | |||
| 708 | =head2 sub set_filehandle | ||
| 709 | |||
| 710 | =cut | ||
| 711 | |||
| 712 | sub set_filehandle { | ||
| 713 | my ( $self, $filehandle ) = @_; | ||
| 714 | |||
| 715 | if ($filehandle) { | ||
| 716 | $oop_text->{_filehandle} = $filehandle; | ||
| 717 | |||
| 718 | # print("oop_text,set_filehandle, filehandle=$oop_text->{_filehandle}\n"); | ||
| 719 | } | ||
| 720 | return (); | ||
| 721 | } | ||
| 722 | |||
| 723 | =head2 sub set_macro_head | ||
| 724 | |||
| 725 | =cut | ||
| 726 | |||
| 727 | =head2 sub set_macro_tail | ||
| 728 | |||
| 729 | =cut | ||
| 730 | |||
| 731 | =head2 sub set_prog_name | ||
| 732 | |||
| 733 | =cut | ||
| 734 | |||
| 735 | sub set_prog_name { | ||
| 736 | my ( $self, $prog_name ) = @_; | ||
| 737 | |||
| 738 | if ($prog_name) { | ||
| 739 | $oop_text->{_prog_name} = $prog_name; | ||
| 740 | |||
| 741 | # print("oop_text,set_prog_name,prog_name=$oop_text->{_prog_name}\n"); | ||
| 742 | } | ||
| 743 | return (); | ||
| 744 | } | ||
| 745 | |||
| 746 | =head2 sub set_prog_version | ||
| 747 | |||
| 748 | =cut | ||
| 749 | |||
| 750 | sub set_prog_version { | ||
| 751 | my ( $self, $prog_version ) = @_; | ||
| 752 | |||
| 753 | if ($prog_version) { | ||
| 754 | $oop_text->{_prog_version} = $prog_version; | ||
| 755 | |||
| 756 | # print("oop_text,set_prog_version,prog_version=$oop_text->{_prog_version}\n"); | ||
| 757 | } | ||
| 758 | return (); | ||
| 759 | } | ||
| 760 | |||
| 761 | =head2 sub set_prog_version_aref | ||
| 762 | |||
| 763 | print("oop_text,set_prog_version_aref,prog_version_aref=@{$hash_aref->{_items_versions_aref}}\n"); | ||
| 764 | print("oop_text,set_prog_version_aref,prog_version_aref=@{$oop_text->{_prog_version_aref}}\n"); | ||
| 765 | |||
| 766 | =cut | ||
| 767 | |||
| 768 | sub set_prog_version_aref { | ||
| 769 | my ( $self, $hash_aref ) = @_; | ||
| 770 | |||
| 771 | if ($hash_aref) { | ||
| 772 | $oop_text->{_prog_version_aref} = $hash_aref->{_items_versions_aref}; | ||
| 773 | } | ||
| 774 | return (); | ||
| 775 | } | ||
| 776 | |||
| 777 | =head2 sub set_num_progs4flow | ||
| 778 | |||
| 779 | =cut | ||
| 780 | |||
| 781 | sub set_num_progs4flow { | ||
| 782 | my ( $self, $prog_names_aref ) = @_; | ||
| 783 | |||
| 784 | if ($prog_names_aref) { | ||
| 785 | $oop_text->{_num_progs4flow} = scalar @$prog_names_aref; | ||
| 786 | |||
| 787 | # print("oop_text,set_num_progs4flow,num_progs4flow =$oop_text->{_num_progs4flow}\n"); | ||
| 788 | } | ||
| 789 | return (); | ||
| 790 | } | ||
| 791 | |||
| 792 | =head2 sub set_prog_names_aref | ||
| 793 | |||
| 794 | =cut | ||
| 795 | |||
| 796 | sub set_prog_names_aref { | ||
| 797 | my ( $self, $prog_names_aref ) = @_; | ||
| 798 | |||
| 799 | if ($prog_names_aref) { | ||
| 800 | $oop_text->{_prog_names_aref} = $prog_names_aref; | ||
| 801 | |||
| 802 | # print("oop_text,set_prog_names_aref, prog_names=@{$oop_text->{_prog_names_aref}}\n"); | ||
| 803 | } | ||
| 804 | return (); | ||
| 805 | } | ||
| 806 | |||
| 807 | =head2 sub set_prog_param_values_aref | ||
| 808 | |||
| 809 | =cut | ||
| 810 | |||
| 811 | sub set_prog_param_values_aref { | ||
| 812 | my ( $self, $prog_param_values_aref ) = @_; | ||
| 813 | |||
| 814 | # print("oop_text,set_prog_param_values_aref, prog_param_values=@{$prog_param_values_aref}\n"); | ||
| 815 | |||
| 816 | if ($prog_param_values_aref) { | ||
| 817 | $oop_text->{_prog_param_values_aref} = $prog_param_values_aref; | ||
| 818 | |||
| 819 | # print("oop_text,set_prog_param_values_aref, prog_param_values=@{$oop_text->{_prog_param_values_aref}}\n"); | ||
| 820 | } | ||
| 821 | return (); | ||
| 822 | } | ||
| 823 | |||
| 824 | =head2 sub set_prog_param_labels_aref | ||
| 825 | |||
| 826 | =cut | ||
| 827 | |||
| 828 | sub set_prog_param_labels_aref { | ||
| 829 | my ( $self, $prog_param_labels_aref ) = @_; | ||
| 830 | |||
| 831 | if ($prog_param_labels_aref) { | ||
| 832 | $oop_text->{_prog_param_labels_aref} = $prog_param_labels_aref; | ||
| 833 | |||
| 834 | # print("oop_text,set_prog_param_labels_aref, prog_param_labels=@{$oop_text->{_prog_param_labels_aref}}\n"); | ||
| 835 | } | ||
| 836 | return (); | ||
| 837 | } | ||
| 838 | |||
| 839 | =head2 sub get_use_pkg | ||
| 840 | |||
| 841 | origanize output text in the declaration section | ||
| 842 | of the perl script | ||
| 843 | |||
| 844 | N.B. @{$oop_text->{_prog_names_aref}}[$j] contains other programs | ||
| 845 | N.B. ref-array contains: | ||
| 846 | e.g., use aliased 'App::SeismicUnixGui::misc::message'; | ||
| 847 | use aliased 'App::SeismicUnixGui::misc::flow'; | ||
| 848 | |||
| 849 | output in the text file should look something like | ||
| 850 | use aliased 'App::SeismicUnixGui::misc::message'; | ||
| 851 | use aliased 'App::SeismicUnixGui::misc::flow'; | ||
| 852 | use data_in | ||
| 853 | use suxwigb | ||
| 854 | |||
| 855 | 4-4-19: prevent repetition of programs being output | ||
| 856 | |||
| 857 | July 2022: program name needs to know its full path | ||
| 858 | within the project e.g., | ||
| 859 | name is now App::SeismicGui::misc::name | ||
| 860 | use L_SU_global_constants, e.g.,->get_path4convert_file. | ||
| 861 | |||
| 862 | =cut | ||
| 863 | |||
| 864 | sub get_use_pkg { | ||
| 865 | |||
| 866 | my ($self) = @_; | ||
| 867 | |||
| 868 | my @unique_progs; | ||
| 869 | my $unique_progs_ref; | ||
| 870 | my $num_unique_progs; | ||
| 871 | my $array_ref = $oop_use_pkg->section(); | ||
| 872 | my $length = scalar @$array_ref; | ||
| 873 | my $filter = manage_files_by2->new(); | ||
| 874 | my $L_SU_global_constants = L_SU_global_constants->new(); | ||
| 875 | my $var = $L_SU_global_constants->var(); | ||
| 876 | my $filehandle = $oop_text->{_filehandle}; | ||
| 877 | |||
| 878 | # print("oop,text,get_use_pkg,length=$length\n"); | ||
| 879 | # print("oop_text,get_use_pkg filehandle =$filehandle \n"); | ||
| 880 | |||
| 881 | # print first two use lines | ||
| 882 | for ( my $i = 0 ; $i < $length ; $i++ ) { | ||
| 883 | |||
| 884 | print $filehandle @{$array_ref}[$i]; | ||
| 885 | # print("oop_text,get_use_pkg i=$i, @{$array_ref}[$i]\n"); | ||
| 886 | |||
| 887 | } | ||
| 888 | |||
| 889 | # remove repeated programs from the list | ||
| 890 | $unique_progs_ref = | ||
| 891 | $filter->unique_elements( $oop_text->{_prog_names_aref} ); | ||
| 892 | @unique_progs = @{$unique_progs_ref}; | ||
| 893 | $num_unique_progs = scalar @unique_progs; | ||
| 894 | |||
| 895 | for ( my $j = 0 ; $j < $num_unique_progs ; $j++ ) { | ||
| 896 | my $prog_name = $unique_progs[$j]; | ||
| 897 | |||
| 898 | my $module_name_pm = $prog_name . $var->{_suffix_pm}; | ||
| 899 | my $separation = $var->{_App} . '/' . $var->{_SeismicUnixGui}; | ||
| 900 | |||
| 901 | $dirs->set_file_name($module_name_pm); | ||
| 902 | my $PATH = $dirs->get_path4convert_file(); | ||
| 903 | # carp $PATH; | ||
| 904 | |||
| 905 | if ( length $PATH ) { | ||
| 906 | |||
| 907 | my $pathNmodule_pm = $PATH . '/' . $module_name_pm; | ||
| 908 | my @next_string = split( $separation, $pathNmodule_pm ); | ||
| 909 | |||
| 910 | # warn 'b4:' . $next_string[0]; | ||
| 911 | # warn 'After:' . $next_string[1]; | ||
| 912 | # warn $next_string[2]; | ||
| 913 | |||
| 914 | # substitute "/" with "::" | ||
| 915 | $next_string[1] =~ s/(\/)+/::/g; | ||
| 916 | $next_string[1] =~ s/.pm//g; | ||
| 917 | $next_string[1] = | ||
| 918 | $var->{_App} . '::' . $var->{_SeismicUnixGui} . $next_string[1]; | ||
| 919 | |||
| 920 | print $filehandle "\t" | ||
| 921 | . 'use aliased \'' | ||
| 922 | . $next_string[1] . '\';' . "\n"; | ||
| 923 | |||
| 924 | # print "\t" | ||
| 925 | # . 'use aliased \''.$next_string[1] .'\';' | ||
| 926 | # . "\n"; | ||
| 927 | |||
| 928 | } | ||
| 929 | else { | ||
| 930 | warn 'Warning: variable missing'; | ||
| 931 | } | ||
| 932 | |||
| 933 | } | ||
| 934 | return (); | ||
| 935 | } | ||
| 936 | |||
| 937 | 1; |