Add CodeResponse class - a simple response with just a status 67/24667/2
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Thu, 17 Jul 2014 18:07:16 +0000 (20:07 +0200)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 18 Jul 2014 06:50:50 +0000 (08:50 +0200)
This class shall be used as an answer for administrative requests:
* InsertOrUpdateBucketRequest;
* RemoveBucketRequest;
* SetPoliciesRequest.

Change-Id: I764ff5947a728504227114a1c5297df184a0c4bc

src/common/CMakeLists.txt
src/common/response/CodeResponse.cpp [new file with mode: 0644]
src/common/response/CodeResponse.h [new file with mode: 0644]
src/common/response/ResponseTaker.cpp
src/common/response/ResponseTaker.h
src/common/response/pointers.h

index 39b9e47..d2d5e03 100644 (file)
@@ -38,6 +38,7 @@ SET(COMMON_SOURCES
     ${COMMON_PATH}/request/SetPoliciesRequest.cpp
     ${COMMON_PATH}/request/SignalRequest.cpp
     ${COMMON_PATH}/response/CheckResponse.cpp
+    ${COMMON_PATH}/response/CodeResponse.cpp
     ${COMMON_PATH}/response/ResponseTaker.cpp
     ${COMMON_PATH}/sockets/Socket.cpp
     ${COMMON_PATH}/sockets/SocketClient.cpp
diff --git a/src/common/response/CodeResponse.cpp b/src/common/response/CodeResponse.cpp
new file mode 100644 (file)
index 0000000..5b6f749
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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        CodeResponse.cpp
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file implements class for responding to a request with a code
+ */
+
+#include <memory>
+
+#include "CodeResponse.h"
+
+namespace Cynara {
+
+void CodeResponse::execute(ResponsePtr self, ResponseTakerPtr taker,
+                           RequestContextPtr context) const {
+    taker->execute(context, std::dynamic_pointer_cast<CodeResponse>(self));
+}
+
+} // namespace Cynara
diff --git a/src/common/response/CodeResponse.h b/src/common/response/CodeResponse.h
new file mode 100644 (file)
index 0000000..ec04e03
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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        CodeResponse.h
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file defines class for responding to a request with a code
+ */
+
+#ifndef SRC_COMMON_RESPONSE_CODERESPONSE_H_
+#define SRC_COMMON_RESPONSE_CODERESPONSE_H_
+
+#include <request/pointers.h>
+#include <response/pointers.h>
+#include <response/Response.h>
+
+namespace Cynara {
+
+class CodeResponse : public Response {
+public:
+    enum Code {
+        OK,
+        NO_BUCKET,
+        NOT_ALLOWED
+    };
+
+    const Code m_code;
+
+    CodeResponse(Code code, ProtocolFrameSequenceNumber sequenceNumber) :
+        Response(sequenceNumber), m_code(code) {
+    }
+
+    virtual ~CodeResponse() = default;
+
+    virtual void execute(ResponsePtr self, ResponseTakerPtr taker,
+                         RequestContextPtr context) const;
+};
+
+} // namespace Cynara
+
+#endif /* SRC_COMMON_RESPONSE_CODERESPONSE_H_ */
index 4ad200f..759c023 100644 (file)
@@ -32,4 +32,8 @@ void ResponseTaker::execute(RequestContextPtr context UNUSED, CheckResponsePtr r
     throw NotImplementedException();
 }
 
+void ResponseTaker::execute(RequestContextPtr context UNUSED, CodeResponsePtr response UNUSED) {
+    throw NotImplementedException();
+}
+
 } // namespace Cynara
index a54974c..545f60f 100644 (file)
@@ -34,6 +34,7 @@ public:
     virtual ~ResponseTaker() = default;
 
     virtual void execute(RequestContextPtr context, CheckResponsePtr response);
+    virtual void execute(RequestContextPtr context, CodeResponsePtr response);
 };
 
 } // namespace Cynara
index 3d39d2c..16d0a95 100644 (file)
@@ -30,6 +30,9 @@ namespace Cynara {
 class CheckResponse;
 typedef std::shared_ptr<CheckResponse> CheckResponsePtr;
 
+class CodeResponse;
+typedef std::shared_ptr<CodeResponse> CodeResponsePtr;
+
 class Response;
 typedef std::shared_ptr<Response> ResponsePtr;