diff options
author | Max Kellermann <max@duempel.org> | 2013-01-16 22:55:33 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-16 23:00:13 +0100 |
commit | 601495fa0f3d3793d4ee761d1b86f8435417266c (patch) | |
tree | 1284f0f0ac48668391063e5f45eba08d0b59c2ed /src/ClientList.hxx | |
parent | 1998633739b027b97ff89f92825512db91dca8f9 (diff) | |
download | mpd-601495fa0f3d3793d4ee761d1b86f8435417266c.tar.gz mpd-601495fa0f3d3793d4ee761d1b86f8435417266c.tar.xz mpd-601495fa0f3d3793d4ee761d1b86f8435417266c.zip |
ClientList: convert to a class
Diffstat (limited to '')
-rw-r--r-- | src/ClientList.hxx | 41 |
1 files changed, 31 insertions, 10 deletions
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 <list> + class Client; -bool -client_list_is_full(void); +class ClientList { + const unsigned max_size; + + unsigned size; + std::list<Client *> list; + +public: + ClientList(unsigned _max_size) + :max_size(_max_size), size(0) {} + + std::list<Client *>::iterator begin() { + return list.begin(); + } + + std::list<Client *>::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 |