got rid of some 'new' class creations

pull/14/head
Tom Early 6 years ago
parent 34699ff13e
commit 1591828218

@ -5,9 +5,8 @@
#include <string.h> #include <string.h>
#include "IRCClient.h" #include "IRCClient.h"
#include "IRCProtocol.h"
#include "IRCutils.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) 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; this->app = app;
proto = new IRCProtocol(app, this->callsign, password, update_channel, versionInfo); proto.Init(app, this->callsign, password, update_channel, versionInfo);
recvQ = NULL; recvQ = NULL;
sendQ = NULL; sendQ = NULL;
recv = NULL;
} }
IRCClient::~IRCClient() IRCClient::~IRCClient()
{ {
delete proto;
} }
bool IRCClient::startWork() bool IRCClient::startWork()
@ -87,10 +83,10 @@ void IRCClient::Entry()
recvQ = new IRCMessageQueue(); recvQ = new IRCMessageQueue();
sendQ = new IRCMessageQueue(); sendQ = new IRCMessageQueue();
recv = new IRCReceiver(&ircSock, recvQ); receiver.Init(&ircSock, recvQ);
recv->startWork(); receiver.startWork();
proto->setNetworkReady(true); proto.setNetworkReady(true);
state = 5; state = 5;
timer = 0; timer = 0;
break; break;
@ -104,7 +100,7 @@ void IRCClient::Entry()
if (recvQ->isEOF()) { if (recvQ->isEOF()) {
timer = 0; timer = 0;
state = 6; state = 6;
} else if (proto->processQueues(recvQ, sendQ) == false) { } else if (proto.processQueues(recvQ, sendQ) == false) {
timer = 0; timer = 0;
state = 6; state = 6;
} }
@ -145,12 +141,11 @@ void IRCClient::Entry()
app->userListReset(); app->userListReset();
} }
proto->setNetworkReady(false); proto.setNetworkReady(false);
recv->stopWork(); receiver.stopWork();
sleep(2); sleep(2);
delete recv;
delete recvQ; delete recvQ;
delete sendQ; delete sendQ;

@ -6,8 +6,9 @@
#include "IRCReceiver.h" #include "IRCReceiver.h"
#include "IRCMessageQueue.h" #include "IRCMessageQueue.h"
#include "IRCProtocol.h"
#include "IRCReceiver.h"
class IRCProtocol;
class IRCDDBApp; class IRCDDBApp;
class IRCClient class IRCClient
@ -34,10 +35,10 @@ private:
bool terminateThread; bool terminateThread;
IRCReceiver *recv; IRCReceiver receiver;
IRCMessageQueue *recvQ; IRCMessageQueue *recvQ;
IRCMessageQueue *sendQ; IRCMessageQueue *sendQ;
IRCProtocol *proto; IRCProtocol proto;
IRCDDBApp *app; IRCDDBApp *app;
}; };

@ -6,10 +6,11 @@
#include "IRCutils.h" #include "IRCutils.h"
#include "IRCProtocol.h" #include "IRCProtocol.h"
#include "IRCMessageQueue.h" #include "IRCMessageQueue.h"
#include "IRCDDBApp.h"
#define CIRCDDB_VERSION "2.0.0" #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)); srand(time(NULL));
this->password = password; this->password = password;

@ -1,12 +1,14 @@
#pragma once #pragma once
#include "IRCDDBApp.h"
#include "IRCMessageQueue.h" #include "IRCMessageQueue.h"
class IRCDDBApp;
class IRCProtocol class IRCProtocol
{ {
public: 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(); ~IRCProtocol();

@ -6,7 +6,7 @@
#include "IRCMessage.h" #include "IRCMessage.h"
#include "IRCReceiver.h" #include "IRCReceiver.h"
IRCReceiver::IRCReceiver(CTCPReaderWriterClient *sock, IRCMessageQueue *q) void IRCReceiver::Init(CTCPReaderWriterClient *sock, IRCMessageQueue *q)
{ {
ircSock = sock; ircSock = sock;
recvQ = q; recvQ = q;

@ -6,7 +6,8 @@
class IRCReceiver class IRCReceiver
{ {
public: public:
IRCReceiver(CTCPReaderWriterClient *ircSock, IRCMessageQueue *q); IRCReceiver() {}
void Init(CTCPReaderWriterClient *ircSock, IRCMessageQueue *q);
virtual ~IRCReceiver(); virtual ~IRCReceiver();
bool startWork(); bool startWork();
void stopWork(); void stopWork();

Loading…
Cancel
Save

Powered by TurnKey Linux.