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