| 1 | #!perl | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # ########################################################################## # | ||||||||||||||||||||
| 4 | # Title: Opaque transformer | ||||||||||||||||||||
| 5 | # Creation date: 2007-03-05 | ||||||||||||||||||||
| 6 | # Author: Michael Zedeler | ||||||||||||||||||||
| 7 | # Description: Provides opaque bindings between some internal transformers | ||||||||||||||||||||
| 8 | # and external transformers | ||||||||||||||||||||
| 9 | # Data Stream class | ||||||||||||||||||||
| 10 | # Data transformer | ||||||||||||||||||||
| 11 | # File: $Source: /data/cvs/lib/DSlib/lib/DS/Transformer/Opaque.pm,v $ | ||||||||||||||||||||
| 12 | # Repository: kronhjorten | ||||||||||||||||||||
| 13 | # State: $State: Exp $ | ||||||||||||||||||||
| 14 | # Documentation: inline | ||||||||||||||||||||
| 15 | # Recepient: - | ||||||||||||||||||||
| 16 | # ########################################################################## # | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | package DS::Transformer::Opaque; | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 1 | ▶ | use base qw{ DS::Transformer }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 1 | ▶ | use Carp qw{ confess croak }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | 1 | ▶ | use Carp::Assert; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | 1 | ▶ | use DS::Source::Push; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | 1 | ▶ | use DS::Target::Sub; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 1 | our ($VERSION) = $DS::VERSION; | |||||||||||||||||||
| 29 | 1 | our ($REVISION) = '$Revision: 1.1 $' =~ /(\d+\.\d+)/; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 3 | ▶ | sub source { | ||||||||||||||||||
|
Subroutine
source: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||
| 33 | 3 | my( $self, $source ) = @_; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 3 | my $result = $self->SUPER::source( $source ); | |||||||||||||||||||
| 36 | 3 | ▶ | if( $source ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 1 | ▶ | $self->{internal_source} = new DS::Source::Push( $source->out_type ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | or confess("Fatal error while trying to create source proxy object."); | ||||||||||||||||||||
| 39 | 1 | ▶ | $result &&= $self->attach_source_internal( $self->{internal_source} ); | ||||||||||||||||||
|
Condition33%1/3
$result &&= $self->attach_source_internal($self->{"internal_source"})
MC/DC0%0/2
$result &&= $self->attach_source_internal($self->{"internal_source"})
$result
$self->attach_source_internal($self->{"internal_source"})
Truth table33%1/3
A &&= B
A= $resultB= $self->attach_source_internal($self->{"internal_source"})
| |||||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | 3 | return $result; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 30 | ▶ | sub target { | ||||||||||||||||||
|
Subroutine
target: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||
| 45 | 30 | my( $self, $target ) = @_; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 30 | my $result = $self->SUPER::target( $target ); | |||||||||||||||||||
| 48 | 30 | ▶ | if( $target ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | $self->{internal_target} = new DS::Target::Sub( | ||||||||||||||||||||
| 50 | 13 | ▶ | sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 51 | 13 | my( undef, $row ) = @_; | |||||||||||||||||||
| 52 | 13 | $self->pass_row( $row ); | |||||||||||||||||||
| 53 | }, | ||||||||||||||||||||
| 54 | 1 | ▶ | $target->in_type | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | ) or confess("Fatal error while trying to create target proxy object."); | ||||||||||||||||||||
| 56 | 1 | ▶ | $result &&= $self->attach_target_internal( $self->{internal_target} ); | ||||||||||||||||||
|
Condition33%1/3
$result &&= $self->attach_target_internal($self->{"internal_target"})
MC/DC0%0/2
$result &&= $self->attach_target_internal($self->{"internal_target"})
$result
$self->attach_target_internal($self->{"internal_target"})
Truth table33%1/3
A &&= B
A= $resultB= $self->attach_target_internal($self->{"internal_target"})
| |||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | 30 | return $result; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | sub validate_source { | ||||||||||||||||||
|
Subroutine
validate_source: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 62 | # In DS::Transformer::Stack validation is done elsewhere. | ||||||||||||||||||||
| 63 | # Proxies causes validation to happen at two places: | ||||||||||||||||||||
| 64 | # (1) top-of-stack and target and (2) bottom-of-stack and source | ||||||||||||||||||||
| 65 | 0 | return 1; | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 0 | ▶ | sub receive_row { | ||||||||||||||||||
|
Subroutine
receive_row: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 69 | 0 | my( $self, $row ) = @_; | |||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 0 | assert( $self->{internal_source}, 'Cannot receive rows from undefined source' ); | |||||||||||||||||||
| 72 | 0 | $self->{internal_source}->receive_row( $row ); | |||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 0 | return; | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | # The following methods are delegated to the internal object | ||||||||||||||||||||
| 78 | 1 | foreach my $internal_method ( qw{ target source } ) { | |||||||||||||||||||
| 79 | 0 | ▶ | eval <<"END_METHOD"; ## no critic | ||||||||||||||||||
|
Subroutine
attach_source_internal: not called CC=1 SCAR=2.6
Subroutine
attach_target_internal: not called CC=1 SCAR=2.6
Pod
undocumented
Pod
undocumented
| |||||||||||||||||||||
| 80 | sub attach_${internal_method}_internal { | ||||||||||||||||||||
| 81 | croak("This method must be overridden. You probably want to proxy it to the internal object that needs to be hidden from the outside."); | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | END_METHOD | ||||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 1 | 1; | |||||||||||||||||||