forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaycounter.h
56 lines (46 loc) · 1.57 KB
/
playcounter.h
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
#ifndef MIXXX_PLAYCOUNTER_H
#define MIXXX_PLAYCOUNTER_H
#include "util/assert.h"
// Counts the total number of times a track has been played
// and if the track has been played during the current session.
class PlayCounter {
public:
explicit PlayCounter(int timesPlayed = 0):
m_iTimesPlayed(timesPlayed),
m_bPlayed(false) {
}
// Sets total number of times a track has been played
void setTimesPlayed(int iTimesPlayed) {
DEBUG_ASSERT(0 <= iTimesPlayed);
m_iTimesPlayed = iTimesPlayed;
}
// Returns the total number of times a track has been played
int getTimesPlayed() const {
return m_iTimesPlayed;
}
// Sets the played status of a track for the current session
// without affecting the play count.
void setPlayed(bool bPlayed = true) {
m_bPlayed = bPlayed;
}
// Returns true if track has been played during the current session
bool isPlayed() const {
return m_bPlayed;
}
// Sets the played status of a track for the current session and
// increments or decrements the total play count accordingly.
void setPlayedAndUpdateTimesPlayed(bool bPlayed = true);
private:
int m_iTimesPlayed;
bool m_bPlayed;
};
bool operator==(const PlayCounter& lhs, const PlayCounter& rhs);
inline
bool operator!=(const PlayCounter& lhs, const PlayCounter& rhs) {
return !(lhs == rhs);
}
inline
QDebug operator<<(QDebug dbg, const PlayCounter& arg) {
return dbg << "played =" << arg.isPlayed() << "/" << "count =" << arg.getTimesPlayed();
}
#endif // MIXXX_PLAYCOUNTER_H