IODA Bundle
ODAHandle.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 /// \file ODAHandle.h
12 /// @author Piotr Kuchta - ECMWF Aug 2011
13 
14 #ifndef ODAHandle_H
15 #define ODAHandle_H
16 
17 #include "eckit/io/Offset.h"
18 #include "odc/ODATranslator.h"
19 
20 namespace odc {
21 
22 
23 class ODAHandle {
24 public:
25  ODAHandle(eckit::Offset, eckit::Offset);
26  ~ODAHandle();
27 
28  void addValue(const std::string& columnName, double v);
29 
30  template <typename T>
31  void getValue(const std::string& name, T& value)
32  {
33  value = ODATranslator<T>()(values_[name]);
34  eckit::Log::debug() << "ODAHandle::getValue('" << name << "',=>" << value << ")" << std::endl;
35  }
36 
37  void print(std::ostream&) const;
38 
39  eckit::Offset start() { return start_; }
40  void start(const eckit::Offset& n) { start_ = n; }
41 
42  eckit::Offset end() { return end_; }
43  void end(const eckit::Offset& n) { end_ = n; }
44 
45 private:
46 // No copy allowed
49 
50  eckit::Offset start_;
51  eckit::Offset end_;
52  std::map<std::string, double> values_;
53 
54  friend std::ostream& operator<<(std::ostream& s, const ODAHandle& p)
55  { p.print(s); return s; }
56 
57 };
58 
59 }
60 
61 #endif
ODAHandle(const ODAHandle &)
void print(std::ostream &) const
Definition: ODAHandle.cc:27
eckit::Offset start()
Definition: ODAHandle.h:39
friend std::ostream & operator<<(std::ostream &s, const ODAHandle &p)
Definition: ODAHandle.h:54
void getValue(const std::string &name, T &value)
Definition: ODAHandle.h:31
void addValue(const std::string &columnName, double v)
Definition: ODAHandle.cc:37
eckit::Offset end()
Definition: ODAHandle.h:42
ODAHandle & operator=(const ODAHandle &)
eckit::Offset end_
Definition: ODAHandle.h:51
void end(const eckit::Offset &n)
Definition: ODAHandle.h:43
void start(const eckit::Offset &n)
Definition: ODAHandle.h:40
eckit::Offset start_
Definition: ODAHandle.h:50
ODAHandle(eckit::Offset, eckit::Offset)
std::map< std::string, double > values_
Definition: ODAHandle.h:52
Definition: ColumnInfo.h:23