blob: 275b85e87a1ca511dbaa8d70d0cc7633f6aa78a9 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/* +------------------------------------+
* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
* InspIRCd: (C) 2002-2011 InspIRCd Development Team
* See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
* the file COPYING for details.
*
* ---------------------------------------------------
*/
#ifndef __MEMBERSHIP_H__
#define __MEMBERSHIP_H__
class CoreExport Membership : public Extensible
{
Membership* u_prev;
Membership* u_next;
public:
User* const user;
Channel* const chan;
// mode list, sorted by prefix rank, higest first
std::string modes;
Membership(User* u, Channel* c) : Extensible(EXTENSIBLE_MEMBERSHIP), u_prev(NULL), u_next(NULL), user(u), chan(c) {}
inline bool hasMode(char m) const
{
return modes.find(m) != std::string::npos;
}
/** Rank in the channel for actions this user is taking */
unsigned int GetAccessRank();
/** Rank in the channel for actions performed on this user */
unsigned int GetProtectRank();
friend class UCListIter;
friend class UserChanList;
};
class CoreExport UCListIter
{
Membership* curr;
public:
UCListIter(Membership* i) : curr(i) {}
inline void operator++() { if (curr) curr = curr->u_next; }
inline void operator++(int) { if (curr) curr = curr->u_next; }
inline bool operator==(const UCListIter& o) const { return curr == o.curr; }
inline bool operator!=(const UCListIter& o) const { return curr != o.curr; }
inline operator Membership*() const { return curr; }
inline Membership* operator->() const { return curr; }
inline Membership& operator*() const { return *curr; }
};
class CoreExport UserChanList : public interfacebase
{
Membership* head;
size_t siz;
public:
UserChanList() : head(NULL), siz(0) {}
inline UCListIter begin() { return head; }
inline UCListIter end() { return NULL; }
inline void insert(Membership* m)
{
siz++;
if (head)
{
m->u_next = head;
head->u_prev = m;
}
head = m;
}
inline void erase(Membership* m)
{
siz--;
if (head == m)
head = m->u_next;
if (m->u_next)
m->u_next->u_prev = m->u_prev;
if (m->u_prev)
m->u_prev->u_next = m->u_next;
m->u_prev = m->u_next = NULL;
}
inline size_t size() { return siz; }
};
#endif
|