~ubuntu-branches/ubuntu/karmic/transmission/karmic-proposed

« back to all changes in this revision

Viewing changes to qt/.svn/text-base/speed.h.svn-base

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda
  • Date: 2009-12-06 19:11:34 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20091206191134-t0ayk0mv6xuoyt0t
Tags: 1.75-0ubuntu2.1
* debian/patches/25_new_inhibition_api.diff:
  - Port Transmission to the new gnome-session inhibit API in order
    to make suspend/hibernate inhibiting work again on Karmic (LP: #457123)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
 
3
 *
 
4
 * This file is licensed by the GPL version 2.  Works owned by the
 
5
 * Transmission project are granted a special exemption to clause 2(b)
 
6
 * so that the bulk of its code can remain under the MIT license.
 
7
 * This exemption does not extend to derived works not owned by
 
8
 * the Transmission project.
 
9
 *
 
10
 * $Id$
 
11
 */
 
12
 
 
13
#ifndef QTR_SPEED_H
 
14
#define QTR_SPEED_H
 
15
 
 
16
class Speed
 
17
{
 
18
    private:
 
19
        double _kbps;
 
20
        Speed( double kbps ): _kbps(kbps) { }
 
21
    public:
 
22
        Speed( ): _kbps(0) { }
 
23
        double kbps( ) const { return _kbps; }
 
24
        double bps( ) const { return kbps()*1024.0; }
 
25
        bool isZero( ) const { return _kbps < 0.001; }
 
26
        static Speed fromKbps( double kbps ) { return Speed( kbps ); }
 
27
        static Speed fromBps( double bps ) { return Speed( bps/1024.0 ); }
 
28
        void setKbps( double kbps ) { _kbps = kbps; }
 
29
        void setBps( double bps ) { _kbps = bps/1024.0; }
 
30
        Speed operator+( const Speed& that ) const { return Speed( kbps() + that.kbps() ); }
 
31
        Speed& operator+=( const Speed& that ) { _kbps += that._kbps; return *this; }
 
32
        bool operator<( const Speed& that ) const { return kbps() < that.kbps(); }
 
33
};
 
34
 
 
35
#endif