Add EraseRequest class 86/32486/2
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 19 Dec 2014 08:37:55 +0000 (09:37 +0100)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Mon, 22 Dec 2014 04:58:49 +0000 (05:58 +0100)
EraseRequest class will be used to send request for erasing multiple
policies matching filter key from cynara database.

Change-Id: I32f8ef4449ecfcc2b32061a609a9beb442823c64

src/common/CMakeLists.txt
src/common/request/EraseRequest.cpp [new file with mode: 0644]
src/common/request/EraseRequest.h [new file with mode: 0644]
src/common/request/RequestTaker.cpp
src/common/request/RequestTaker.h
src/common/request/pointers.h
test/CMakeLists.txt

index e01c325..37073ad 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/EraseRequest.cpp
     ${COMMON_PATH}/request/InsertOrUpdateBucketRequest.cpp
     ${COMMON_PATH}/request/ListRequest.cpp
     ${COMMON_PATH}/request/RemoveBucketRequest.cpp
diff --git a/src/common/request/EraseRequest.cpp b/src/common/request/EraseRequest.cpp
new file mode 100644 (file)
index 0000000..54b59fc
--- /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/EraseRequest.cpp
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file implements policies erase request class
+ */
+
+#include <memory>
+
+#include <request/RequestTaker.h>
+
+#include "EraseRequest.h"
+
+namespace Cynara {
+
+void EraseRequest::execute(RequestPtr self, RequestTakerPtr taker,
+                           RequestContextPtr context) const {
+    taker->execute(context, std::dynamic_pointer_cast<EraseRequest>(self));
+}
+
+} // namespace Cynara
diff --git a/src/common/request/EraseRequest.h b/src/common/request/EraseRequest.h
new file mode 100644 (file)
index 0000000..bbbf7d3
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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/EraseRequest.h
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file defines policies erase request class
+ */
+
+#ifndef SRC_COMMON_REQUEST_ERASEREQUEST_H_
+#define SRC_COMMON_REQUEST_ERASEREQUEST_H_
+
+#include <types/PolicyBucketId.h>
+#include <types/PolicyKey.h>
+
+#include <request/pointers.h>
+#include <request/Request.h>
+
+namespace Cynara {
+
+class EraseRequest : public Request {
+public:
+    EraseRequest(const PolicyBucketId &startBucket, bool recursive, const PolicyKey &filter,
+                 ProtocolFrameSequenceNumber sequenceNumber) :
+        Request(sequenceNumber), m_startBucket(startBucket), m_recursive(recursive),
+        m_filter(filter) {
+    }
+
+    virtual ~EraseRequest() {};
+
+    const PolicyBucketId &startBucket(void) const {
+        return m_startBucket;
+    }
+
+    bool recursive(void) const {
+        return m_recursive;
+    }
+
+    const PolicyKey &filter(void) const {
+        return m_filter;
+    }
+
+    virtual void execute(RequestPtr self, RequestTakerPtr taker, RequestContextPtr context) const;
+
+private:
+    PolicyBucketId m_startBucket;
+    bool m_recursive;
+    PolicyKey m_filter;
+};
+
+} // namespace Cynara
+
+#endif /* SRC_COMMON_REQUEST_ERASEREQUEST_H_ */
index 6a9b0df..1233f17 100644 (file)
@@ -50,6 +50,10 @@ void RequestTaker::execute(RequestContextPtr context UNUSED, CheckRequestPtr req
     throw NotImplementedException();
 }
 
+void RequestTaker::execute(RequestContextPtr context UNUSED, EraseRequestPtr request UNUSED) {
+    throw NotImplementedException();
+}
+
 void RequestTaker::execute(RequestContextPtr context UNUSED,
                            InsertOrUpdateBucketRequestPtr request UNUSED) {
     throw NotImplementedException();
index c36b5c9..9d929d9 100644 (file)
@@ -37,8 +37,9 @@ 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, ListRequestPtr request);
+    virtual void execute(RequestContextPtr context, EraseRequestPtr request);
     virtual void execute(RequestContextPtr context, InsertOrUpdateBucketRequestPtr request);
+    virtual void execute(RequestContextPtr context, ListRequestPtr request);
     virtual void execute(RequestContextPtr context, RemoveBucketRequestPtr request);
     virtual void execute(RequestContextPtr context, SetPoliciesRequestPtr request);
     virtual void execute(RequestContextPtr context, SignalRequestPtr request);
index d984c99..865a4c4 100644 (file)
@@ -42,6 +42,9 @@ typedef std::shared_ptr<CancelRequest> CancelRequestPtr;
 class CheckRequest;
 typedef std::shared_ptr<CheckRequest> CheckRequestPtr;
 
+class EraseRequest;
+typedef std::shared_ptr<EraseRequest> EraseRequestPtr;
+
 class InsertOrUpdateBucketRequest;
 typedef std::shared_ptr<InsertOrUpdateBucketRequest> InsertOrUpdateBucketRequestPtr;
 
index 82f26cd..fb9524c 100644 (file)
@@ -29,6 +29,7 @@ SET(CYNARA_SOURCES_FOR_TESTS
     ${CYNARA_SRC}/common/protocol/ProtocolFrameHeader.cpp
     ${CYNARA_SRC}/common/protocol/ProtocolFrameSerializer.cpp
     ${CYNARA_SRC}/common/request/AdminCheckRequest.cpp
+    ${CYNARA_SRC}/common/request/EraseRequest.cpp
     ${CYNARA_SRC}/common/request/InsertOrUpdateBucketRequest.cpp
     ${CYNARA_SRC}/common/request/ListRequest.cpp
     ${CYNARA_SRC}/common/request/RemoveBucketRequest.cpp