From 9023ba4a81d597c8694432655833cf23d83c6cde Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 2 Jan 2013 22:16:52 +0100 Subject: PlaylistVector: use std::list --- src/PlaylistVector.hxx | 68 ++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) (limited to 'src/PlaylistVector.hxx') diff --git a/src/PlaylistVector.hxx b/src/PlaylistVector.hxx index 14445315..0a4cd95b 100644 --- a/src/PlaylistVector.hxx +++ b/src/PlaylistVector.hxx @@ -21,43 +21,35 @@ #define MPD_PLAYLIST_VECTOR_HXX #include "PlaylistInfo.hxx" -#include "util/list.h" - -#include - -#define playlist_vector_for_each(pos, head) \ - list_for_each_entry(pos, head, siblings) - -#define playlist_vector_for_each_safe(pos, n, head) \ - list_for_each_entry_safe(pos, n, head, siblings) - -void -playlist_vector_deinit(struct list_head *pv); - -/** - * Caller must lock the #db_mutex. - */ -PlaylistInfo * -playlist_vector_find(struct list_head *pv, const char *name); - -/** - * Caller must lock the #db_mutex. - */ -void -playlist_vector_add(struct list_head *pv, PlaylistInfo &&pi); - -/** - * Caller must lock the #db_mutex. - * - * @return true if the vector or one of its items was modified - */ -bool -playlist_vector_update_or_add(struct list_head *pv, PlaylistInfo &&pi); - -/** - * Caller must lock the #db_mutex. - */ -bool -playlist_vector_remove(struct list_head *pv, const char *name); +#include "gcc.h" + +#include + +class PlaylistVector : protected std::list { +protected: + /** + * Caller must lock the #db_mutex. + */ + gcc_pure + iterator find(const char *name); + +public: + using std::list::empty; + using std::list::begin; + using std::list::end; + using std::list::erase; + + /** + * Caller must lock the #db_mutex. + * + * @return true if the vector or one of its items was modified + */ + bool UpdateOrInsert(PlaylistInfo &&pi); + + /** + * Caller must lock the #db_mutex. + */ + bool erase(const char *name); +}; #endif /* SONGVEC_H */ -- cgit v1.2.3