aboutsummaryrefslogtreecommitdiffstats
path: root/src/DatabasePlugin.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-15 22:20:28 +0200
committerMax Kellermann <max@duempel.org>2012-08-15 23:05:08 +0200
commit3c0dea811d498db3091dad868740c4653c22717e (patch)
tree698de51e854a052d43cb3f872a5aee5b608fb71f /src/DatabasePlugin.hxx
parenta6ac0f89656b9ef374703d24bbb27316a705eadc (diff)
downloadmpd-3c0dea811d498db3091dad868740c4653c22717e.tar.gz
mpd-3c0dea811d498db3091dad868740c4653c22717e.tar.xz
mpd-3c0dea811d498db3091dad868740c4653c22717e.zip
DatabasePlugin: add method GetStats()
Optimize the ProxyDatabase by invoking "stats" on the peer, instead of visiting all songs.
Diffstat (limited to 'src/DatabasePlugin.hxx')
-rw-r--r--src/DatabasePlugin.hxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/DatabasePlugin.hxx b/src/DatabasePlugin.hxx
index a6168b628..37df7f654 100644
--- a/src/DatabasePlugin.hxx
+++ b/src/DatabasePlugin.hxx
@@ -37,6 +37,34 @@ struct config_param;
struct DatabaseSelection;
struct db_visitor;
+struct DatabaseStats {
+ /**
+ * Number of songs.
+ */
+ unsigned song_count;
+
+ /**
+ * Total duration of all songs (in seconds).
+ */
+ unsigned long total_duration;
+
+ /**
+ * Number of distinct artist names.
+ */
+ unsigned artist_count;
+
+ /**
+ * Number of distinct album names.
+ */
+ unsigned album_count;
+
+ void Clear() {
+ song_count = 0;
+ total_duration = 0;
+ artist_count = album_count = 0;
+ }
+};
+
class Database {
public:
/**
@@ -94,6 +122,10 @@ public:
enum tag_type tag_type,
VisitString visit_string,
GError **error_r) const = 0;
+
+ virtual bool GetStats(const DatabaseSelection &selection,
+ DatabaseStats &stats,
+ GError **error_r) const = 0;
};
struct DatabasePlugin {