diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-07-08 22:31:29 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-07-08 22:31:29 +0200 |
commit | 1508969d508e41de824d1d1227be708136760cfa (patch) | |
tree | 8950d27e708ac8f0451f14c94c8cf76b0ce15877 /src/Common/RequestManager.h | |
parent | 4cd88a87e66dbbb9be4137de04ad79c97ac5bf2c (diff) | |
download | mad-1508969d508e41de824d1d1227be708136760cfa.tar mad-1508969d508e41de824d1d1227be708136760cfa.zip |
Request-Verarbeitung ?berarbeitet
Diffstat (limited to 'src/Common/RequestManager.h')
-rw-r--r-- | src/Common/RequestManager.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h index a5861dd..fde8f3e 100644 --- a/src/Common/RequestManager.h +++ b/src/Common/RequestManager.h @@ -20,7 +20,7 @@ #ifndef MAD_COMMON_REQUESTMANAGER_H_ #define MAD_COMMON_REQUESTMANAGER_H_ -#include "RequestInfo.h" +#include "Request/Request.h" #include <Net/Connection.h> #include <map> @@ -29,7 +29,29 @@ namespace Common { class RequestManager { private: - typedef std::map<unsigned short,RequestInfo> RequestMap; + class RequestMap : private std::map<unsigned short,Request::Request*> { + public: + ~RequestMap() { + for(iterator it = begin(); it != end(); ++it) + delete it->second; + } + + bool addRequest(unsigned short id, Request::Request *info) { + return insert(std::make_pair(id, info)).second; + } + + Request::Request* findRequest(unsigned short id) { + iterator it = find(id); + if(it == end()) + return 0; + + return it->second; + } + + bool deleteRequest(unsigned short id) { + return erase(id); + } + }; std::map<Net::Connection*,RequestMap> requestMap; unsigned short requestId; @@ -51,7 +73,7 @@ class RequestManager { requestMap.erase(connection); } - bool sendRequest(Net::Connection *connection, RequestInfo requestData); + bool sendRequest(Net::Connection *connection, Request::Request *request); RequestManager() : requestId(0) {} |