diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/Speed.h | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'xbmc/utils/Speed.h')
| -rw-r--r-- | xbmc/utils/Speed.h | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/xbmc/utils/Speed.h b/xbmc/utils/Speed.h new file mode 100644 index 0000000..8ad5d05 --- /dev/null +++ b/xbmc/utils/Speed.h | |||
| @@ -0,0 +1,116 @@ | |||
| 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 CSpeed : public IArchivable | ||
| 16 | { | ||
| 17 | public: | ||
| 18 | CSpeed(); | ||
| 19 | CSpeed(const CSpeed& speed); | ||
| 20 | |||
| 21 | typedef enum Unit | ||
| 22 | { | ||
| 23 | UnitKilometresPerHour = 0, | ||
| 24 | UnitMetresPerMinute, | ||
| 25 | UnitMetresPerSecond, | ||
| 26 | UnitFeetPerHour, | ||
| 27 | UnitFeetPerMinute, | ||
| 28 | UnitFeetPerSecond, | ||
| 29 | UnitMilesPerHour, | ||
| 30 | UnitKnots, | ||
| 31 | UnitBeaufort, | ||
| 32 | UnitInchPerSecond, | ||
| 33 | UnitYardPerSecond, | ||
| 34 | UnitFurlongPerFortnight | ||
| 35 | } Unit; | ||
| 36 | |||
| 37 | static CSpeed CreateFromKilometresPerHour(double value); | ||
| 38 | static CSpeed CreateFromMetresPerMinute(double value); | ||
| 39 | static CSpeed CreateFromMetresPerSecond(double value); | ||
| 40 | static CSpeed CreateFromFeetPerHour(double value); | ||
| 41 | static CSpeed CreateFromFeetPerMinute(double value); | ||
| 42 | static CSpeed CreateFromFeetPerSecond(double value); | ||
| 43 | static CSpeed CreateFromMilesPerHour(double value); | ||
| 44 | static CSpeed CreateFromKnots(double value); | ||
| 45 | static CSpeed CreateFromBeaufort(unsigned int value); | ||
| 46 | static CSpeed CreateFromInchPerSecond(double value); | ||
| 47 | static CSpeed CreateFromYardPerSecond(double value); | ||
| 48 | static CSpeed CreateFromFurlongPerFortnight(double value); | ||
| 49 | |||
| 50 | bool operator >(const CSpeed& right) const; | ||
| 51 | bool operator >=(const CSpeed& right) const; | ||
| 52 | bool operator <(const CSpeed& right) const; | ||
| 53 | bool operator <=(const CSpeed& right) const; | ||
| 54 | bool operator ==(const CSpeed& right) const; | ||
| 55 | bool operator !=(const CSpeed& right) const; | ||
| 56 | |||
| 57 | CSpeed& operator =(const CSpeed& right); | ||
| 58 | const CSpeed& operator +=(const CSpeed& right); | ||
| 59 | const CSpeed& operator -=(const CSpeed& right); | ||
| 60 | const CSpeed& operator *=(const CSpeed& right); | ||
| 61 | const CSpeed& operator /=(const CSpeed& right); | ||
| 62 | CSpeed operator +(const CSpeed& right) const; | ||
| 63 | CSpeed operator -(const CSpeed& right) const; | ||
| 64 | CSpeed operator *(const CSpeed& right) const; | ||
| 65 | CSpeed operator /(const CSpeed& right) const; | ||
| 66 | |||
| 67 | bool operator >(double right) const; | ||
| 68 | bool operator >=(double right) const; | ||
| 69 | bool operator <(double right) const; | ||
| 70 | bool operator <=(double right) const; | ||
| 71 | bool operator ==(double right) const; | ||
| 72 | bool operator !=(double right) const; | ||
| 73 | |||
| 74 | const CSpeed& operator +=(double right); | ||
| 75 | const CSpeed& operator -=(double right); | ||
| 76 | const CSpeed& operator *=(double right); | ||
| 77 | const CSpeed& operator /=(double right); | ||
| 78 | CSpeed operator +(double right) const; | ||
| 79 | CSpeed operator -(double right) const; | ||
| 80 | CSpeed operator *(double right) const; | ||
| 81 | CSpeed operator /(double right) const; | ||
| 82 | |||
| 83 | CSpeed& operator ++(); | ||
| 84 | CSpeed& operator --(); | ||
| 85 | CSpeed operator ++(int); | ||
| 86 | CSpeed operator --(int); | ||
| 87 | |||
| 88 | void Archive(CArchive& ar) override; | ||
| 89 | |||
| 90 | bool IsValid() const; | ||
| 91 | |||
| 92 | double ToKilometresPerHour() const; | ||
| 93 | double ToMetresPerMinute() const; | ||
| 94 | double ToMetresPerSecond() const; | ||
| 95 | double ToFeetPerHour() const; | ||
| 96 | double ToFeetPerMinute() const; | ||
| 97 | double ToFeetPerSecond() const; | ||
| 98 | double ToMilesPerHour() const; | ||
| 99 | double ToKnots() const; | ||
| 100 | double ToBeaufort() const; | ||
| 101 | double ToInchPerSecond() const; | ||
| 102 | double ToYardPerSecond() const; | ||
| 103 | double ToFurlongPerFortnight() const; | ||
| 104 | |||
| 105 | double To(Unit speedUnit) const; | ||
| 106 | std::string ToString(Unit speedUnit) const; | ||
| 107 | |||
| 108 | protected: | ||
| 109 | explicit CSpeed(double value); | ||
| 110 | |||
| 111 | void SetValid(bool valid) { m_valid = valid; } | ||
| 112 | |||
| 113 | double m_value; // we store in m/s | ||
| 114 | bool m_valid; | ||
| 115 | }; | ||
| 116 | |||
