MI - Fimex
Units.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 UNITS_H_
25 #define UNITS_H_
26 
27 #include <string>
28 #include "fimex/CDMException.h"
29 #include "fimex/UnitsConverter.h"
30 #include <boost/shared_ptr.hpp>
31 
32 namespace MetNoFimex
33 {
34 
39 {
40 public:
42  UnitException(std::string message) : CDMException(message) {}
43 };
44 
53 class Units
54 {
55  friend class TimeUnit;
56 public:
62  Units();
63  Units(const Units& rhs);
64  Units& operator=(const Units& rhs);
65  virtual ~Units();
75  void convert(const std::string& from, const std::string& to, double& slope, double& offset);
83  boost::shared_ptr<UnitsConverter> getConverter(const std::string& from, const std::string& to);
89  bool areConvertible(const std::string& unit1, const std::string& unit2) const;
94  bool isTime(const std::string& timeUnit) const;
104  static bool unload(bool force = false) throw(UnitException);
105 private:
112  const void* exposeInternals() const;
113 };
114 
115 void handleUdUnitError(int unitErrCode, const std::string& message = "") throw(UnitException);
116 
117 }
118 
119 #endif /*UNITS_H_*/
basic_string< char > string
STL namespace.
Definition: CDMException.h:36
Definition: Units.h:53
Definition: C_CDMReader.h:35
Definition: TimeUnit.h:138
UnitException()
Definition: Units.h:41
void handleUdUnitError(int unitErrCode, const std::string &message="")
UnitException(std::string message)
Definition: Units.h:42
Definition: Units.h:38