]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/channels.h~
Modified documentation for base classes
[user/henk/code/inspircd.git] / include / channels.h~
1 /*
2
3 $Log$
4 Revision 1.1  2003/01/26 23:52:59  brain
5 Modified documentation for base classes
6 Added base classes
7
8 Revision 1.1.1.1  2003/01/23 19:45:58  brain
9 InspIRCd second source tree
10
11 Revision 1.7  2003/01/22 00:44:26  brain
12 Added documentation comments
13
14 Revision 1.6  2003/01/21 21:11:17  brain
15 Added documentation
16
17 Revision 1.5  2003/01/16 20:11:55  brain
18 fixed some ugly pointer bugs (thanks dblack and a|KK|y!)
19
20 Revision 1.4  2003/01/15 22:47:44  brain
21 Changed user and channel structs to classes (finally)
22
23    
24 */
25
26 #include "inspircd_config.h"
27 #include <time.h>
28 #include <vector>
29
30 #ifndef __CHANNELS_H__
31 #define __CHANNELS_H__
32
33 /** Holds an entry for a ban list, exemption list, or invite list.
34  * This class contains a single element in a channel list, such as a banlist.
35  */
36 class HostItem
37 {
38  public:
39         time_t set_time;
40         char set_by[NICKMAX];
41         char data[MAXBUF];
42
43         HostItem() { /* stub */ }
44         virtual ~HostItem() { /* stub */ }
45 };
46
47 // banlist is inherited from HostList mainly for readability
48 // reasons only
49
50 /** A subclass of HostItem designed to hold channel bans (+b)
51  */
52 class BanItem : public HostItem
53 {
54 };
55
56 // same with this...
57
58 /** A subclass of HostItem designed to hold channel exempts (+e)
59  */
60 class ExemptItem : public HostItem
61 {
62 };
63
64 // and this...
65
66 /** A subclass of HostItem designed to hold channel invites (+I)
67  */
68 class InviteItem : public HostItem
69 {
70 };
71
72
73 /** Holds a complete ban list
74  */
75 typedef vector<BanItem>         BanList;
76
77 /** Holds a complete exempt list
78  */
79 typedef vector<ExemptItem>      ExemptList;
80
81 /** Holds a complete invite list
82  */
83 typedef vector<InviteItem>      InviteList;
84
85 /** Holds all relevent information for a channel.
86  * This class represents a channel, and contains its name, modes, time created, topic, topic set time,
87  * etc, and an instance of the BanList type.
88  */
89 class chanrec
90 {
91  public:
92         /** The channels name.
93          */
94         char name[CHANMAX]; /* channel name */
95         /** Custom modes for the channel.
96          * Plugins may use this field in any way they see fit.
97          */
98         char custom_modes[MAXMODES];     /* modes handled by modules */
99         /** Channel topic.
100          * If this is an empty string, no channel topic is set.
101          */
102         char topic[MAXBUF];
103         /** Creation time.
104          */
105         time_t created;
106         /** Time topic was set.
107          * If no topic was ever set, this will be equal to chanrec::created
108          */
109         time_t topicset;
110         /** The last user to set the topic.
111          * If this member is an empty string, no topic was ever set.
112          */
113         char setby[NICKMAX];
114
115         /** Contains the channel user limit.
116          * If this value is zero, there is no limit in place.
117          */
118         long limit;
119         
120         /** Contains the channel key.
121          * If this value is an empty string, there is no channel key in place.
122          */
123         char key[32];
124         
125         /** Nonzero if the mode +t is set.
126          */
127         short int topiclock;
128         
129         /** Nonzero if the mode +n is set.
130          */
131         short int noexternal;
132         
133         /** Nonzero if the mode +i is set.
134          */
135         short int inviteonly;
136         
137         /** Nonzero if the mode +m is set.
138          */
139         short int moderated;
140         
141         /** Nonzero if the mode +s is set.
142          * This value cannot be set at the same time as chanrec::c_private
143          */
144         short int secret;
145         
146         /** Nonzero if the mode +p is set.
147          * This value cannot be set at the same time as chanrec::secret
148          */
149         short int c_private;
150         
151         /** The list of all bans set on the channel.
152          */
153         BanList bans;
154
155         /** Creates a channel record and initialises it with default values
156          */
157         chanrec()
158         {
159                 strcpy(name,"");
160                 strcpy(custom_modes,"");
161                 strcpy(topic,"");
162                 strcpy(setby,"");
163                 strcpy(key,"");
164                 created = topicset = limit = 0;
165                 topiclock = noexternal = inviteonly = moderated = secret = c_private = false;
166         }
167
168         virtual ~chanrec() { /* stub */ }
169 };
170
171 /* used to hold a channel and a users modes on that channel, e.g. +v, +h, +o
172  * needs to come AFTER struct chanrec */
173
174 #define UCMODE_OP      1
175 #define UCMODE_VOICE   2
176 #define UCMODE_HOP     4
177 #define UCMODE_PROTECT 8
178 #define UCMODE_FOUNDER 16
179  
180 /** Holds a user's modes on a channel
181  * This class associates a users privilages with a channel by creating a pointer link between
182  * a userrec and chanrec class. The uc_modes member holds a bitmask of which privilages the user
183  * has on the channel, such as op, voice, etc.
184  */
185 class ucrec
186 {
187  public:
188         /** Contains a bitmask of the UCMODE_OP ... UCMODE_FOUNDER values.
189          * If this value is zero, the user has no privilages upon the channel.
190          */
191         long uc_modes;
192         
193         /** Points to the channel record where the given modes apply.
194          * If the record is not in use, this value will be NULL.
195          */
196         chanrec *channel;
197
198         ucrec() { /* stub */ }
199         virtual ~ucrec() { /* stub */ }
200 };
201
202 #endif
203