MI - Fimex
FeltFile.h
Go to the documentation of this file.
1 /*
2  wdb
3 
4  Copyright (C) 2007 met.no
5 
6  Contact information:
7  Norwegian Meteorological Institute
8  Box 43 Blindern
9  0313 OSLO
10  NORWAY
11  E-mail: wdb@met.no
12 
13  This program is free software; you can redistribute it and/or modify
14  it under the terms of the GNU General Public License as published by
15  the Free Software Foundation; either version 2 of the License, or
16  (at your option) any later version.
17 
18  This program is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with this program; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26  MA 02110-1301, USA
27  */
28 
29 #ifndef FELTFILE_H_
30 #define FELTFILE_H_
31 
32 #include "FeltConstants.h"
33 #include "FeltTypes.h"
34 #include <boost/shared_ptr.hpp>
35 #include <boost/weak_ptr.hpp>
36 #include <boost/filesystem/path.hpp>
37 #include <boost/date_time/posix_time/posix_time_types.hpp>
38 #include <boost/shared_array.hpp>
39 #include <boost/noncopyable.hpp>
40 
41 
42 #include <iterator>
43 #include <vector>
44 #include <iosfwd>
45 
46 namespace felt
47 {
48 
49 class FeltFile : boost::noncopyable
50 {
51 public:
52  explicit FeltFile(const boost::filesystem::path & file);
53  ~FeltFile();
54 
55  typedef size_t size_type;
56  size_type size() const;
57  bool empty() const { return size() == 0; }
58 
59  const boost::filesystem::path & fileName() const { return fileName_; }
60 
61  std::string information() const;
62 
63  boost::posix_time::ptime lastUpdateTime() const;
64  boost::posix_time::ptime referenceTime() const;
65  boost::posix_time::ptime firstTime() const;
66  boost::posix_time::ptime lastTime() const;
67 
68  typedef boost::shared_ptr<FeltField> FeltFieldPtr;
69 
71 // class iterator;
72  iterator begin();
73  iterator end();
74 
75  typedef iterator const_iterator;
76  const_iterator begin() const;
77  const_iterator end() const;
78 
80  const FeltField & at(size_t idx) const;
81 
82 
83 
84  // simple log facility
85  static void log(const std::string& msg);
86  static void setLogStream(std::ostream& o);
87  static void setLogging(bool enableLogging);
88  static bool isLogging();
89 private:
90 
92  bool complete() const;
93 
94  typedef boost::shared_array<word> Block;
95 
96  Block getBlock_(size_type blockNo) const;
97 
105  void get_(std::vector<word> & out, size_type fromWord, size_type noOfWords) const;
106 
107  const boost::filesystem::path fileName_;
108 
113  bool changeEndianness_;
114 
115  Block block1_;
116 
118  mutable Fields fields_;
119 
120  mutable std::istream * feltFile_;
121 
122  friend class FeltField;
123 // friend class iterator;
124 };
125 
126 
127 
128 //class FeltFile::iterator : public std::iterator<std::input_iterator_tag, FeltField>
129 //{
130 //public:
131 // iterator & operator ++ ();
132 // iterator operator ++ (int);
133 // const reference operator * () const;
134 // const pointer operator -> () const;
135 //
136 // bool operator == ( const iterator & i ) const;
137 // bool operator != ( const iterator & i ) const;
138 //
139 //private:
140 // value_type & data_;
141 // const FeltFile * ff_;
142 // int index_;
143 // iterator(const FeltFile & ff);
144 // iterator();
145 // friend class FeltFile;
146 //};
147 
148 
149 }
150 #endif /*FELTFILE_H_*/
const boost::filesystem::path & fileName() const
Definition: FeltFile.h:59
Definition: FeltConstants.h:35
basic_string< char > string
std::vector< FeltFieldPtr >::const_iterator iterator
Definition: FeltFile.h:70
iterator const_iterator
Definition: FeltFile.h:75
static void log(const std::string &msg)
Definition: FeltField.h:47
iterator end()
basic_istream< char > istream
basic_ostream< char > ostream
FeltFile(const boost::filesystem::path &file)
size_type size() const
STL class.
boost::posix_time::ptime lastUpdateTime() const
static bool isLogging()
boost::posix_time::ptime lastTime() const
boost::posix_time::ptime firstTime() const
static void setLogging(bool enableLogging)
boost::posix_time::ptime referenceTime() const
Definition: FeltFile.h:49
size_t size_type
Definition: FeltFile.h:55
static void setLogStream(std::ostream &o)
const FeltField & at(size_t idx) const
throws std::out_of_range if idx is too large.
std::string information() const
bool empty() const
Definition: FeltFile.h:57
boost::shared_ptr< FeltField > FeltFieldPtr
Definition: FeltFile.h:68
iterator begin()