feat(command/ACommand): now an abstract class
This commit is contained in:
parent
fd69a76af1
commit
4598e0f3c1
1 changed files with 19 additions and 6 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/20 23:31:58 by rparodi #+# #+# */
|
/* Created: 2025/05/20 23:31:58 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/05/20 23:49:46 by rparodi ### ########.fr */
|
/* Updated: 2025/05/24 17:41:11 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "user.hpp"
|
#include "user.hpp"
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
|
#include "server.hpp"
|
||||||
|
#include "logs.hpp"
|
||||||
|
|
||||||
namespace cmd
|
namespace cmd
|
||||||
{
|
{
|
||||||
|
|
@ -28,16 +30,25 @@ namespace cmd
|
||||||
*/
|
*/
|
||||||
void dispatch(User *user, Channel *channel, const std::string &line);
|
void dispatch(User *user, Channel *channel, const std::string &line);
|
||||||
std::vector<std::string> split(const std::string &line);
|
std::vector<std::string> split(const std::string &line);
|
||||||
|
template <typename T>
|
||||||
|
T searchList(const std::list<T> &list, const std::string &name);
|
||||||
|
|
||||||
class ICommand {
|
class ACommand {
|
||||||
private:
|
protected:
|
||||||
|
User* _sender;
|
||||||
|
User* _uTarget;
|
||||||
|
Channel *_channel;
|
||||||
|
Channel *_cTarget;
|
||||||
|
Server *_server;
|
||||||
|
std::list<Channel *> _channels;
|
||||||
|
std::list<User *> _users;
|
||||||
std::string _command;
|
std::string _command;
|
||||||
std::vector<std::string> _args;
|
std::vector<std::string> _args;
|
||||||
User _user;
|
|
||||||
public:
|
public:
|
||||||
virtual void execute() = 0;
|
virtual void execute() = 0;
|
||||||
~ICommand();
|
virtual bool checkArgs() = 0;
|
||||||
ICommand(User *user, Channel *channel, const std::string &line);
|
~ACommand();
|
||||||
|
ACommand(User *user, Channel *channel, Server *server, const std::string &line);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Invite;
|
class Invite;
|
||||||
|
|
@ -58,3 +69,5 @@ namespace cmd
|
||||||
class Unknown;
|
class Unknown;
|
||||||
class User;
|
class User;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include "./commands/commands.tpp"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue