From 082dac7a8cb39ec1b005680680c4f3e1e8ddc256 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 14 Sep 2008 23:16:58 +0200 Subject: Verwende statische Instanzen von ConfigManager, ConnectionManager und RequestManager (Singleton) --- src/Common/RequestManager.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/Common/RequestManager.h') diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h index 2ca10e7..795f277 100644 --- a/src/Common/RequestManager.h +++ b/src/Common/RequestManager.h @@ -22,7 +22,10 @@ #include "RequestHandler.h" #include + #include +#include + namespace Mad { namespace Common { @@ -68,9 +71,7 @@ class RequestManager { } }; - // Prevent shallow copy - RequestManager(const RequestManager &o); - RequestManager& operator=(const RequestManager &o); + static std::auto_ptr requestManager; std::map requestMaps; uint16_t requestId; @@ -81,9 +82,23 @@ class RequestManager { return requestId+=2; } + // Prevent shallow copy + RequestManager(const RequestManager &o); + RequestManager& operator=(const RequestManager &o); + + RequestManager(bool core); + void receiveHandler(Net::Connection *connection, const Net::Packet &packet); public: + static void init(bool core) { + requestManager = std::auto_ptr(new RequestManager(core)); + } + + static RequestManager* getRequestManager() { + return requestManager.get(); + } + void registerConnection(Net::Connection *connection); void unregisterConnection(Net::Connection *connection); @@ -95,7 +110,6 @@ class RequestManager { bool sendRequest(Net::Connection *connection, Request *request); - RequestManager(bool core); virtual ~RequestManager(); }; -- cgit v1.2.3