Repository navigation
Expand file tree
/
Copy pathChanel.cpp
More file actions
61 lines (52 loc) · 2.96 KB
/
Copy pathChanel.cpp
File metadata and controls
61 lines (52 loc) · 2.96 KB
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
#include "Chanel.hpp"
#include "Client.hpp"
#include <algorithm>
#include <cstddef>
#include <ctime>
Chanel::Chanel(void) : topic(""), limitRequired(false), keyRequired(false), invitOnly(false), reqTopic(true), userLimit(0), whoSetTopic(""), whenTopicSet(0), timestamp(time(NULL)) {}
Chanel::Chanel(std::string &chanelName) : topic(""), limitRequired(false), keyRequired(false), invitOnly(false), reqTopic(true), userLimit(0), whoSetTopic(""), whenTopicSet(0), timestamp(time(NULL)) {
this->setChanelName(chanelName);
};
Chanel::~Chanel(void) {}
std::string Chanel::getChanelName() const { return chanelName; };
std::vector<int>& Chanel::getOperators() { return operators; };
std::vector<int>& Chanel::getMembers() { return members; };
std::string Chanel::getTopic() const { return topic; };
std::string Chanel::getWhoSetTopic() const { return whoSetTopic;};
time_t Chanel::getWhenTopicSet() const { return whenTopicSet;};
size_t Chanel::getUserLimit() const { return userLimit; };
std::string Chanel::getChannelKey() const { return channelKey; };
std::vector<int>& Chanel::getInvitedUsers() { return invitedUsers; };
time_t Chanel::getTimestamp() const { return timestamp; };
void Chanel::setChanelName(std::string val) { chanelName = val; };
void Chanel::setOperators(int val) { operators.push_back(val); };
void Chanel::setMembers(int val) { members.push_back(val); };
void Chanel::setInvitedUsers(int val) { invitedUsers.push_back(val); };
void Chanel::setTopic(std::string val) { topic = val; };
void Chanel::setWhoSetTopic(std::string val) { whoSetTopic = val;};
void Chanel::setWhenTopicSet(time_t val) { whenTopicSet = val;};
void Chanel::setUserLimit(size_t val) { userLimit = val; };
void Chanel::setChannelKey(std::string val) { channelKey = val; };
bool Chanel::getLimitRequired() const { return limitRequired; };
bool Chanel::getKeyRequired() const { return keyRequired; };
bool Chanel::getInvitOnly() const { return invitOnly; };
bool Chanel::getReqTopic() const { return reqTopic; };
void Chanel::setReqTopic(bool val) { reqTopic = val; };
void Chanel::setLimitRequired(bool val) { limitRequired = val; };
void Chanel::setKeyRequired(bool val) { keyRequired = val; };
void Chanel::setInvitOnly(bool val) { invitOnly = val; };
void Chanel::removeOperator(int fd)
{
std::vector<int>::iterator position = std::remove(operators.begin(), operators.end(), fd);
operators.erase(position, operators.end());
}
void Chanel::addInvited(int fd)
{
this->invitedUsers.push_back(fd);
}
bool Chanel::isInvited(int fd)
{
if (std::find(invitedUsers.begin(), invitedUsers.end(), fd) != invitedUsers.end())
return true;
return false;
}