line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ########################################################################## #
|
4
|
|
|
|
|
|
|
# Title: Data stream transformer
|
5
|
|
|
|
|
|
|
# Creation date: 2007-03-05
|
6
|
|
|
|
|
|
|
# Author: Michael Zedeler
|
7
|
|
|
|
|
|
|
# Description: Transforms data stream
|
8
|
|
|
|
|
|
|
# Data Stream class
|
9
|
|
|
|
|
|
|
# File: $Source: /data/cvs/lib/DSlib/lib/DS/Transformer.pm,v $
|
10
|
|
|
|
|
|
|
# Repository: kronhjorten
|
11
|
|
|
|
|
|
|
# State: $State: Exp $
|
12
|
|
|
|
|
|
|
# Documentation: inline
|
13
|
|
|
|
|
|
|
# Recepient: -
|
14
|
|
|
|
|
|
|
# ########################################################################## #
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package DS::Transformer;
|
17
|
|
|
|
|
|
|
|
18
|
6
|
|
|
6
|
|
987
|
use strict;
|
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
225
|
|
19
|
6
|
|
|
6
|
|
31
|
use Carp::Assert;
|
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
52
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our ($VERSION) = $DS::VERSION;
|
22
|
|
|
|
|
|
|
our ($REVISION) = '$Revision: 1.2 $' =~ /(\d+\.\d+)/;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
require DS::TypeSpec;
|
25
|
|
|
|
|
|
|
require DS::Target;
|
26
|
|
|
|
|
|
|
require DS::Source;
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our( @ISA ) = qw{ DS::Target DS::Source };
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new {
|
32
|
17
|
|
|
17
|
1
|
980
|
my( $class, $in_type, $out_type, $source, $target ) = @_;
|
33
|
|
|
|
|
|
|
|
34
|
17
|
|
|
|
|
49
|
bless my $self = {}, $class;
|
35
|
|
|
|
|
|
|
|
36
|
17
|
100
|
|
|
|
67
|
if( $in_type ) {
|
37
|
6
|
|
|
|
|
37
|
$self->in_type( $in_type );
|
38
|
|
|
|
|
|
|
}
|
39
|
17
|
100
|
|
|
|
47
|
if( $out_type ) {
|
40
|
6
|
|
|
|
|
30
|
$self->out_type( $out_type );
|
41
|
|
|
|
|
|
|
}
|
42
|
17
|
100
|
|
|
|
41
|
if( $source ) {
|
43
|
3
|
|
|
|
|
29
|
$self->attach_source( $source );
|
44
|
|
|
|
|
|
|
}
|
45
|
17
|
100
|
|
|
|
39
|
if( $target ) {
|
46
|
1
|
|
|
|
|
8
|
$self->attach_target( $target );
|
47
|
|
|
|
|
|
|
}
|
48
|
|
|
|
|
|
|
|
49
|
17
|
|
|
|
|
58
|
return $self;
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Override this method if you want to change how the transformer passes
|
53
|
|
|
|
|
|
|
# rows onto its target when this method is called. If you just want to
|
54
|
|
|
|
|
|
|
# transform the row without changing how data is passed on, override
|
55
|
|
|
|
|
|
|
# process() in stead.
|
56
|
|
|
|
|
|
|
# This method MUST NOT return anything. If errors occur, croak or die with exceptions
|
57
|
|
|
|
|
|
|
sub receive_row {
|
58
|
91
|
|
|
91
|
1
|
114
|
my( $self, $row ) = @_;
|
59
|
|
|
|
|
|
|
|
60
|
91
|
|
|
|
|
249
|
$self->pass_row( $self->process( $row ) );
|
61
|
|
|
|
|
|
|
|
62
|
91
|
|
|
|
|
198
|
return;
|
63
|
|
|
|
|
|
|
}
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Process row (possibly transforming it) before passing it to
|
66
|
|
|
|
|
|
|
# the next transformer.
|
67
|
|
|
|
|
|
|
# Just no operation (this method is here to be overridden)
|
68
|
|
|
|
|
|
|
sub process {
|
69
|
0
|
|
|
0
|
1
|
|
return $_[1];
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1;
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__
|