xbmc
Temperature.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "utils/IArchivable.h"
12 
13 #include <string>
14 
15 class CTemperature : public IArchivable
16 {
17 public:
18  CTemperature();
19  CTemperature(const CTemperature& temperature);
20 
21  typedef enum Unit
22  {
23  UnitFahrenheit = 0,
24  UnitKelvin,
25  UnitCelsius,
26  UnitReaumur,
27  UnitRankine,
28  UnitRomer,
29  UnitDelisle,
30  UnitNewton
31  } Unit;
32 
33  static CTemperature CreateFromFahrenheit(double value);
34  static CTemperature CreateFromKelvin(double value);
35  static CTemperature CreateFromCelsius(double value);
36  static CTemperature CreateFromReaumur(double value);
37  static CTemperature CreateFromRankine(double value);
38  static CTemperature CreateFromRomer(double value);
39  static CTemperature CreateFromDelisle(double value);
40  static CTemperature CreateFromNewton(double value);
41 
42  bool operator >(const CTemperature& right) const;
43  bool operator >=(const CTemperature& right) const;
44  bool operator <(const CTemperature& right) const;
45  bool operator <=(const CTemperature& right) const;
46  bool operator ==(const CTemperature& right) const;
47  bool operator !=(const CTemperature& right) const;
48 
49  CTemperature& operator =(const CTemperature& right);
50  const CTemperature& operator +=(const CTemperature& right);
51  const CTemperature& operator -=(const CTemperature& right);
52  const CTemperature& operator *=(const CTemperature& right);
53  const CTemperature& operator /=(const CTemperature& right);
54  CTemperature operator +(const CTemperature& right) const;
55  CTemperature operator -(const CTemperature& right) const;
56  CTemperature operator *(const CTemperature& right) const;
57  CTemperature operator /(const CTemperature& right) const;
58 
59  bool operator >(double right) const;
60  bool operator >=(double right) const;
61  bool operator <(double right) const;
62  bool operator <=(double right) const;
63  bool operator ==(double right) const;
64  bool operator !=(double right) const;
65 
66  const CTemperature& operator +=(double right);
67  const CTemperature& operator -=(double right);
68  const CTemperature& operator *=(double right);
69  const CTemperature& operator /=(double right);
70  CTemperature operator +(double right) const;
71  CTemperature operator -(double right) const;
72  CTemperature operator *(double right) const;
73  CTemperature operator /(double right) const;
74 
75  CTemperature& operator ++();
76  CTemperature& operator --();
77  CTemperature operator ++(int);
78  CTemperature operator --(int);
79 
80  void Archive(CArchive& ar) override;
81 
82  bool IsValid() const;
83  void SetValid(bool valid) { m_valid = valid; }
84 
85  double ToFahrenheit() const;
86  double ToKelvin() const;
87  double ToCelsius() const;
88  double ToReaumur() const;
89  double ToRankine() const;
90  double ToRomer() const;
91  double ToDelisle() const;
92  double ToNewton() const;
93 
94  double To(Unit temperatureUnit) const;
95  std::string ToString(Unit temperatureUnit) const;
96 
97 protected:
98  explicit CTemperature(double value);
99 
100  double m_value; // we store as fahrenheit
101  bool m_valid;
102 };
103 
Definition: Archive.h:29
Definition: Temperature.h:15
Definition: IArchivable.h:13