Add CheckRequest class
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Wed, 18 Jun 2014 19:54:42 +0000 (21:54 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Thu, 3 Jul 2014 12:19:09 +0000 (14:19 +0200)
Change-Id: I98ecece4473f9806e6515320402e607f8d6dfffb

src/service/CMakeLists.txt
src/service/request/CheckRequest.cpp [new file with mode: 0644]
src/service/request/CheckRequest.h [new file with mode: 0644]

index e980a11..349275a 100644 (file)
@@ -26,6 +26,7 @@ SET(CYNARA_SOURCES
     ${CYNARA_SERVICE_PATH}/protocol/ProtocolAdmin.cpp
     ${CYNARA_SERVICE_PATH}/protocol/ProtocolClient.cpp
     ${CYNARA_SERVICE_PATH}/protocol/ProtocolSignal.cpp
+    ${CYNARA_SERVICE_PATH}/request/CheckRequest.cpp
     ${CYNARA_SERVICE_PATH}/request/Request.cpp
     ${CYNARA_SERVICE_PATH}/request/RequestContext.cpp
     ${CYNARA_SERVICE_PATH}/sockets/Descriptor.cpp
diff --git a/src/service/request/CheckRequest.cpp b/src/service/request/CheckRequest.cpp
new file mode 100644 (file)
index 0000000..e5d2295
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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        CheckRequest.cpp
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file implements check request class
+ */
+
+#include <common.h>
+#include <types/PolicyResult.h>
+
+#include <protocol/Protocol.h>
+#include <request/RequestContext.h>
+
+#include "CheckRequest.h"
+
+namespace Cynara {
+
+CheckRequest::CheckRequest(const PolicyKey &key) : m_key(key) {
+}
+
+void CheckRequest::execute(Logic *logic, int sourceDesc) {
+    PolicyResult result = logic->check(sourceDesc, m_key);
+    BinaryQueue &queue = RequestContext::resultQueue(sourceDesc);
+    RequestContext::protocol(sourceDesc)->appendResponseToBuffer(CheckResponse(queue, result));
+}
+
+} // namespace Cynara
diff --git a/src/service/request/CheckRequest.h b/src/service/request/CheckRequest.h
new file mode 100644 (file)
index 0000000..d7b28ab
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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        CheckRequest.h
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file defines check request class
+ */
+
+#ifndef SRC_SERVICE_REQUEST_CHECKREQUEST_H_
+#define SRC_SERVICE_REQUEST_CHECKREQUEST_H_
+
+#include <types/PolicyKey.h>
+
+#include "Request.h"
+
+namespace Cynara {
+
+class CheckRequest : public Request {
+private:
+    PolicyKey m_key;
+
+public:
+    CheckRequest(const PolicyKey &key);
+    virtual ~CheckRequest() = default;
+
+    virtual void execute(Logic *logic, int sourceDesc);
+};
+
+} // namespace Cynara
+
+#endif /* SRC_SERVICE_REQUEST_CHECKREQUEST_H_ */