summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/Temperature.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/Temperature.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/utils/Temperature.h')
-rw-r--r--xbmc/utils/Temperature.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/xbmc/utils/Temperature.h b/xbmc/utils/Temperature.h
new file mode 100644
index 0000000..9d2a019
--- /dev/null
+++ b/xbmc/utils/Temperature.h
@@ -0,0 +1,103 @@
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
15class CTemperature : public IArchivable
16{
17public:
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
97protected:
98 explicit CTemperature(double value);
99
100 double m_value; // we store as fahrenheit
101 bool m_valid;
102};
103