diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2012-09-06 14:26:02 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2012-09-06 14:46:51 +0200 |
commit | fcf9ffe668004c5437467744371024959ae78f94 (patch) | |
tree | f0cb3517c8e45795d5946e87f10bcf0a6cdac4da /src/mpdpp.h | |
parent | 0147a24add81c7f2192ef8048555c45d5b3982a0 (diff) |
mpd: separate statistics
Diffstat (limited to 'src/mpdpp.h')
-rw-r--r-- | src/mpdpp.h | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/mpdpp.h b/src/mpdpp.h index d636949e..c6af960b 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -21,6 +21,7 @@ #ifndef _MPDPP_H #define _MPDPP_H +#include <cassert> #include <set> #include <vector> @@ -33,6 +34,26 @@ enum ItemType { itDirectory, itSong, itPlaylist }; enum PlayerState { psUnknown, psStop, psPlay, psPause }; enum ReplayGainMode { rgmOff, rgmTrack, rgmAlbum }; +struct Statistics +{ + friend class Connection; + + bool empty() const; + + unsigned artists() const; + unsigned albums() const; + unsigned songs() const; + unsigned long playTime() const; + unsigned long uptime() const; + unsigned long dbUpdateTime() const; + unsigned long dbPlayTime() const; + +private: + Statistics(mpd_stats *stats) : m_stats(stats, mpd_stats_free) { } + + std::shared_ptr<mpd_stats> m_stats; +}; + struct Item { std::shared_ptr<Song> song; @@ -78,6 +99,8 @@ typedef std::vector<Output> OutputList; class Connection { + friend struct Statistics; + typedef void (*StatusUpdater) (Connection *, StatusChanges, void *); typedef void (*ErrorHandler) (Connection *, int, const char *, void *); @@ -106,10 +129,11 @@ public: void SetPassword(const std::string &password) { itsPassword = password; } bool SendPassword(); + Statistics getStatistics(); + void SetStatusUpdater(StatusUpdater, void *); void SetErrorHandler(ErrorHandler, void *); void UpdateStatus(); - void UpdateStats(); bool UpdateDirectory(const std::string &); void Play(); @@ -143,14 +167,6 @@ public: int GetTotalTime() const { return itsCurrentStatus ? mpd_status_get_total_time(itsCurrentStatus) : 0; } unsigned GetBitrate() const { return itsCurrentStatus ? mpd_status_get_kbit_rate(itsCurrentStatus) : 0; } - unsigned NumberOfArtists() const { return itsStats ? mpd_stats_get_number_of_artists(itsStats) : 0; } - unsigned NumberOfAlbums() const { return itsStats ? mpd_stats_get_number_of_albums(itsStats) : 0; } - unsigned NumberOfSongs() const { return itsStats ? mpd_stats_get_number_of_songs(itsStats) : 0; } - unsigned long Uptime() const { return itsStats ? mpd_stats_get_uptime(itsStats) : 0; } - unsigned long DBUpdateTime() const { return itsStats ? mpd_stats_get_db_update_time(itsStats) : 0; } - unsigned long PlayTime() const { return itsStats ? mpd_stats_get_play_time(itsStats) : 0; } - unsigned long DBPlayTime() const { return itsStats ? mpd_stats_get_db_play_time(itsStats) : 0; } - size_t GetPlaylistLength() const { return itsCurrentStatus ? mpd_status_get_queue_length(itsCurrentStatus) : 0; } SongList GetPlaylistChanges(unsigned); @@ -219,6 +235,8 @@ public: StringList GetTagTypes(); private: + //void check + void GoIdle(); int GoBusy(); @@ -243,7 +261,6 @@ private: mpd_status *itsCurrentStatus; mpd_status *itsOldStatus; - mpd_stats *itsStats; unsigned itsElapsed; time_t itsElapsedTimer[2]; |