From 10b2572501ee231523b0ba7a7630e663d2bf340e Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Fri, 19 Dec 2014 09:37:55 +0100 Subject: [PATCH] Add EraseRequest class 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 | 1 + src/common/request/EraseRequest.cpp | 36 ++++++++++++++++++++ src/common/request/EraseRequest.h | 66 +++++++++++++++++++++++++++++++++++++ src/common/request/RequestTaker.cpp | 4 +++ src/common/request/RequestTaker.h | 3 +- src/common/request/pointers.h | 3 ++ test/CMakeLists.txt | 1 + 7 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 src/common/request/EraseRequest.cpp create mode 100644 src/common/request/EraseRequest.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index e01c325..37073ad 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -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 index 0000000..54b59fc --- /dev/null +++ b/src/common/request/EraseRequest.cpp @@ -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 + * @version 1.0 + * @brief This file implements policies erase request class + */ + +#include + +#include + +#include "EraseRequest.h" + +namespace Cynara { + +void EraseRequest::execute(RequestPtr self, RequestTakerPtr taker, + RequestContextPtr context) const { + taker->execute(context, std::dynamic_pointer_cast(self)); +} + +} // namespace Cynara diff --git a/src/common/request/EraseRequest.h b/src/common/request/EraseRequest.h new file mode 100644 index 0000000..bbbf7d3 --- /dev/null +++ b/src/common/request/EraseRequest.h @@ -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 + * @version 1.0 + * @brief This file defines policies erase request class + */ + +#ifndef SRC_COMMON_REQUEST_ERASEREQUEST_H_ +#define SRC_COMMON_REQUEST_ERASEREQUEST_H_ + +#include +#include + +#include +#include + +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_ */ diff --git a/src/common/request/RequestTaker.cpp b/src/common/request/RequestTaker.cpp index 6a9b0df..1233f17 100644 --- a/src/common/request/RequestTaker.cpp +++ b/src/common/request/RequestTaker.cpp @@ -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(); diff --git a/src/common/request/RequestTaker.h b/src/common/request/RequestTaker.h index c36b5c9..9d929d9 100644 --- a/src/common/request/RequestTaker.h +++ b/src/common/request/RequestTaker.h @@ -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); diff --git a/src/common/request/pointers.h b/src/common/request/pointers.h index d984c99..865a4c4 100644 --- a/src/common/request/pointers.h +++ b/src/common/request/pointers.h @@ -42,6 +42,9 @@ typedef std::shared_ptr CancelRequestPtr; class CheckRequest; typedef std::shared_ptr CheckRequestPtr; +class EraseRequest; +typedef std::shared_ptr EraseRequestPtr; + class InsertOrUpdateBucketRequest; typedef std::shared_ptr InsertOrUpdateBucketRequestPtr; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 82f26cd..fb9524c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 -- 2.7.4