line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ########################################################################## #
|
4
|
|
|
|
|
|
|
# Title: Data stream generator
|
5
|
|
|
|
|
|
|
# Creation date: 2007-03-05
|
6
|
|
|
|
|
|
|
# Author: Michael Zedeler
|
7
|
|
|
|
|
|
|
# Description: Generates data stream data
|
8
|
|
|
|
|
|
|
# Data Stream class
|
9
|
|
|
|
|
|
|
# File: $Source: /data/cvs/lib/DSlib/lib/DS/Source.pm,v $
|
10
|
|
|
|
|
|
|
# Repository: kronhjorten
|
11
|
|
|
|
|
|
|
# State: $State: Exp $
|
12
|
|
|
|
|
|
|
# Documentation: inline
|
13
|
|
|
|
|
|
|
# Recepient: -
|
14
|
|
|
|
|
|
|
# ########################################################################## #
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package DS::Source;
|
17
|
|
|
|
|
|
|
|
18
|
10
|
|
|
10
|
|
74882
|
use strict;
|
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
375
|
|
19
|
10
|
|
|
10
|
|
49
|
use Carp;
|
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
828
|
|
20
|
10
|
|
|
10
|
|
5349
|
use Carp::Assert;
|
|
10
|
|
|
|
|
5468
|
|
|
10
|
|
|
|
|
72
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our ($VERSION) = $DS::VERSION;
|
23
|
|
|
|
|
|
|
our ($REVISION) = '$Revision: 1.2 $' =~ /(\d+\.\d+)/;
|
24
|
|
|
|
|
|
|
our ($STATE) = '$State: Exp $' =~ /:\s+(.+\S)\s+\$$/;
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new {
|
28
|
17
|
|
|
17
|
1
|
1602
|
my( $class, $out_type, $target ) = @_;
|
29
|
|
|
|
|
|
|
|
30
|
17
|
|
|
|
|
49
|
my $self = {
|
31
|
|
|
|
|
|
|
row => {}
|
32
|
|
|
|
|
|
|
};
|
33
|
17
|
|
|
|
|
42
|
bless $self, $class;
|
34
|
|
|
|
|
|
|
|
35
|
17
|
100
|
|
|
|
55
|
if( defined( $out_type ) ) {
|
36
|
9
|
|
|
|
|
42
|
$self->out_type( $out_type );
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
|
39
|
17
|
100
|
|
|
|
72
|
if( defined( $target ) ) {
|
40
|
1
|
|
|
|
|
9
|
$self->attach_target( $target );
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
|
43
|
17
|
|
|
|
|
50
|
return $self;
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub attach_target {
|
47
|
22
|
|
|
22
|
1
|
1530
|
my( $self, $target ) = @_;
|
48
|
|
|
|
|
|
|
|
49
|
22
|
|
|
|
|
133
|
assert( $target->isa('DS::Target') );
|
50
|
|
|
|
|
|
|
# First break link with old target, if any
|
51
|
21
|
100
|
|
|
|
115
|
if( $self->{target} ) {
|
52
|
2
|
|
|
|
|
6
|
$self->{target}->{source} = undef;
|
53
|
|
|
|
|
|
|
}
|
54
|
21
|
50
|
|
|
|
119
|
if( $target->source( $self ) ) {
|
55
|
19
|
|
|
|
|
69
|
$self->target( $target );
|
56
|
|
|
|
|
|
|
}
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# This is a primarily private method
|
60
|
|
|
|
|
|
|
# Important caveat: this method is just a field accessor method.
|
61
|
|
|
|
|
|
|
# Maintaining consistent links with target is handled by attach_target
|
62
|
|
|
|
|
|
|
sub target {
|
63
|
395
|
|
|
395
|
1
|
2662
|
my( $self, $target ) = @_;
|
64
|
|
|
|
|
|
|
|
65
|
395
|
|
|
|
|
468
|
my $result;
|
66
|
395
|
100
|
|
|
|
598
|
if( $target ) {
|
67
|
29
|
|
|
|
|
239
|
assert($target->isa('DS::Target'));
|
68
|
29
|
|
|
|
|
114
|
$self->{target} = $target;
|
69
|
29
|
|
|
|
|
58
|
$result = 1;
|
70
|
|
|
|
|
|
|
} else {
|
71
|
366
|
|
|
|
|
520
|
$result = $self->{target};
|
72
|
|
|
|
|
|
|
}
|
73
|
395
|
|
|
|
|
1611
|
return $result;
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Send row to target
|
77
|
|
|
|
|
|
|
sub pass_row {
|
78
|
168
|
|
|
168
|
1
|
1515
|
my( $self, $row ) = @_;
|
79
|
168
|
100
|
|
|
|
298
|
confess("Can't pass rows since no target has been set") unless $self->target;
|
80
|
166
|
|
|
|
|
351
|
$self->target()->receive_row( $row );
|
81
|
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub out_type {
|
84
|
62
|
|
|
62
|
1
|
1338
|
my( $self, $type ) = @_;
|
85
|
|
|
|
|
|
|
|
86
|
62
|
|
|
|
|
69
|
my $result;
|
87
|
62
|
100
|
|
|
|
115
|
if( $type ) {
|
88
|
21
|
|
|
|
|
123
|
assert($type->isa('DS::TypeSpec'));
|
89
|
21
|
|
|
|
|
114
|
$self->{out_type} = $type;
|
90
|
|
|
|
|
|
|
} else {
|
91
|
41
|
|
|
|
|
65
|
$result = $self->{out_type};
|
92
|
|
|
|
|
|
|
}
|
93
|
62
|
|
|
|
|
182
|
return $result;
|
94
|
|
|
|
|
|
|
}
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1;
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__
|