From 874a6473e48ea69c782539558ebb6cd536474f6b Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 13 May 2025 11:23:28 +0200 Subject: [PATCH] feat(server): starting the server class --- include/core/server.hpp | 25 ++++++++++++++++++++++++ sources/core/server.cpp | 42 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 include/core/server.hpp create mode 100644 sources/core/server.cpp diff --git a/include/core/server.hpp b/include/core/server.hpp new file mode 100644 index 0000000..f19a6e1 --- /dev/null +++ b/include/core/server.hpp @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* server.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/05/13 11:06:56 by rparodi #+# #+# */ +/* Updated: 2025/05/13 11:08:41 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include + +class Server { + private: + int _port; + std::string _password; + public: + Server(); + Server(int port, const std::string &password); + ~Server(); +}; diff --git a/sources/core/server.cpp b/sources/core/server.cpp new file mode 100644 index 0000000..62a8052 --- /dev/null +++ b/sources/core/server.cpp @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* server.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */ +/* Updated: 2025/05/13 11:19:18 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "core.hpp" +#include + +/** + * @brief The default constructor of the Server class. + */ +Server::Server() : _port(0), _password("") { + if (DEBUG) + std::cerr << CLR_MAGENTA << "[DEBUG] Thanks to use the constructor with port and password !" << std::endl; + std::cout << CLR_GREY << "[INFO] Server default constructor called" << CLR_RESET << std::endl; +} + +/** + * @brief The constructor of the Server class. + * + * @param port The port given by the user (argv[1]) + * @param password The password given by the user (argv[2]) + * + * @note Thanks to check the port / password before give them to the constructor. + */ +Server::Server(int port, const std::string &password) : _port(port), _password(password) { + std::cout << CLR_GREY << "[INFO] Server constructor called" << CLR_RESET << std::endl; +} + +/** + * @brief The default destructor of the Server class. + */ +Server::~Server() { + std::cout << CLR_GREY << "[INFO] Server destructor called" << CLR_RESET << std::endl; +}