Commit | Line | Data |
---|---|---|
71cf2688 | 1 | // ChannelUserList.H -*- C++ -*- |
2 | // Copyright (c) 1997, 1998 Etienne BERNARD | |
3 | // Copyright (C) 2002,2005,2008,2009 Clinton Ebadi | |
4 | ||
5 | // This program is free software; you can redistribute it and/or modify | |
6 | // it under the terms of the GNU General Public License as published by | |
7 | // the Free Software Foundation; either version 2 of the License, or | |
8 | // any later version. | |
9 | ||
10 | // This program is distributed in the hope that it will be useful, | |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | // GNU General Public License for more details. | |
14 | ||
15 | // You should have received a copy of the GNU General Public License | |
16 | // along with this program; if not, write to the Free Software | |
17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
18 | // 02110-1301, USA. | |
19 | ||
20 | #ifndef CHANNEL_USER_LIST_H | |
21 | #define CHANNEL_USER_LIST_H | |
22 | ||
23 | #include <algorithm> | |
24 | #include <list> | |
25 | #include <string> | |
26 | ||
27 | #include "BotThreading.H" | |
28 | ||
29 | class User; | |
30 | class UserList; | |
31 | class UserListItem; | |
32 | ||
33 | class ChannelUserList | |
34 | { | |
35 | std::list<User> users; | |
36 | mutable BotMutex users_mutex; | |
37 | std::string channel_name; | |
38 | ||
39 | std::equal_to<User> user_equal_p; | |
40 | std::less<User> user_less_p; | |
41 | ||
42 | std::list<User>::iterator get_user_i_ (const std::string &); | |
43 | void add_ (std::string, std::string, int, UserListItem*, bool) throw (); | |
44 | ||
45 | public: | |
46 | struct user_not_found | |
47 | { | |
48 | std::string name; | |
49 | user_not_found (const std::string &n) | |
50 | : name (n) | |
51 | { } | |
52 | }; | |
53 | ||
54 | enum | |
55 | { | |
56 | MODE_ADD = 0, | |
57 | MODE_REMOVE = 1 | |
58 | }; | |
59 | ||
60 | ChannelUserList (const std::string &) throw (); | |
61 | ~ChannelUserList () throw (); | |
62 | ||
63 | void add (std::string, std::string, int, UserList*, bool = false) throw (); | |
64 | void del (const std::string &) throw (); | |
d82e6ba2 CE |
65 | User get (const std::string &) const; |
66 | void change_nickname (const std::string &, std::string); | |
71cf2688 | 67 | void change_user_mode (const std::string &, int, bool) throw (); |
68 | void change_user_key (const std::string &, const std::string &) throw (); | |
69 | bool in_channel_p (const std::string &) const throw (); | |
70 | unsigned int user_count () const throw (); | |
71 | unsigned int operator_count () const throw (); | |
72 | ||
73 | template<typename T> | |
c1ea3a86 | 74 | void foreach (T & fun) |
71cf2688 | 75 | { |
76 | BotLock foreach_lock (users_mutex); | |
77 | std::for_each (users.begin (), users.end (), fun); | |
78 | } | |
79 | }; | |
80 | ||
81 | #endif |