IODA Bundle
TODATableIterator.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2012 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 /// @author Piotr Kuchta
12 /// @author Simon Smart
13 /// ECMWF Oct 2010
14 
15 #ifndef odc_sql_TODATableIterator_H
16 #define odc_sql_TODATableIterator_H
17 
18 #include "eckit/sql/SQLTable.h"
19 
20 #include "odc/Reader.h"
21 #include "odc/csv/TextReader.h"
22 
23 
24 namespace odc {
25 namespace sql {
26 
27 template <typename READER> class TODATable;
28 
29 //----------------------------------------------------------------------------------------------------------------------
30 
31 template <typename READER>
32 class TODATableIterator : public eckit::sql::SQLTableIterator {
33 
34 public: // methods
35 
37  const std::vector<std::reference_wrapper<const eckit::sql::SQLColumn>>& columns,
38  std::function<void(eckit::sql::SQLTableIterator&)> metadataUpdateCallback);
39  virtual ~TODATableIterator();
40 
41 private: // methods (override>
42 
43  virtual void rewind() override;
44  virtual bool next() override;
45 
46  virtual std::vector<size_t> columnOffsets() const override;
47  virtual std::vector<size_t> doublesDataSizes() const override;
48  virtual const double* data() const override;
49 
50 private: // methods
51 
52  void updateMetaData();
53 
54 private: // members
55 
57  typename READER::iterator it_;
58  typename READER::iterator end_;
59 
60  const std::vector<std::reference_wrapper<const eckit::sql::SQLColumn>>& columns_;
61  std::vector<size_t> columnOffsets_;
62  std::vector<size_t> columnDoublesSizes_;
63 
64  std::function<void(eckit::sql::SQLTableIterator&)> metadataUpdateCallback_;
65 
66  bool firstRow_;
67 };
68 
69 extern template class TODATableIterator<Reader>;
70 extern template class TODATableIterator<TextReader>;
71 
72 //----------------------------------------------------------------------------------------------------------------------
73 
74 } // namespace sql
75 } // namespace odc
76 
77 #endif
std::vector< size_t > columnOffsets_
std::vector< size_t > columnDoublesSizes_
virtual std::vector< size_t > columnOffsets() const override
const std::vector< std::reference_wrapper< const eckit::sql::SQLColumn > > & columns_
virtual const double * data() const override
TODATableIterator(const TODATable< READER > &parent, const std::vector< std::reference_wrapper< const eckit::sql::SQLColumn >> &columns, std::function< void(eckit::sql::SQLTableIterator &)> metadataUpdateCallback)
virtual void rewind() override
virtual bool next() override
std::function< void(eckit::sql::SQLTableIterator &)> metadataUpdateCallback_
const TODATable< READER > & parent_
virtual std::vector< size_t > doublesDataSizes() const override
Definition: ColumnInfo.h:23