Elements  6.2
A C++ base framework for the Euclid Software.
TemplatedDataSourceUser.tpp
Go to the documentation of this file.
1 /*
2  * @file ElementsExamples/TemplateDataSourceUser.tpp
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 #ifndef ELEMENTSEXAMPLES_ELEMENTSEXAMPLES_TEMPLATEDDATASOURCEUSER_IMPL_
22 #error "This file should not be included directly! Use ElementsExamples/TemplatedDataSourceUser.h instead"
23 #else
24 
25 #include <cstddef> // for std::size_t
26 
27 namespace Elements {
28 namespace Examples {
29 
30 template <typename T>
31 double TemplatedDataSourceUser::sumRecords(const T& data_source) {
32  double sum = 0.;
33  std::size_t records_number = data_source.countRecords();
34  for (std::size_t index = 0; index < records_number; ++index) {
35  sum += data_source.getRecordValue(index);
36  }
37 
38  return sum;
39 }
40 
41 } // namespace Examples
42 } // namespace Elements
43 
44 #endif // ELEMENTSEXAMPLES_ELEMENTSEXAMPLES_TEMPLATEDDATASOURCEUSER_IMPL_