diff options
author | Max Kellermann <max@duempel.org> | 2013-01-02 22:16:52 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-03 02:25:06 +0100 |
commit | 9023ba4a81d597c8694432655833cf23d83c6cde (patch) | |
tree | 304c2465ea160297dff17302f36c4cc38687ccb6 /src/PlaylistVector.hxx | |
parent | 83488848e1091024a0a307b1539c1a85762ee1f1 (diff) | |
download | mpd-9023ba4a81d597c8694432655833cf23d83c6cde.tar.gz mpd-9023ba4a81d597c8694432655833cf23d83c6cde.tar.xz mpd-9023ba4a81d597c8694432655833cf23d83c6cde.zip |
PlaylistVector: use std::list
Diffstat (limited to '')
-rw-r--r-- | src/PlaylistVector.hxx | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/src/PlaylistVector.hxx b/src/PlaylistVector.hxx index 14445315c..0a4cd95b3 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 <sys/time.h> - -#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 <list> + +class PlaylistVector : protected std::list<PlaylistInfo> { +protected: + /** + * Caller must lock the #db_mutex. + */ + gcc_pure + iterator find(const char *name); + +public: + using std::list<PlaylistInfo>::empty; + using std::list<PlaylistInfo>::begin; + using std::list<PlaylistInfo>::end; + using std::list<PlaylistInfo>::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 */ |