MI - Fimex
CDMReader.h
Go to the documentation of this file.
1 /*
2  * Fimex
3  *
4  * (C) Copyright 2008, met.no
5  *
6  * Project Info: https://wiki.met.no/fimex/start
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21  * USA.
22  */
23 
24 #ifndef CDMREADER_H_
25 #define CDMREADER_H_
26 
27 #include <boost/shared_ptr.hpp>
28 #include <boost/noncopyable.hpp>
29 #include "fimex/DataDecl.h"
30 #include "fimex/CDMException.h"
31 #include "fimex/SliceBuilder.h"
32 
33 namespace MetNoFimex
34 {
35 /* forward declarations */
36 class CDM;
37 class CDMVariable;
38 class UnitsConverter;
39 
53 class CDMReader : boost::noncopyable
54 {
55 public:
56  CDMReader();
57  virtual ~CDMReader() {}
58 
62  virtual const CDM& getCDM() const;
68  virtual CDM& getInternalCDM();
69 
119  virtual DataPtr getDataSlice(const std::string& varName, size_t unLimDimPos) = 0;
120 
131  virtual DataPtr getDataSlice(const std::string& varName, const SliceBuilder& sb);
132 
143  virtual DataPtr getData(const std::string& varName);
144 
157  virtual DataPtr getScaledDataSlice(const std::string& varName, size_t unLimDimPos);
171  virtual DataPtr getScaledDataSliceInUnit(const std::string& varName, const std::string& unit, size_t unLimDimPos);
172 
180  virtual DataPtr getScaledDataSlice(const std::string& varName, const SliceBuilder& sb);
189  virtual DataPtr getScaledDataSliceInUnit(const std::string& varName, const std::string& unit, const SliceBuilder& sb);
190 
202  virtual DataPtr getScaledData(const std::string& varName);
215  virtual DataPtr getScaledDataInUnit(const std::string& varName, const std::string& unit);
216 
217 protected:
218  boost::shared_ptr<CDM> cdm_;
225  virtual DataPtr getDataSliceFromMemory(const CDMVariable& variable, size_t unLimDimPos = 0);
226 
227  void getScaleAndOffsetOf(const std::string& varName, double& scale, double& offset) const;
228 
229 private:
230  DataPtr scaleDataOf(const std::string& varName, DataPtr data, double unitScale = 1., double unitOffset = 0.);
231  DataPtr scaleDataOf(const std::string& varName, DataPtr data, boost::shared_ptr<UnitsConverter> uc);
232  DataPtr scaleDataToUnitOf(const std::string& varName, DataPtr data, const std::string& unit);
233 };
234 
235 }
236 
237 #endif /*CDMREADER_H_*/
basic_string< char > string
virtual DataPtr getScaledDataSliceInUnit(const std::string &varName, const std::string &unit, size_t unLimDimPos)
read and scale a dataslice to a known unit
boost::shared_ptr< Data > DataPtr
Definition: DataDecl.h:39
virtual DataPtr getScaledDataInUnit(const std::string &varName, const std::string &unit)
read and scale the complete data to a set unit
virtual CDM & getInternalCDM()
virtual DataPtr getDataSliceFromMemory(const CDMVariable &variable, size_t unLimDimPos=0)
Definition: SliceBuilder.h:46
boost::shared_ptr< CDM > cdm_
Definition: CDMReader.h:218
virtual DataPtr getDataSlice(const std::string &varName, size_t unLimDimPos)=0
data-reading function to be called from the CDMWriter
Data structure of the Common Data Model.
Definition: CDM.h:54
virtual DataPtr getData(const std::string &varName)
data-reading function to be called from the CDMWriter
Definition: C_CDMReader.h:35
Basic interface for CDM reading and manipulation classes.
Definition: CDMReader.h:53
void getScaleAndOffsetOf(const std::string &varName, double &scale, double &offset) const
virtual DataPtr getScaledDataSlice(const std::string &varName, size_t unLimDimPos)
read and scale a dataslice
virtual ~CDMReader()
Definition: CDMReader.h:57
virtual std::vector< std::size_t > getDimsSlice(std::string varName)
Read the sizes of the dimensions belonging to a variable slice.
virtual DataPtr getScaledData(const std::string &varName)
read and scale the complete data
Definition: CDMVariable.h:41
virtual const CDM & getCDM() const
virtual std::vector< std::size_t > getDims(std::string varName)
Read the sizes of the dimensions belonging to a variable.