diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-11-15 22:09:20 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-11-16 07:16:37 (GMT) |
commit | 999f19158672bd6c91fa274a9f8e968b84f8a931 (patch) | |
tree | cbcf864514c0abc71414d187f6810619bbf0fea9 /Swiften/Network | |
parent | 0f4fad3929097dca24d1ca92b06283811661e1f4 (diff) | |
download | swift-999f19158672bd6c91fa274a9f8e968b84f8a931.zip swift-999f19158672bd6c91fa274a9f8e968b84f8a931.tar.bz2 |
Pass NetworkFactories as an explicit dependency into client.
Diffstat (limited to 'Swiften/Network')
-rw-r--r-- | Swiften/Network/BoostNetworkFactories.cpp | 23 | ||||
-rw-r--r-- | Swiften/Network/BoostNetworkFactories.h | 37 | ||||
-rw-r--r-- | Swiften/Network/MainBoostIOServiceThread.cpp | 18 | ||||
-rw-r--r-- | Swiften/Network/NetworkFactories.cpp (renamed from Swiften/Network/MainBoostIOServiceThread.h) | 10 | ||||
-rw-r--r-- | Swiften/Network/NetworkFactories.h | 23 | ||||
-rw-r--r-- | Swiften/Network/SConscript | 3 |
6 files changed, 89 insertions, 25 deletions
diff --git a/Swiften/Network/BoostNetworkFactories.cpp b/Swiften/Network/BoostNetworkFactories.cpp new file mode 100644 index 0000000..fc52b08 --- /dev/null +++ b/Swiften/Network/BoostNetworkFactories.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include "Swiften/Network/BoostNetworkFactories.h" +#include "Swiften/Network/BoostTimerFactory.h" +#include "Swiften/Network/BoostConnectionFactory.h" + +namespace Swift { + +BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop) { + timerFactory = new BoostTimerFactory(&ioServiceThread.getIOService(), eventLoop); + connectionFactory = new BoostConnectionFactory(&ioServiceThread.getIOService(), eventLoop); +} + +BoostNetworkFactories::~BoostNetworkFactories() { + delete connectionFactory; + delete timerFactory; +} + +} diff --git a/Swiften/Network/BoostNetworkFactories.h b/Swiften/Network/BoostNetworkFactories.h new file mode 100644 index 0000000..3f8b557 --- /dev/null +++ b/Swiften/Network/BoostNetworkFactories.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include "Swiften/Network/NetworkFactories.h" +#include "Swiften/Network/BoostIOServiceThread.h" + +namespace Swift { + class EventLoop; + + class BoostNetworkFactories : public NetworkFactories { + public: + BoostNetworkFactories(EventLoop* eventLoop); + ~BoostNetworkFactories(); + + virtual TimerFactory* getTimerFactory() const { + return timerFactory; + } + + virtual ConnectionFactory* getConnectionFactory() const { + return connectionFactory; + } + + BoostIOServiceThread* getIOServiceThread() { + return &ioServiceThread; + } + + private: + BoostIOServiceThread ioServiceThread; + TimerFactory* timerFactory; + ConnectionFactory* connectionFactory; + }; +} diff --git a/Swiften/Network/MainBoostIOServiceThread.cpp b/Swiften/Network/MainBoostIOServiceThread.cpp deleted file mode 100644 index 9e4f1fc..0000000 --- a/Swiften/Network/MainBoostIOServiceThread.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include "Swiften/Network/MainBoostIOServiceThread.h" - -#include "Swiften/Network/BoostIOServiceThread.h" - -namespace Swift { - -BoostIOServiceThread& MainBoostIOServiceThread::getInstance() { - static BoostIOServiceThread instance; - return instance; -} - -} diff --git a/Swiften/Network/MainBoostIOServiceThread.h b/Swiften/Network/NetworkFactories.cpp index 29cd4d3..361cb90 100644 --- a/Swiften/Network/MainBoostIOServiceThread.h +++ b/Swiften/Network/NetworkFactories.cpp @@ -4,13 +4,11 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#pragma once +#include "Swiften/Network/NetworkFactories.h" namespace Swift { - class BoostIOServiceThread; - class MainBoostIOServiceThread { - public: - static BoostIOServiceThread& getInstance(); - }; +NetworkFactories::~NetworkFactories() { +} + } diff --git a/Swiften/Network/NetworkFactories.h b/Swiften/Network/NetworkFactories.h new file mode 100644 index 0000000..23e2780 --- /dev/null +++ b/Swiften/Network/NetworkFactories.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +namespace Swift { + class TimerFactory; + class ConnectionFactory; + + /** + * An interface collecting network factories. + */ + class NetworkFactories { + public: + virtual ~NetworkFactories(); + + virtual TimerFactory* getTimerFactory() const = 0; + virtual ConnectionFactory* getConnectionFactory() const = 0; + }; +} diff --git a/Swiften/Network/SConscript b/Swiften/Network/SConscript index b4946f9..f193407 100644 --- a/Swiften/Network/SConscript +++ b/Swiften/Network/SConscript @@ -9,7 +9,6 @@ sourceList = [ "BoostConnection.cpp", "BoostConnectionFactory.cpp", "BoostConnectionServer.cpp", - "MainBoostIOServiceThread.cpp", "BoostIOServiceThread.cpp", "ConnectionFactory.cpp", "ConnectionServer.cpp", @@ -24,6 +23,8 @@ sourceList = [ "PlatformDomainNameServiceQuery.cpp", "StaticDomainNameResolver.cpp", "HostAddress.cpp", + "NetworkFactories.cpp", + "BoostNetworkFactories.cpp", "Timer.cpp", "BoostTimer.cpp"] if myenv.get("HAVE_CARES", False) : |