Starting Channel class

This commit is contained in:
aortigos
2026-04-17 18:43:52 +02:00
parent c84178c9bc
commit 4faa83eb89
7 changed files with 148 additions and 7 deletions

60
Channel/Channel.cpp Normal file
View File

@@ -0,0 +1,60 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Channel.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/17 14:36:43 by aortigos #+# #+# */
/* Updated: 2026/04/17 14:36:43 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "Channel.hpp"
//////////////////
// Constructors //
//////////////////
Channel::Channel()
{
// std::cout << "Channel default constructor called" << std::endl;
}
Channel::Channel(std::string name) : name(name)
{
}
Channel::~Channel()
{
// std::cout << "Channel destructor called" << std::endl;
}
std::string Channel::getName() const
{
return (this->name);
}
void Channel::addMember(int fd)
{
this->members.push_back(fd);
}
void Channel::removeMember(int fd)
{
for (size_t i = 0; i < this->members.size(); i++)
{
if (this->members[i] == fd)
{
members.erase(members.begin() + 1);
return ;
}
}
}
std::vector<int> Channel::getMembers() const
{
return (this->members);
}

35
Channel/Channel.hpp Normal file
View File

@@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Channel.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/17 14:36:43 by aortigos #+# #+# */
/* Updated: 2026/04/17 14:36:43 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CHANNEL_HPP
# define CHANNEL_HPP
# include <iostream>
# include <vector>
class Channel
{
private:
std::string name;
std::vector<int> members;
public:
Channel();
Channel(std::string name);
~Channel();
std::string getName() const;
void addMember(int fd);
void removeMember(int fd);
std::vector<int> getMembers() const;
};
#endif