From 3c0dea811d498db3091dad868740c4653c22717e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 15 Aug 2012 22:20:28 +0200 Subject: DatabasePlugin: add method GetStats() Optimize the ProxyDatabase by invoking "stats" on the peer, instead of visiting all songs. --- src/DatabasePlugin.hxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/DatabasePlugin.hxx') 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 { -- cgit v1.2.3