Elements  5.10
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TemplatedDataSourceUser.icpp
Go to the documentation of this file.
1 /*
2  * TemplateDataSourceUser.icpp
3  *
4  * Created on: Sep 23, 2015
5  * Author: fdubath
6  *
7  * @copyright 2012-2020 Euclid Science Ground Segment
8  *
9  * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
10  * Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option)
11  * any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <cstddef> // for std::size_t
22 
23 namespace Elements {
24 namespace Examples {
25 
26 template <typename T>
27  double TemplatedDataSourceUser::sumRecords(const T& data_source) {
28  double sum = 0.;
29  std::size_t records_number = data_source.countRecords();
30  for (std::size_t index = 0; index < records_number; ++index) {
31  sum += data_source.getRecordValue(index);
32  }
33 
34  return sum;
35 }
36 
37 } // namespace Examples
38 } // namespace Elements
39 
40 
double sumRecords(const T &data_source)
Compute the sum of the values of the records stored into the provided DataSource. ...