/******************************************************************************/ /* */ /* ::: :::::::: */ /* channel.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 10:34:25 by maldavid #+# #+# */ /* Updated: 2024/01/24 00:42:16 by vvaas ### ########.fr */ /* */ /******************************************************************************/ #ifndef __CHANNEL__ #define __CHANNEL__ #include #include #include #include #include namespace irc { struct ClientCmp { bool operator()(const unstd::SharedPtr& lhs, const unstd::SharedPtr& rhs) const { return lhs.get() < rhs.get(); } }; class Channel { public: Channel(const std::string& name); inline const std::string& getName() const { return _name; } inline const std::string& getPassword() const { return _password; } void addClient(unstd::SharedPtr client); void addClient(unstd::SharedPtr client, bool op); bool removeClient(unstd::SharedPtr client); inline std::size_t getNumberOfClients() const { return _clients.size(); } inline void addOperator(unstd::SharedPtr op) { _operators.insert(op); } inline bool removeOperator(unstd::SharedPtr op) { return _operators.erase(op); } void handleMessage(const std::string& msg, unstd::SharedPtr client) const; inline bool isInviteOnly() const { return _invite_only; } void setTopic(unstd::SharedPtr client, const std::string& new_topic); ~Channel(); private: std::set, ClientCmp> _clients; std::set, ClientCmp> _operators; const std::string _name; std::string _password; std::string _topic; bool _invite_only; bool _topic_op_restrict; }; } #endif