summaryrefslogtreecommitdiffstats
path: root/src/Common/RequestManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/RequestManager.h')
-rw-r--r--src/Common/RequestManager.h34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index 2dd892e..fb67748 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -33,8 +33,11 @@
namespace Mad {
namespace Common {
-class RequestManager : boost::noncopyable {
+class Application;
+
+class RequestManager : private boost::noncopyable {
private:
+ friend class Application;
friend class RequestHandler;
class RequestMap : private boost::noncopyable {
@@ -78,18 +81,17 @@ class RequestManager : boost::noncopyable {
return types;
}
- virtual boost::shared_ptr<RequestHandler> createRequestHandler(const std::string &type _UNUSED_PARAMETER_) {
- return boost::shared_ptr<RequestHandler>(new T());
+ virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const std::string &type _UNUSED_PARAMETER_) {
+ return boost::shared_ptr<RequestHandler>(new T(application));
}
};
- static RequestManager requestManager;
+ Application *application;
boost::shared_mutex mutex;
RequestMap requestMap;
- bool server;
boost::uint16_t lastRequestId;
std::map<std::string, boost::shared_ptr<RequestHandlerGroup> > requestHandlerGroups;
@@ -109,29 +111,9 @@ class RequestManager : boost::noncopyable {
bool send(Request *request);
- RequestManager();
+ RequestManager(Application *application0, bool server);
public:
- static RequestManager* get() {
- return &requestManager;
- }
-
- bool isServer() {
- boost::shared_lock<boost::shared_mutex> lock(mutex);
- return server;
- }
-
- void setServer(bool newServer) {
- boost::lock_guard<boost::shared_mutex> lock(mutex);
-
- server = newServer;
-
- if(server)
- lastRequestId &= ~0x01;
- else
- lastRequestId |= 0x01;
- }
-
void registerConnection(Connection *connection);
void unregisterConnection(Connection *connection) {