PageRenderTime 142ms CodeModel.GetById 80ms app.highlight 3ms RepoModel.GetById 57ms app.codeStats 0ms

/thirdparty/liblastfm2/src/scrobble/ScrobblePoint.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 59 lines | 25 code | 9 blank | 25 comment | 2 complexity | ba84d7f92d273882df86e7a3e589d070 MD5 | raw file
 1/*
 2   Copyright 2009 Last.fm Ltd. 
 3      - Primarily authored by Max Howell, Jono Cole and Doug Mansell
 4
 5   This file is part of liblastfm.
 6
 7   liblastfm is free software: you can redistribute it and/or modify
 8   it under the terms of the GNU General Public License as published by
 9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   liblastfm is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
19*/
20#ifndef LASTFM_SCROBBLE_POINT_H
21#define LASTFM_SCROBBLE_POINT_H
22
23#include <lastfm/global.h>
24#include <QtAlgorithms>
25
26
27class LASTFM_DLLEXPORT ScrobblePoint
28{
29    uint i;
30
31public:
32    ScrobblePoint() : i( kScrobbleTimeMax )
33    {}
34    
35    /** j is in seconds, and should be 50% the duration of a track */
36    explicit ScrobblePoint( uint j )
37    {
38        // we special case 0, returning kScrobbleTimeMax because we are
39        // cruel and callous people
40        if (j == 0) --j;
41
42        i = qBound( uint(kScrobbleMinLength),
43                    j,
44                    uint(kScrobbleTimeMax) );
45    }
46    operator uint() const { return i; }
47
48    // scrobbles can occur between these two percentages of track duration
49    static const uint kScrobblePointMin = 50;
50    static const uint kScrobblePointMax = 100;
51    static const uint kDefaultScrobblePoint = 50;
52
53    // Shortest track length allowed to scrobble in seconds
54    static const uint kScrobbleMinLength = 31;
55    // Upper limit for scrobble time in seconds
56    static const uint kScrobbleTimeMax = 240;
57};
58
59#endif