Use references instead of raw pointer, to store the “parent” object

In Bridge and IrcClient
This commit is contained in:
Florent Le Coz
2015-12-21 14:51:26 +01:00
parent 8ddbe8d3e6
commit 7e2427148e
5 changed files with 75 additions and 77 deletions
+3 -5
View File
@@ -33,7 +33,7 @@ using irc_responder_callback_t = std::function<bool(const std::string& irc_hostn
class Bridge
{
public:
explicit Bridge(const std::string& user_jid, BiboumiComponent* xmpp, std::shared_ptr<Poller> poller);
explicit Bridge(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_ptr<Poller> poller);
~Bridge();
/**
* QUIT all connected IRC servers.
@@ -216,11 +216,9 @@ private:
*/
std::unordered_map<std::string, std::shared_ptr<IrcClient>> irc_clients;
/**
* A raw pointer, because we do not own it, the XMPP component owns us,
* but we still need to communicate with it, when sending messages from
* IRC to XMPP.
* To communicate back with the XMPP component
*/
BiboumiComponent* xmpp;
BiboumiComponent& xmpp;
/**
* Poller, to give it the IrcClients that we spawn, to make it manage
* their sockets.