IODA Bundle
Reader.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 /// @date Feb 2009
13 /// @author Simon Smart
14 /// @date Dec 2018
15 
16 #ifndef Reader_H
17 #define Reader_H
18 
19 #ifdef SWIGPYTHON
20 #include <Python.h>
21 #endif
22 
23 #include "odc/IteratorProxy.h"
24 #include "odc/ReaderIterator.h"
25 
26 namespace eckit { class PathName; }
27 namespace eckit { class DataHandle; }
28 
29 namespace odc {
30 
31 class Reader : public eckit::NonCopyable
32 {
33 public:
35  typedef iterator::Row row;
36 
37  Reader(eckit::DataHandle &);
38  Reader(const std::string& path);
39  Reader();
40 
41  Reader(Reader&& rhs);
42  Reader& operator=(Reader&& rhs);
43 
44  virtual ~Reader();
45 
46  // TODO: begin() should be const.
47  iterator begin();
48  const iterator end() const;
49 
50  eckit::DataHandle* dataHandle();
51  // For C API
52  ReaderIterator* createReadIterator(const eckit::PathName&);
54 
55 #ifdef SWIGPYTHON
56  iterator __iter__() { return iterator(createReadIterator()); }
57 #endif
58 
59  // For the iterator to signal all data has been slurped.
60  void noMoreData();
61 
62 private:
63 
64  eckit::DataHandle* dataHandle_;
66  std::string path_;
67 
68  friend class IteratorProxy<ReaderIterator,Reader,const double>;
69  friend class ReaderIterator;
70 };
71 
72 } // namespace odc
73 
74 #endif
void noMoreData()
Definition: Reader.cc:85
eckit::DataHandle * dataHandle()
Definition: Reader.cc:95
ReaderIterator * createReadIterator()
Definition: Reader.cc:69
iterator::Row row
Definition: Reader.h:35
std::string path_
Definition: Reader.h:66
ReaderIterator * createReadIterator(const eckit::PathName &)
IteratorProxy< ReaderIterator, Reader, const double > iterator
Definition: Reader.h:34
virtual ~Reader()
Definition: Reader.cc:55
bool deleteDataHandle_
Definition: Reader.h:65
eckit::DataHandle * dataHandle_
Definition: Reader.h:64
const iterator end() const
Definition: Reader.cc:81
Reader & operator=(Reader &&rhs)
Definition: Reader.cc:42
iterator begin()
Definition: Reader.cc:74
Definition: ColumnInfo.h:23