use shared-ptr more consistently

This commit is contained in:
2025-01-31 08:38:14 -08:00
parent eb01b304e3
commit 7728bc6aee
8 changed files with 64 additions and 64 deletions

View File

@@ -12,7 +12,7 @@
class Challenge : std::enable_shared_from_this<Challenge>
{
Ref<EVP_PKEY> key_;
Connection &connection_;
std::shared_ptr<Connection> connection_;
boost::signals2::scoped_connection slot_;
std::string buffer_;
@@ -20,12 +20,12 @@ class Challenge : std::enable_shared_from_this<Challenge>
auto finish_challenge() -> void;
public:
Challenge(Ref<EVP_PKEY>, Connection &);
Challenge(Ref<EVP_PKEY>, std::shared_ptr<Connection>);
/// @brief Starts the CHALLENGE protocol.
/// @param connection Registered connection.
/// @param user Operator username
/// @param key Operator private RSA key
/// @return Handle to the challenge object.
static auto start(Connection &, std::string_view user, Ref<EVP_PKEY> key) -> std::shared_ptr<Challenge>;
static auto start(std::shared_ptr<Connection>, std::string_view user, Ref<EVP_PKEY> key) -> std::shared_ptr<Challenge>;
};

View File

@@ -32,7 +32,7 @@ struct Chat {
*/
class Client
{
Connection &connection_;
std::shared_ptr<Connection> connection_;
std::string nickname_;
std::string mode_;
@@ -67,23 +67,23 @@ public:
boost::signals2::signal<void(const std::unordered_map<std::string, std::string> &)> sig_cap_ls;
boost::signals2::signal<void(const Chat &)> sig_chat;
Client(Connection &connection)
: connection_{connection}
Client(std::shared_ptr<Connection> connection)
: connection_{std::move(connection)}
, casemap_{Casemap::Rfc1459}
, channel_prefix_{"#&"}
, status_msg_{"+@"}
{
}
auto get_connection() -> Connection & { return connection_; }
auto get_connection() -> Connection & { return *connection_; }
static auto start(Connection &) -> std::shared_ptr<Client>;
static auto start(std::shared_ptr<Connection>) -> std::shared_ptr<Client>;
auto start_sasl(std::unique_ptr<SaslMechanism> mechanism) -> void;
auto get_connection() const -> std::shared_ptr<Connection>
{
return connection_.shared_from_this();
return connection_->shared_from_this();
}
auto get_my_nick() const -> const std::string &;