Elements  6.2
A C++ base framework for the Euclid Software.
DataSourceUser.cpp
Go to the documentation of this file.
1 
23 
24 #include <cstdlib> // for size_t
25 
26 namespace Elements {
27 namespace Examples {
28 
29 double DataSourceUser::sumRecords(const DataSourceInterface& data_source) {
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
Elements::Examples::DataSourceInterface::countRecords
virtual std::size_t countRecords() const =0
Count the number of records into the DataSource.
Elements::Examples::DataSourceInterface::getRecordValue
virtual double getRecordValue(std::size_t index) const =0
Fetch the value of the n-th record of the DataSource.
DataSourceUser.h
Elements::Examples::DataSourceInterface
This class has been created to demonstrate unit testing. It is an Interface over a DataSource (a File...
Definition: DataSourceUser.h:46
std::size_t
Elements::Examples::DataSourceUser::sumRecords
double sumRecords(const DataSourceInterface &data_source)
Compute the sum of the values of the records stored into the provided DataSource.
Definition: DataSourceUser.cpp:29
Elements
Definition: callBackExample.h:35