1 /*
2  * This file Copyright (C) 2009-2015 Mnemosyne LLC
3  *
4  * It may be used under the GNU GPL versions 2 or 3
5  * or any future license endorsed by Mnemosyne LLC.
6  *
7  */
8 
9 #pragma once
10 
11 class Speed
12 {
13 public:
Speed()14     Speed() :
15         _Bps(0)
16     {
17     }
18 
19     double KBps() const;
20 
Bps()21     int Bps() const
22     {
23         return _Bps;
24     }
25 
isZero()26     bool isZero() const
27     {
28         return _Bps == 0;
29     }
30 
31     static Speed fromKBps(double KBps);
32 
fromBps(int Bps)33     static Speed fromBps(int Bps)
34     {
35         return Speed(Bps);
36     }
37 
setBps(int Bps)38     void setBps(int Bps)
39     {
40         _Bps = Bps;
41     }
42 
43     Speed& operator +=(Speed const& that)
44     {
45         _Bps += that._Bps;
46         return *this;
47     }
48 
49     Speed operator +(Speed const& that) const
50     {
51         return Speed(_Bps + that._Bps);
52     }
53 
54     bool operator <(Speed const& that) const
55     {
56         return _Bps < that._Bps;
57     }
58 
59 private:
Speed(int Bps)60     Speed(int Bps) :
61         _Bps(Bps)
62     {
63     }
64 
65 private:
66     int _Bps;
67 };
68