diff options
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) {} |