Redesign RequestContext to avoid cyclic dependencies
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Wed, 18 Jun 2014 19:49:41 +0000 (21:49 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Thu, 3 Jul 2014 12:19:09 +0000 (14:19 +0200)
Change-Id: Ia3ff6511f279a43c972eb47ec984d16dd13d5a27

src/service/request/Request.h
src/service/request/RequestContext.cpp
src/service/request/RequestContext.h
src/service/sockets/SocketManager.cpp

index e0f4465..14c7743 100644 (file)
@@ -24,7 +24,6 @@
 #define SRC_SERVICE_REQUEST_REQUEST_H_
 
 #include <logic/Logic.h>
-#include "RequestContext.h"
 
 namespace Cynara {
 
@@ -33,7 +32,7 @@ public:
     Request();
     virtual ~Request();
 
-    virtual void execute(Logic *logic, const RequestContext &context) = 0;
+    virtual void execute(Logic *logic, int sourceDesc) = 0;
 };
 
 } // namespace Cynara
index 38361ac..8671f02 100644 (file)
  * @brief       This file implements request context class
  */
 
+#include <main/Cynara.h>
+#include <sockets/SocketManager.h>
+
 #include "RequestContext.h"
 
 namespace Cynara {
 
-RequestContext::RequestContext(int fd) : m_sourceFd(fd) {
+BinaryQueue &RequestContext::resultQueue(int fd) {
+    return Cynara::getSocketManager()->descriptor(fd).writeQueue();
+}
+
+Protocol *RequestContext::protocol(int fd) {
+    return Cynara::getSocketManager()->descriptor(fd).protocol();
 }
 
 } // namespace Cynara
index 75824d2..1d98a33 100644 (file)
 #ifndef SRC_SERVICE_REQUEST_REQUESTCONTEXT_H_
 #define SRC_SERVICE_REQUEST_REQUESTCONTEXT_H_
 
+#include <common.h>
+
+#include <protocol/Protocol.h>
+
 namespace Cynara {
 
+class Protocol;
+
 class RequestContext {
-public:
-    RequestContext(int fd);
 
-    int m_sourceFd;
+public:
+    static BinaryQueue &resultQueue(int fd);
+    static Protocol *protocol(int fd);
 };
 
 } // namespace Cynara
index 51aca80..7e7c079 100644 (file)
@@ -221,7 +221,7 @@ bool SocketManager::handleRead(int fd, const RawBuffer &readbuffer) {
                 break;
 
             LOGD("request extracted");
-            req->execute(Cynara::getLogic(), {fd});
+            req->execute(Cynara::getLogic(), fd);
             delete req;
 
             if (desc.hasDataToWrite())