From 15918282184ba9dc227292efe1670b230356c89a Mon Sep 17 00:00:00 2001 From: Tom Early Date: Wed, 18 Mar 2020 09:16:34 -0700 Subject: [PATCH] got rid of some 'new' class creations --- ircddb/IRCClient.cpp | 21 ++++++++------------- ircddb/IRCClient.h | 7 ++++--- ircddb/IRCProtocol.cpp | 3 ++- ircddb/IRCProtocol.h | 6 ++++-- ircddb/IRCReceiver.cpp | 2 +- ircddb/IRCReceiver.h | 3 ++- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ircddb/IRCClient.cpp b/ircddb/IRCClient.cpp index 2ed3d86..0edab22 100644 --- a/ircddb/IRCClient.cpp +++ b/ircddb/IRCClient.cpp @@ -5,9 +5,8 @@ #include #include "IRCClient.h" -#include "IRCProtocol.h" #include "IRCutils.h" - +#include "IRCDDBApp.h" IRCClient::IRCClient(IRCDDBApp *app, const std::string &update_channel, const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo) { @@ -21,17 +20,14 @@ IRCClient::IRCClient(IRCDDBApp *app, const std::string &update_channel, const st this->app = app; - proto = new IRCProtocol(app, this->callsign, password, update_channel, versionInfo); + proto.Init(app, this->callsign, password, update_channel, versionInfo); recvQ = NULL; sendQ = NULL; - - recv = NULL; } IRCClient::~IRCClient() { - delete proto; } bool IRCClient::startWork() @@ -87,10 +83,10 @@ void IRCClient::Entry() recvQ = new IRCMessageQueue(); sendQ = new IRCMessageQueue(); - recv = new IRCReceiver(&ircSock, recvQ); - recv->startWork(); + receiver.Init(&ircSock, recvQ); + receiver.startWork(); - proto->setNetworkReady(true); + proto.setNetworkReady(true); state = 5; timer = 0; break; @@ -104,7 +100,7 @@ void IRCClient::Entry() if (recvQ->isEOF()) { timer = 0; state = 6; - } else if (proto->processQueues(recvQ, sendQ) == false) { + } else if (proto.processQueues(recvQ, sendQ) == false) { timer = 0; state = 6; } @@ -145,12 +141,11 @@ void IRCClient::Entry() app->userListReset(); } - proto->setNetworkReady(false); - recv->stopWork(); + proto.setNetworkReady(false); + receiver.stopWork(); sleep(2); - delete recv; delete recvQ; delete sendQ; diff --git a/ircddb/IRCClient.h b/ircddb/IRCClient.h index 200da5b..0490ec1 100644 --- a/ircddb/IRCClient.h +++ b/ircddb/IRCClient.h @@ -6,8 +6,9 @@ #include "IRCReceiver.h" #include "IRCMessageQueue.h" +#include "IRCProtocol.h" +#include "IRCReceiver.h" -class IRCProtocol; class IRCDDBApp; class IRCClient @@ -34,10 +35,10 @@ private: bool terminateThread; - IRCReceiver *recv; + IRCReceiver receiver; IRCMessageQueue *recvQ; IRCMessageQueue *sendQ; - IRCProtocol *proto; + IRCProtocol proto; IRCDDBApp *app; }; diff --git a/ircddb/IRCProtocol.cpp b/ircddb/IRCProtocol.cpp index 24ca516..e3076cd 100644 --- a/ircddb/IRCProtocol.cpp +++ b/ircddb/IRCProtocol.cpp @@ -6,10 +6,11 @@ #include "IRCutils.h" #include "IRCProtocol.h" #include "IRCMessageQueue.h" +#include "IRCDDBApp.h" #define CIRCDDB_VERSION "2.0.0" -IRCProtocol::IRCProtocol(IRCDDBApp *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo) +void IRCProtocol::Init(IRCDDBApp *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo) { srand(time(NULL)); this->password = password; diff --git a/ircddb/IRCProtocol.h b/ircddb/IRCProtocol.h index ab0c599..f7f9510 100644 --- a/ircddb/IRCProtocol.h +++ b/ircddb/IRCProtocol.h @@ -1,12 +1,14 @@ #pragma once -#include "IRCDDBApp.h" #include "IRCMessageQueue.h" +class IRCDDBApp; class IRCProtocol { public: - IRCProtocol(IRCDDBApp *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo); + IRCProtocol() {} + + void Init(IRCDDBApp *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo); ~IRCProtocol(); diff --git a/ircddb/IRCReceiver.cpp b/ircddb/IRCReceiver.cpp index ae2c12f..e677c84 100644 --- a/ircddb/IRCReceiver.cpp +++ b/ircddb/IRCReceiver.cpp @@ -6,7 +6,7 @@ #include "IRCMessage.h" #include "IRCReceiver.h" -IRCReceiver::IRCReceiver(CTCPReaderWriterClient *sock, IRCMessageQueue *q) +void IRCReceiver::Init(CTCPReaderWriterClient *sock, IRCMessageQueue *q) { ircSock = sock; recvQ = q; diff --git a/ircddb/IRCReceiver.h b/ircddb/IRCReceiver.h index f09c237..cf2ac69 100644 --- a/ircddb/IRCReceiver.h +++ b/ircddb/IRCReceiver.h @@ -6,7 +6,8 @@ class IRCReceiver { public: - IRCReceiver(CTCPReaderWriterClient *ircSock, IRCMessageQueue *q); + IRCReceiver() {} + void Init(CTCPReaderWriterClient *ircSock, IRCMessageQueue *q); virtual ~IRCReceiver(); bool startWork(); void stopWork();