From 601495fa0f3d3793d4ee761d1b86f8435417266c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 16 Jan 2013 22:55:33 +0100 Subject: ClientList: convert to a class --- src/ClientList.hxx | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'src/ClientList.hxx') diff --git a/src/ClientList.hxx b/src/ClientList.hxx index a5a89ceea..e8560af78 100644 --- a/src/ClientList.hxx +++ b/src/ClientList.hxx @@ -20,21 +20,42 @@ #ifndef MPD_CLIENT_LIST_HXX #define MPD_CLIENT_LIST_HXX +#include + class Client; -bool -client_list_is_full(void); +class ClientList { + const unsigned max_size; + + unsigned size; + std::list list; + +public: + ClientList(unsigned _max_size) + :max_size(_max_size), size(0) {} + + std::list::iterator begin() { + return list.begin(); + } + + std::list::iterator end() { + return list.end(); + } + + bool IsFull() const { + return size >= max_size; + } -void -client_list_add(Client *client); + void Add(Client &client) { + list.push_front(&client); + ++size; + } -void -client_list_foreach(void (*callback)(Client *client, void *ctx), void *ctx); + void Remove(Client &client); -void -client_list_remove(Client *client); + void CloseAll(); -void -client_list_close_all(); + void IdleAdd(unsigned flags); +}; #endif -- cgit v1.2.3