Add classes for plugin description listing request and response 95/32695/3
authorZofia Abramowska <z.abramowska@samsung.com>
Mon, 22 Dec 2014 12:19:15 +0000 (13:19 +0100)
committerZofia Abramowska <z.abramowska@samsung.com>
Tue, 23 Dec 2014 16:31:27 +0000 (17:31 +0100)
DescritpionListRequest used for asking cynara for list of internal
and external plugin description.
DescriptionListResponse used for sending this list back to client.

Change-Id: I047747efcf69ecf7f15747e890ffe1b2b98132f1

src/common/CMakeLists.txt
src/common/request/DescriptionListRequest.cpp [new file with mode: 0644]
src/common/request/DescriptionListRequest.h [new file with mode: 0644]
src/common/request/RequestTaker.cpp
src/common/request/RequestTaker.h
src/common/request/pointers.h
src/common/response/DescriptionListResponse.cpp [new file with mode: 0644]
src/common/response/DescriptionListResponse.h [new file with mode: 0644]
src/common/response/ResponseTaker.cpp
src/common/response/ResponseTaker.h
src/common/response/pointers.h

index fe2f727..feb7e80 100644 (file)
@@ -44,6 +44,7 @@ SET(COMMON_SOURCES
     ${COMMON_PATH}/request/AgentRegisterRequest.cpp
     ${COMMON_PATH}/request/CancelRequest.cpp
     ${COMMON_PATH}/request/CheckRequest.cpp
+    ${COMMON_PATH}/request/DescriptionListRequest.cpp
     ${COMMON_PATH}/request/EraseRequest.cpp
     ${COMMON_PATH}/request/InsertOrUpdateBucketRequest.cpp
     ${COMMON_PATH}/request/ListRequest.cpp
@@ -57,6 +58,7 @@ SET(COMMON_SOURCES
     ${COMMON_PATH}/response/CancelResponse.cpp
     ${COMMON_PATH}/response/CheckResponse.cpp
     ${COMMON_PATH}/response/CodeResponse.cpp
+    ${COMMON_PATH}/response/DescriptionListResponse.cpp
     ${COMMON_PATH}/response/ListResponse.cpp
     ${COMMON_PATH}/response/ResponseTaker.cpp
     ${COMMON_PATH}/sockets/Socket.cpp
diff --git a/src/common/request/DescriptionListRequest.cpp b/src/common/request/DescriptionListRequest.cpp
new file mode 100644 (file)
index 0000000..1cea6f5
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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        src/common/request/DescriptionListRequest.cpp
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @version     1.0
+ * @brief       This file implements plugin description list request class
+ */
+
+#include <memory>
+
+#include <request/RequestTaker.h>
+
+#include "DescriptionListRequest.h"
+
+namespace Cynara {
+
+void DescriptionListRequest::execute(RequestPtr self, RequestTakerPtr taker,
+                                     RequestContextPtr context) const {
+    taker->execute(context, std::dynamic_pointer_cast<DescriptionListRequest>(self));
+}
+
+} // namespace Cynara
diff --git a/src/common/request/DescriptionListRequest.h b/src/common/request/DescriptionListRequest.h
new file mode 100644 (file)
index 0000000..53e14ef
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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        src/common/request/DescriptionListRequest.h
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @version     1.0
+ * @brief       This file defines plugin description list request class
+ */
+
+#ifndef SRC_COMMON_REQUEST_DESCRIPTIONLISTREQUEST_H_
+#define SRC_COMMON_REQUEST_DESCRIPTIONLISTREQUEST_H_
+
+#include <request/pointers.h>
+#include <request/Request.h>
+
+namespace Cynara {
+
+class DescriptionListRequest : public Request {
+public:
+    DescriptionListRequest(ProtocolFrameSequenceNumber sequenceNumber) :
+        Request(sequenceNumber) {
+    }
+
+    virtual ~DescriptionListRequest() {};
+
+    virtual void execute(RequestPtr self, RequestTakerPtr taker, RequestContextPtr context) const;
+};
+
+} // namespace Cynara
+
+#endif /* SRC_COMMON_REQUEST_DESCRIPTIONLISTREQUEST_H_ */
index 1233f17..ea25f16 100644 (file)
@@ -55,6 +55,11 @@ void RequestTaker::execute(RequestContextPtr context UNUSED, EraseRequestPtr req
 }
 
 void RequestTaker::execute(RequestContextPtr context UNUSED,
+                           DescriptionListRequestPtr request UNUSED) {
+    throw NotImplementedException();
+}
+
+void RequestTaker::execute(RequestContextPtr context UNUSED,
                            InsertOrUpdateBucketRequestPtr request UNUSED) {
     throw NotImplementedException();
 }
index 9d929d9..e6e3f08 100644 (file)
@@ -37,6 +37,7 @@ public:
     virtual void execute(RequestContextPtr context, AgentRegisterRequestPtr request);
     virtual void execute(RequestContextPtr context, CancelRequestPtr request);
     virtual void execute(RequestContextPtr context, CheckRequestPtr request);
+    virtual void execute(RequestContextPtr context, DescriptionListRequestPtr request);
     virtual void execute(RequestContextPtr context, EraseRequestPtr request);
     virtual void execute(RequestContextPtr context, InsertOrUpdateBucketRequestPtr request);
     virtual void execute(RequestContextPtr context, ListRequestPtr request);
index 865a4c4..be1fdeb 100644 (file)
@@ -42,6 +42,9 @@ typedef std::shared_ptr<CancelRequest> CancelRequestPtr;
 class CheckRequest;
 typedef std::shared_ptr<CheckRequest> CheckRequestPtr;
 
+class DescriptionListRequest;
+typedef std::shared_ptr<DescriptionListRequest> DescriptionListRequestPtr;
+
 class EraseRequest;
 typedef std::shared_ptr<EraseRequest> EraseRequestPtr;
 
diff --git a/src/common/response/DescriptionListResponse.cpp b/src/common/response/DescriptionListResponse.cpp
new file mode 100644 (file)
index 0000000..481913a
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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        src/common/response/DescriptionListResponse.cpp
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @version     1.0
+ * @brief       This file implements plugins description list response class
+ */
+
+#include <memory>
+
+#include <response/ResponseTaker.h>
+
+#include "DescriptionListResponse.h"
+
+namespace Cynara {
+
+void DescriptionListResponse::execute(ResponsePtr self, ResponseTakerPtr taker,
+                                      RequestContextPtr context) const {
+    taker->execute(context, std::dynamic_pointer_cast<DescriptionListResponse>(self));
+}
+
+} // namespace Cynara
diff --git a/src/common/response/DescriptionListResponse.h b/src/common/response/DescriptionListResponse.h
new file mode 100644 (file)
index 0000000..a963775
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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        src/common/response/DescriptionListResponse.h
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @version     1.0
+ * @brief       This file defines response class for plugins description list response
+ */
+
+#ifndef SRC_COMMON_RESPONSE_DESCRIPTIONLISTRESPONSE_H_
+#define SRC_COMMON_RESPONSE_DESCRIPTIONLISTRESPONSE_H_
+
+#include <vector>
+
+#include <types/PolicyDescription.h>
+#include <request/pointers.h>
+#include <response/pointers.h>
+#include <response/Response.h>
+
+namespace Cynara {
+
+class DescriptionListResponse : public Response {
+public:
+    DescriptionListResponse(const std::vector<PolicyDescription> &descriptions,
+                            ProtocolFrameSequenceNumber sequenceNumber) :
+        Response(sequenceNumber), m_descriptions(descriptions) {
+    }
+
+    virtual ~DescriptionListResponse() {};
+
+    virtual void execute(ResponsePtr self, ResponseTakerPtr taker, RequestContextPtr context) const;
+
+    const std::vector<PolicyDescription> &descriptions(void) const {
+        return m_descriptions;
+    }
+
+private:
+    std::vector<PolicyDescription> m_descriptions;
+};
+
+} // namespace Cynara
+
+#endif /* SRC_COMMON_RESPONSE_DESCRIPTIONLISTRESPONSE_H_ */
index af47659..492af6e 100644 (file)
@@ -55,6 +55,11 @@ void ResponseTaker::execute(RequestContextPtr context UNUSED, CodeResponsePtr re
     throw NotImplementedException();
 }
 
+void ResponseTaker::execute(RequestContextPtr context UNUSED,
+                            DescriptionListResponsePtr response UNUSED) {
+    throw NotImplementedException();
+}
+
 void ResponseTaker::execute(RequestContextPtr context UNUSED, ListResponsePtr response UNUSED) {
     throw NotImplementedException();
 }
index 20296af..c642b4f 100644 (file)
@@ -39,6 +39,7 @@ public:
     virtual void execute(RequestContextPtr context, CancelResponsePtr response);
     virtual void execute(RequestContextPtr context, CheckResponsePtr response);
     virtual void execute(RequestContextPtr context, CodeResponsePtr response);
+    virtual void execute(RequestContextPtr context, DescriptionListResponsePtr response);
     virtual void execute(RequestContextPtr context, ListResponsePtr response);
 };
 
index 5e26929..5e90289 100644 (file)
@@ -45,6 +45,9 @@ typedef std::shared_ptr<CheckResponse> CheckResponsePtr;
 class CodeResponse;
 typedef std::shared_ptr<CodeResponse> CodeResponsePtr;
 
+class DescriptionListResponse;
+typedef std::shared_ptr<DescriptionListResponse> DescriptionListResponsePtr;
+
 class ListResponse;
 typedef std::shared_ptr<ListResponse> ListResponsePtr;