GeniusTrader/Graphics/DataSource.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 67 CC 1 SCAR 6.9
CC
1
Cov
0%
get_selected_range
2.0
set_selected_range
2.0
get_available_range
2.0
CRAP 2.0
1 package Finance::GeniusTrader::Graphics::DataSource;
2  
3 # Copyright 2000-2002 Raphaƫl Hertzog, Fabien Fulhaber
4 # This file is distributed under the terms of the General Public License
5 # version 2 or (at your option) any later version.
6  
7 use strict;
8  
9 require Finance::GeniusTrader::Graphics::DataSource::Prices;
10 require Finance::GeniusTrader::Graphics::DataSource::Volume;
11 require Finance::GeniusTrader::Graphics::DataSource::Close;
12 require Finance::GeniusTrader::Graphics::DataSource::PricesColor;
13 require Finance::GeniusTrader::Graphics::DataSource::GenericIndicatorResults;
14 require Finance::GeniusTrader::Graphics::DataSource::SingleIndicator;
15 require Finance::GeniusTrader::Graphics::DataSource::Systems;
16 require Finance::GeniusTrader::Graphics::DataSource::PortfolioEvaluation;
17  
18 =head1 Finance::GeniusTrader::Graphics::DataSource
19  
20 A datasource if a source of data for a graphical object. The datas
21 are always indexed by an integer.
22  
23 =head1 FUNCTION TO IMPLEMENT
24  
25 Each real datasource has to implement a few functions :
26  
27 =head2 Constructor : $ds->new(...)
28  
29 A constructor for the datasource has the right to have parameters.
30 When constructed it should update the available range and set the
31 selected range to the available range.
32  
33 =head2 $ds->get($index)
34  
35 Return the data associated to the corresponding index.
36  
37 =head2 $ds->is_available($index)
38  
39 Tell if the data is available for the corresponding index.
40  
41 =head2 $ds->update_value_range()
42  
43 Update the minimum value and the maximum value.
44  
45 =head1 GENERIC FUNCTIONS AVAILABLE
46  
47 =head2 ($start, $end) = $ds->get_selected_range()
48  
49 Return the range of selected data.
50  
51 =cut
52 sub get_selected_range {
53 my ($self) = @_;
54 return ($self->{'selected_start'}, $self->{'selected_end'});
55 }
56  
57 =head2 $ds->set_selected_range($start, $end)
58  
59 Set the range of selected data.
60  
61 =cut
62 sub set_selected_range {
63 my ($self, $start, $end) = @_;
64 $self->{'selected_start'} = $start;
65 $self->{'selected_end'} = $end;
66 $self->update_value_range();
67 }
68  
69 =head2 ($start, $end) = $ds->get_available_range()
70  
71 Return the range of available data.
72  
73 =cut
74 sub get_available_range {
75 my ($self) = @_;
76 return ($self->{'available_start'}, $self->{'available_end'});
77 }
78  
79 =head2 $ds->set_available_range($start, $end)
80  
81 Set the range of available data.
82  
83 =cut
84 sub set_available_range {
85 my ($self, $start, $end) = @_;
86 $self->{'available_start'} = $start;
87 $self->{'available_end'} = $end;
88 }
89  
90 =head2 ($min, $max) = $ds->get_value_range()
91  
92 Return the minimum and the maximum of the values available within
93 the selected range.
94  
95 =cut
96 sub get_value_range {
97 my ($self) = @_;
98 return ($self->{'min_value'}, $self->{'max_value'});
99 }
100  
101 =head2 $ds->set_min_value($min)
102  
103 Set the minimum value.
104  
105 =cut
106 sub set_min_value {
107 my ($self, $min) = @_;
108 $self->{'min_value'} = $min;
109 }
110  
111 =head2 $ds->set_max_value($max)
112  
113 Set the maximum value.
114  
115 =cut
116 sub set_max_value {
117 my ($self, $max) = @_;
118 $self->{'max_value'} = $max;
119 }
120  
121 1;