From c08d31dbc4f34eef0cce7766e56832e129e707b4 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Fri, 20 Jun 2014 23:27:12 +0200 Subject: [PATCH] Define ResponseTaker interface for binding response handling 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 | 2 +- src/service/protocol/Protocol.h | 9 +++-- .../protocol/{Protocol.cpp => ResponseTaker.cpp} | 15 +++----- src/service/protocol/ResponseTaker.h | 40 ++++++++++++++++++++++ src/service/sockets/Descriptor.h | 4 +++ 5 files changed, 54 insertions(+), 16 deletions(-) rename src/service/protocol/{Protocol.cpp => ResponseTaker.cpp} (79%) create mode 100644 src/service/protocol/ResponseTaker.h diff --git a/src/service/CMakeLists.txt b/src/service/CMakeLists.txt index 349275a..f3a7553 100644 --- a/src/service/CMakeLists.txt +++ b/src/service/CMakeLists.txt @@ -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 diff --git a/src/service/protocol/Protocol.h b/src/service/protocol/Protocol.h index 282450c..21c6426 100644 --- a/src/service/protocol/Protocol.h +++ b/src/service/protocol/Protocol.h @@ -27,19 +27,18 @@ #include +#include #include #include 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 ProtocolPtr; diff --git a/src/service/protocol/Protocol.cpp b/src/service/protocol/ResponseTaker.cpp similarity index 79% rename from src/service/protocol/Protocol.cpp rename to src/service/protocol/ResponseTaker.cpp index 8f2ca5b..b5fb6ac 100644 --- a/src/service/protocol/Protocol.cpp +++ b/src/service/protocol/ResponseTaker.cpp @@ -14,26 +14,21 @@ * limitations under the License. */ /* - * @file Protocol.cpp + * @file ResponseTaker.cpp * @author Lukasz Wojciechowski * @version 1.0 - * @brief This file implements protocol base class + * @brief This file implements ResponseTaker class */ + #include #include -#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 index 0000000..d8a39c5 --- /dev/null +++ b/src/service/protocol/ResponseTaker.h @@ -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 + * @version 1.0 + * @brief This file defines ResponseTaker class + */ + +#ifndef SRC_SERVICE_PROTOCOL_RESPONSETAKER_H_ +#define SRC_SERVICE_PROTOCOL_RESPONSETAKER_H_ + +#include + +namespace Cynara { + +class ResponseTaker { +public: + ResponseTaker() = default; + virtual ~ResponseTaker() = default; + + virtual void appendResponseToBuffer(CheckResponse &&response); +}; + +} // namespace Cynara + +#endif /* SRC_SERVICE_PROTOCOL_RESPONSETAKER_H_ */ diff --git a/src/service/sockets/Descriptor.h b/src/service/sockets/Descriptor.h index 6922562..769abdd 100644 --- a/src/service/sockets/Descriptor.h +++ b/src/service/sockets/Descriptor.h @@ -60,6 +60,10 @@ public: return m_protocol; } + ResponseTaker &responseTaker(void) { + return *m_protocol; + } + BinaryQueue &writeQueue(void) { return m_writeQueue; } -- 2.7.4