Define ResponseTaker interface for binding response handling
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 20 Jun 2014 21:27:12 +0000 (23:27 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Thu, 3 Jul 2014 12:19:09 +0000 (14:19 +0200)
ResponseTaker is base interface for Protocol class.
Its implementation of appendResponseToBuffer methods throw.
They must be overridden in proper Protocol derivatives.

Change-Id: Ia16008c52f660ebc45143b9e67a741d632c674bc

src/service/CMakeLists.txt
src/service/protocol/Protocol.h
src/service/protocol/ResponseTaker.cpp [moved from src/service/protocol/Protocol.cpp with 79% similarity]
src/service/protocol/ResponseTaker.h [new file with mode: 0644]
src/service/sockets/Descriptor.h

index 349275a..f3a7553 100644 (file)
@@ -22,10 +22,10 @@ SET(CYNARA_SOURCES
     ${CYNARA_SERVICE_PATH}/logic/Logic.cpp
     ${CYNARA_SERVICE_PATH}/main/Cynara.cpp
     ${CYNARA_SERVICE_PATH}/main/main.cpp
-    ${CYNARA_SERVICE_PATH}/protocol/Protocol.cpp
     ${CYNARA_SERVICE_PATH}/protocol/ProtocolAdmin.cpp
     ${CYNARA_SERVICE_PATH}/protocol/ProtocolClient.cpp
     ${CYNARA_SERVICE_PATH}/protocol/ProtocolSignal.cpp
+    ${CYNARA_SERVICE_PATH}/protocol/ResponseTaker.cpp
     ${CYNARA_SERVICE_PATH}/request/CheckRequest.cpp
     ${CYNARA_SERVICE_PATH}/request/Request.cpp
     ${CYNARA_SERVICE_PATH}/request/RequestContext.cpp
index 282450c..21c6426 100644 (file)
 
 #include <common.h>
 
+#include <protocol/ResponseTaker.h>
 #include <request/Request.h>
 #include <response/CheckResponse.h>
 
 namespace Cynara {
 
-class Protocol {
+class Protocol : public ResponseTaker {
 public:
-    Protocol();
-    virtual ~Protocol();
+    Protocol() = default;
+    virtual ~Protocol() = default;
 
     virtual RequestPtr extractRequestFromBuffer(BinaryQueue &bufferQueue) = 0;
-
-    virtual void appendResponseToBuffer(CheckResponse &&response);
 };
 
 typedef std::shared_ptr<Protocol> ProtocolPtr;
similarity index 79%
rename from src/service/protocol/Protocol.cpp
rename to src/service/protocol/ResponseTaker.cpp
index 8f2ca5b..b5fb6ac 100644 (file)
  *    limitations under the License.
  */
 /*
- * @file        Protocol.cpp
+ * @file        ResponseTaker.cpp
  * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
  * @version     1.0
- * @brief       This file implements protocol base class
+ * @brief       This file implements ResponseTaker class
  */
 
+
 #include <common.h>
 #include <exceptions/NotImplementedException.h>
 
-#include "Protocol.h"
+#include "ResponseTaker.h"
 
 namespace Cynara {
 
-Protocol::Protocol() {
-}
-
-Protocol::~Protocol() {
-}
-
-void Protocol::appendResponseToBuffer(CheckResponse &&response UNUSED) {
+void ResponseTaker::appendResponseToBuffer(CheckResponse &&response UNUSED) {
     throw NotImplementedException();
 }
 
diff --git a/src/service/protocol/ResponseTaker.h b/src/service/protocol/ResponseTaker.h
new file mode 100644 (file)
index 0000000..d8a39c5
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file        ResponseTaker.h
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file defines ResponseTaker class
+ */
+
+#ifndef SRC_SERVICE_PROTOCOL_RESPONSETAKER_H_
+#define SRC_SERVICE_PROTOCOL_RESPONSETAKER_H_
+
+#include <response/CheckResponse.h>
+
+namespace Cynara {
+
+class ResponseTaker {
+public:
+    ResponseTaker() = default;
+    virtual ~ResponseTaker() = default;
+
+    virtual void appendResponseToBuffer(CheckResponse &&response);
+};
+
+} // namespace Cynara
+
+#endif /* SRC_SERVICE_PROTOCOL_RESPONSETAKER_H_ */
index 6922562..769abdd 100644 (file)
@@ -60,6 +60,10 @@ public:
         return m_protocol;
     }
 
+    ResponseTaker &responseTaker(void) {
+        return *m_protocol;
+    }
+
     BinaryQueue &writeQueue(void) {
         return m_writeQueue;
     }