GameRC (IRC Server)  1.0.0
C++98 기반 IRC 서버 프로젝트
로딩중...
검색중...
일치하는것 없음
Channel.hpp
이 파일의 문서화 페이지로 가기
1/**
2 * @file Channel.hpp
3 * @author Taeil-Nam (nam0314@gmail.com)
4 * @brief Channel 클래스 정의 헤더 파일.
5 * @version 0.1
6 * @date 2024-03-29
7 *
8 * @copyright Copyright (c) 2024
9 *
10 */
11
12#pragma once
13
14#include "../../common.hpp"
15#include "User.hpp"
16
17namespace grc
18{
19
20/**
21 * @class Channel
22 * @brief IRC에서 생성되는 Channel 객체를 정의하는 클래스.
23 */
25{
26public:
27 /**
28 * @brief 채널에 입장 가능한 최대 유저 수의 제한이 없음을 나타낸다.
29 */
30 enum { UNLIMIT = 0 };
31
32public:
33 /**
34 * @brief Channel 객체의 기본 생성자.
35 *
36 * 객체가 생성될 때, 모든 멤버 변수들을 초기화한다.
37 */
38 Channel();
39 /**
40 * @brief Channel 객체의 소멸자.
41 */
42 virtual ~Channel();
43
44 /**
45 * @brief 채널에 유저가 존재하는지 확인하는 함수.
46 *
47 * @param nickname target nickname.
48 * @return true
49 * @return false
50 */
51 bool IsUserExist(const std::string& IN nickname) const;
52 /**
53 * @brief 유저가 채널의 operator인지 확인하는 함수.
54 *
55 * @param nickname target nickname.
56 * @return true
57 * @return false
58 */
59 bool IsOperator(const std::string& IN nickname) const;
60 /**
61 * @brief 유저가 채널에 초대되었는지 확인하는 함수.
62 *
63 * @param nickname target nickname.
64 * @return true
65 * @return false
66 */
67 bool IsInvited(const std::string& IN nickname) const;
68 /**
69 * @brief 채널의 topic을 operator만 설정할 수 있는지 확인하는 함수.
70 *
71 * @return true
72 * @return false
73 */
74 bool IsProtectedTopic() const;
75 /**
76 * @brief 채널이 초대 전용으로 설정되었는지 확인하는 함수.
77 *
78 * @return true
79 * @return false
80 */
81 bool IsInviteOnly() const;
82 /**
83 * @brief 채널에 key가 설정되었는지 확인하는 함수.
84 *
85 * @return true
86 * @return false
87 */
88 bool IsKeyRequired() const;
89 /**
90 * @brief 채널에 최대 입장 유저 수 제한이 설정되었는지 확인하는 함수.
91 *
92 * @return true
93 * @return false
94 */
95 bool IsLimitedMaxUserCount() const;
96 /**
97 * @brief 채널에 유저가 없는지 확인하는 함수.
98 *
99 * @return true
100 * @return false
101 */
102 bool IsChannelEmpty() const;
103
104 /**
105 * @brief Channel 객체의 name을 반환하는 함수.
106 *
107 * @return const std::string& : Channel 객체의 name.
108 */
109 const std::string& GetName() const;
110 /**
111 * @brief Channel 객체의 topic을 반환하는 함수.
112 *
113 * @return const std::string& : Channel 객체의 topic.
114 */
115 const std::string& GetTopic() const;
116 /**
117 * @brief Channel 객체의 max user count을 반환하는 함수.
118 *
119 * @return uint32 : Channel 객체의 max user count.
120 */
121 uint32 GetMaxUserCount() const;
122 /**
123 * @brief Channel 객체의 key를 반환하는 함수.
124 *
125 * @return const std::string& : Channel 객체의 key.
126 */
127 const std::string& GetKey() const;
128 /**
129 * @brief 현재 채널에 존재하는 유저의 수를 반환하는 함수.
130 *
131 * @return uint32 : Channel 객체에 존재하는 유저의 수.
132 */
133 uint32 GetCurrentUserCount() const;
134 /**
135 * @brief 현재 채널에 존재하는 유저 목록을 반환하는 함수.
136 *
137 * @return const std::map<std::string, User>& : 멤버 변수 mUsers 반환.
138 */
139 const std::map<std::string, User>& GetUsers() const;
140 /**
141 * @brief 현재 채널에 존재하는 operator 목록을 반환하는 함수.
142 *
143 * @return const std::map<std::string, User>& : 멤버 변수 mOperators 반환.
144 */
145 const std::map<std::string, User>& GetOperators() const;
146 /**
147 * @brief 현재 채널에 존재하는 유저들의 nickname 목록을 반환하는 함수.
148 *
149 * @return std::string : 공백(' ')으로 분리된 채널에 존재하는 유저 nickname 목록.
150 */
151 std::string GetAllUsersNickname() const;
152 /**
153 * @brief 현재 채널에 설정된 mode를 반환하는 함수.
154 *
155 * @return std::string : 채널에 설정된 mode.
156 */
157 std::string GetModeString() const;
158 /**
159 * @brief 현재 채널에 설정된 mode에 대한 인자들을 반환하는 함수.
160 *
161 * @return std::string : 채널에 설정된 mode에 대한 인자.
162 */
163 std::string GetModeArgument() const;
164
165 /**
166 * @brief Channel 객체의 name을 설정하는 함수.
167 *
168 * @param channelName target channelName.
169 */
170 void SetName(const std::string& IN channelName);
171 /**
172 * @brief Channel 객체의 topic을 설정하는 함수.
173 *
174 * @param topic target topic.
175 */
176 void SetTopic(const std::string& IN topic);
177 /**
178 * @brief Channel 객체의 max user count를 설정하는 함수.
179 *
180 * @param maxUserCount target maxUserCount.
181 */
182 void SetMaxUserCount(uint32 IN maxUserCount);
183 /**
184 * @brief Channel 객체의 key를 설정하는 함수.
185 *
186 * @param key target key.
187 */
188 void SetKey(const std::string& IN key);
189 /**
190 * @brief 채널의 topic을 operator만 설정할 수 있도록 하는 함수.
191 *
192 * 멤버 변수 mbIsProtectedTopic을 true로 설정한다.
193 */
194 void SetProtectedTopic();
195 /**
196 * @brief 채널을 초대 전용으로 설정하는 함수.
197 *
198 * 멤버 변수 mbIsInviteOnly를 true로 설정한다.
199 */
200 void SetInviteOnly();
201 /**
202 * @brief 채널에 입장 가능한 최대 유저 수 제한을 설정하는 함수.
203 *
204 * 멤버 변수 mbIsLimitedMaxUserCount를 true로 설정한다.
205 */
207 /**
208 * @brief 채널의 key를 설정하는 함수.
209 *
210 * 멤버 변수 mbIsKeyRequired를 true로 설정한다.
211 */
212 void SetKeyRequired();
213
214 /**
215 * @brief 채널의 topic을 모두가 설정할 수 있도록 하는 함수.
216 *
217 * 멤버 변수 mbIsProtectedTopic을 false로 설정한다.
218 */
219 void UnsetProtectedTopic();
220 /**
221 * @brief 초대 전용 설정을 해제하는 함수.
222 *
223 * 멤버 변수 mbIsInviteOnly를 false로 설정한다.
224 */
225 void UnsetInviteOnly();
226 /**
227 * @brief 채널에 입장 가능한 최대 유저 수 제한을 해제하는 함수.
228 *
229 * 멤버 변수 mbIsLimitedMaxUserCount를 false로 설정한다.
230 */
232 /**
233 * @brief 채널의 key를 해제하는 함수.
234 *
235 * 멤버 변수 mbIsKeyRequired를 false로 설정한다.
236 */
237 void UnsetKeyRequired();
238
239 /**
240 * @brief 채널에 유저를 추가하는 함수.
241 *
242 * @param nickname 추가할 유저의 nickname.
243 * @param user 추가할 User 객체.
244 */
245 void AddUser(const std::string& IN nickname, const User& IN user);
246 /**
247 * @brief 채널에 operator를 추가하는 함수.
248 *
249 * @param nickname 추가할 operator의 nickname.
250 * @param user 추가할 User 객체.
251 */
252 void AddOperator(const std::string& IN nickname, const User& IN user);
253 /**
254 * @brief 채널에 초대 받은 유저를 추가하는 함수.
255 *
256 * @param nickname 초대 받은 유저의 nickname.
257 * @param user 추가할 User 객체.
258 */
259 void AddInvitedUser(const std::string& IN nickname, const User& IN user);
260 /**
261 * @brief 채널의 topic을 삭제하는 함수.
262 *
263 */
264 void DeleteTopic();
265 /**
266 * @brief 채널의 유저를 삭제하는 함수.
267 *
268 * @param nickname 삭제할 유저의 nickname.
269 */
270 void DeleteUser(const std::string& IN nickname);
271 /**
272 * @brief 채널의 operator를 삭제하는 함수.
273 *
274 * @param nickname 삭제할 operator의 nickname.
275 */
276 void DeleteOperator(const std::string& IN nickname);
277 /**
278 * @brief 채널에 초대 받은 유저를 삭제하는 함수.
279 *
280 * @param nickname 삭제할 유저의 nickname.
281 */
282 void DeleteInvitedUser(const std::string& IN nickname);
283private:
284 /**
285 * @brief Channel 객체의 복사 생성자. (사용되지 않음)
286 *
287 * @param channel 복사할 Channel 객체.
288 */
289 Channel(const Channel& IN channel); // = delete
290 /**
291 * @brief Channel 객체의 복사 대입 연산자. (사용되지 않음)
292 *
293 * @param channel 복사할 Channel 객체.
294 * @return const Channel& : 복사된 Channel 객체.
295 */
296 const Channel& operator=(const Channel& IN channel); // = delete
297
298private:
299 /**
300 * @brief Channel 객체의 이름을 저장하는 멤버 변수.
301 */
302 std::string mName;
303 /**
304 * @brief Channel 객체의 topic을 저장하는 멤버 변수.
305 */
306 std::string mTopic;
307 /**
308 * @brief Channel 객체의 max user count을 저장하는 멤버 변수.
309 */
311 /**
312 * @brief Channel 객체의 key를 저장하는 멤버 변수.
313 */
314 std::string mKey;
315 /**
316 * @brief 채널에 입장한 유저의 목록을 저장하는 멤버 변수.
317 */
318 std::map<std::string, User> mUsers;
319 /**
320 * @brief 채널에 입장한 operator의 목록을 저장하는 멤버 변수.
321 */
322 std::map<std::string, User> mOperators;
323 /**
324 * @brief 채널에 초대된 유저의 목록을 저장하는 멤버 변수.
325 */
326 std::map<std::string, User> mInvitedUsers;
327 /**
328 * @brief 채널의 topic 설정에 operator 권한이 필요한 상태인지를 저장하는 멤버 변수.
329 */
331 /**
332 * @brief 채널이 초대 전용 상태인지 저장하는 멤버 변수.
333 */
335 /**
336 * @brief 채널에 입장 가능한 최대 유저 수 제한이 설정된 상태인지를 저장하는 멤버 변수.
337 */
339 /**
340 * @brief 채널에 key가 설정된 상태인지 저장하는 멤버 변수.
341 */
343};
344
345}
User 클래스 정의 헤더 파일.
IRC에서 생성되는 Channel 객체를 정의하는 클래스.
Definition Channel.hpp:25
const Channel & operator=(const Channel &IN channel)
Channel 객체의 복사 대입 연산자.
const std::string & GetName() const
Channel 객체의 name을 반환하는 함수.
Definition Channel.cpp:92
const std::string & GetTopic() const
Channel 객체의 topic을 반환하는 함수.
Definition Channel.cpp:88
void SetProtectedTopic()
채널의 topic을 operator만 설정할 수 있도록 하는 함수.
Definition Channel.cpp:205
Channel(const Channel &IN channel)
Channel 객체의 복사 생성자.
std::string mTopic
Channel 객체의 topic을 저장하는 멤버 변수.
Definition Channel.hpp:306
std::string GetAllUsersNickname() const
현재 채널에 존재하는 유저들의 nickname 목록을 반환하는 함수.
Definition Channel.cpp:122
bool mbIsProtectedTopic
채널의 topic 설정에 operator 권한이 필요한 상태인지를 저장하는 멤버 변수.
Definition Channel.hpp:330
void UnsetLimitedMaxUserCount()
채널에 입장 가능한 최대 유저 수 제한을 해제하는 함수.
Definition Channel.cpp:235
void DeleteTopic()
채널의 topic을 삭제하는 함수.
Definition Channel.cpp:275
void SetLimitedMaxUserCount()
채널에 입장 가능한 최대 유저 수 제한을 설정하는 함수.
Definition Channel.cpp:215
bool mbIsKeyRequired
채널에 key가 설정된 상태인지 저장하는 멤버 변수.
Definition Channel.hpp:342
std::map< std::string, User > mUsers
채널에 입장한 유저의 목록을 저장하는 멤버 변수.
Definition Channel.hpp:318
std::string GetModeArgument() const
현재 채널에 설정된 mode에 대한 인자들을 반환하는 함수.
Definition Channel.cpp:167
void DeleteOperator(const std::string &IN nickname)
채널의 operator를 삭제하는 함수.
Definition Channel.cpp:291
Channel()
Channel 객체의 기본 생성자.
Definition Channel.cpp:7
void UnsetProtectedTopic()
채널의 topic을 모두가 설정할 수 있도록 하는 함수.
Definition Channel.cpp:225
const std::map< std::string, User > & GetOperators() const
현재 채널에 존재하는 operator 목록을 반환하는 함수.
Definition Channel.cpp:117
bool IsChannelEmpty() const
채널에 유저가 없는지 확인하는 함수.
Definition Channel.cpp:76
bool mbIsLimitedMaxUserCount
채널에 입장 가능한 최대 유저 수 제한이 설정된 상태인지를 저장하는 멤버 변수.
Definition Channel.hpp:338
void AddInvitedUser(const std::string &IN nickname, const User &IN user)
채널에 초대 받은 유저를 추가하는 함수.
Definition Channel.cpp:265
void UnsetKeyRequired()
채널의 key를 해제하는 함수.
Definition Channel.cpp:240
void UnsetInviteOnly()
초대 전용 설정을 해제하는 함수.
Definition Channel.cpp:230
std::map< std::string, User > mOperators
채널에 입장한 operator의 목록을 저장하는 멤버 변수.
Definition Channel.hpp:322
void DeleteUser(const std::string &IN nickname)
채널의 유저를 삭제하는 함수.
Definition Channel.cpp:281
bool IsUserExist(const std::string &IN nickname) const
채널에 유저가 존재하는지 확인하는 함수.
Definition Channel.cpp:20
uint32 GetMaxUserCount() const
Channel 객체의 max user count을 반환하는 함수.
Definition Channel.cpp:107
void AddOperator(const std::string &IN nickname, const User &IN user)
채널에 operator를 추가하는 함수.
Definition Channel.cpp:255
@ UNLIMIT
Definition Channel.hpp:30
bool IsInvited(const std::string &IN nickname) const
유저가 채널에 초대되었는지 확인하는 함수.
Definition Channel.cpp:44
bool mbIsInviteOnly
채널이 초대 전용 상태인지 저장하는 멤버 변수.
Definition Channel.hpp:334
virtual ~Channel()
Channel 객체의 소멸자.
Definition Channel.cpp:309
void SetMaxUserCount(uint32 IN maxUserCount)
Channel 객체의 max user count를 설정하는 함수.
Definition Channel.cpp:195
bool IsLimitedMaxUserCount() const
채널에 최대 입장 유저 수 제한이 설정되었는지 확인하는 함수.
Definition Channel.cpp:71
void AddUser(const std::string &IN nickname, const User &IN user)
채널에 유저를 추가하는 함수.
Definition Channel.cpp:245
const std::map< std::string, User > & GetUsers() const
현재 채널에 존재하는 유저 목록을 반환하는 함수.
Definition Channel.cpp:112
bool IsProtectedTopic() const
채널의 topic을 operator만 설정할 수 있는지 확인하는 함수.
Definition Channel.cpp:56
bool IsKeyRequired() const
채널에 key가 설정되었는지 확인하는 함수.
Definition Channel.cpp:66
std::string mName
Channel 객체의 이름을 저장하는 멤버 변수.
Definition Channel.hpp:302
uint32 mMaxUserCount
Channel 객체의 max user count을 저장하는 멤버 변수.
Definition Channel.hpp:310
void SetName(const std::string &IN channelName)
Channel 객체의 name을 설정하는 함수.
Definition Channel.cpp:182
uint32 GetCurrentUserCount() const
현재 채널에 존재하는 유저의 수를 반환하는 함수.
Definition Channel.cpp:102
void DeleteInvitedUser(const std::string &IN nickname)
채널에 초대 받은 유저를 삭제하는 함수.
Definition Channel.cpp:301
void SetTopic(const std::string &IN topic)
Channel 객체의 topic을 설정하는 함수.
Definition Channel.cpp:188
std::map< std::string, User > mInvitedUsers
채널에 초대된 유저의 목록을 저장하는 멤버 변수.
Definition Channel.hpp:326
bool IsOperator(const std::string &IN nickname) const
유저가 채널의 operator인지 확인하는 함수.
Definition Channel.cpp:32
bool IsInviteOnly() const
채널이 초대 전용으로 설정되었는지 확인하는 함수.
Definition Channel.cpp:61
const std::string & GetKey() const
Channel 객체의 key를 반환하는 함수.
Definition Channel.cpp:97
std::string GetModeString() const
현재 채널에 설정된 mode를 반환하는 함수.
Definition Channel.cpp:144
void SetInviteOnly()
채널을 초대 전용으로 설정하는 함수.
Definition Channel.cpp:210
void SetKey(const std::string &IN key)
Channel 객체의 key를 설정하는 함수.
Definition Channel.cpp:200
std::string mKey
Channel 객체의 key를 저장하는 멤버 변수.
Definition Channel.hpp:314
void SetKeyRequired()
채널의 key를 설정하는 함수.
Definition Channel.cpp:220
IRC에서 생성되는 User 객체를 정의하는 클래스.
Definition User.hpp:26
Definition Earth.cpp:12