Elements 6.1.2
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
DataSourceUser.cpp
Go to the documentation of this file.
1
23
24#include <cstdlib> // for size_t
25
26namespace Elements {
27namespace Examples {
28
30
31 using std::size_t;
32
33 double sum = 0.;
34
35 size_t records_number = data_source.countRecords();
36 for (size_t index = 0; index < records_number; ++index) {
37 sum += data_source.getRecordValue(index);
38 }
39
40 return sum;
41}
42
43} // namespace Examples
44} // namespace Elements
This class has been created to demonstrate unit testing. It is an Interface over a DataSource (a File...
virtual double getRecordValue(std::size_t index) const =0
Fetch the value of the n-th record of the DataSource.
virtual std::size_t countRecords() const =0
Count the number of records into the DataSource.
double sumRecords(const DataSourceInterface &data_source)
Compute the sum of the values of the records stored into the provided DataSource.