| 1 | #!perl | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # ########################################################################## # | ||||||||||||||||||||
| 4 | # Title: Type pass through transformer | ||||||||||||||||||||
| 5 | # Creation date: 2007-07-31 | ||||||||||||||||||||
| 6 | # Author: Michael Zedeler | ||||||||||||||||||||
| 7 | # Description: Base class for transformers that does not change data type | ||||||||||||||||||||
| 8 | # Data Stream class | ||||||||||||||||||||
| 9 | # Data transformer | ||||||||||||||||||||
| 10 | # File: $Source: /data/cvs/lib/DSlib/lib/DS/Transformer/TypePassthrough.pm,v $ | ||||||||||||||||||||
| 11 | # Repository: kronhjorten | ||||||||||||||||||||
| 12 | # State: $State: Exp $ | ||||||||||||||||||||
| 13 | # Documentation: inline | ||||||||||||||||||||
| 14 | # Recepient: - | ||||||||||||||||||||
| 15 | # ########################################################################## # | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | package DS::Transformer::TypePassthrough; | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 3 | ▶ | use base qw{ DS::Transformer }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 3 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 3 | ▶ | use Carp::Assert; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 3 | our ($VERSION) = $DS::VERSION; | |||||||||||||||||||
| 26 | 3 | our ($REVISION) = '$Revision: 1.1 $' =~ /(\d+\.\d+)/; | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 3 | ▶ | use DS::TypeSpec; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | 3 | ▶ | use DS::TypeSpec::Any; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 7 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 32 | 7 | my( $class, $source, $target ) = @_; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 7 | my $self = $class->SUPER::new( undef, undef, $source, $target ); | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 7 | return $self; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 11 | ▶ | sub out_type { | ||||||||||||||||||
|
Subroutine
out_type: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 40 | 11 | my( $self, $out_type ) = @_; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 11 | my $result; | |||||||||||||||||||
| 43 | 11 | ▶ | if( $out_type ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 1 | croak("The attribute out_type is read only"); | |||||||||||||||||||
| 45 | } else { | ||||||||||||||||||||
| 46 | 10 | ▶ | if( $self->source ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 8 | $result = $self->source->out_type; | |||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||
| 49 | 2 | $result = $DS::TypeSpec::Any; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | 10 | return $result; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 5 | ▶ | sub in_type { | ||||||||||||||||||
|
Subroutine
in_type: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||
| 56 | 5 | my( $self, $in_type ) = @_; | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 5 | my $result; | |||||||||||||||||||
| 59 | 5 | ▶ | if( $in_type ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 60 | 1 | croak("The attribute in_type is read only"); | |||||||||||||||||||
| 61 | } else { | ||||||||||||||||||||
| 62 | 4 | ▶ | if( $self->target ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 4 | $result = $self->target->in_type; | |||||||||||||||||||
| 64 | } else { | ||||||||||||||||||||
| 65 | 0 | $result = $DS::TypeSpec::Any; | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | 4 | return $result; | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 7 | ▶ | sub validate_source_type { | ||||||||||||||||||
|
Subroutine
validate_source_type: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 72 | 7 | my( $self, $type ) = @_; | |||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 7 | my $result = 1; | |||||||||||||||||||
| 75 | 7 | ▶ | if( $self->target ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 2 | ▶ | $result &&= $self->target->validate_source_type( $type ); | ||||||||||||||||||
|
Condition66%2/3
$result &&= $self->target->validate_source_type($type)
MC/DC50%1/2
$result &&= $self->target->validate_source_type($type)
$result
$self->target->validate_source_type($type)
Truth table66%2/3
A &&= B
A= $resultB= $self->target->validate_source_type($type)
| |||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 7 | return $result; | |||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 3 | 1; | |||||||||||||||||||