Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 047a6fb | 2017-06-08 16:16:05 +0000 | [diff] [blame^] | 3 | * Copyright (c) 2014-2017, Regents of the University of California. |
Alexander Afanasyev | e1e6f2a | 2014-04-25 11:28:12 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of NDN repo-ng (Next generation of NDN repository). |
| 6 | * See AUTHORS.md for complete list of repo-ng authors and contributors. |
| 7 | * |
| 8 | * repo-ng is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 18 | */ |
| 19 | |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 20 | #ifndef REPO_HANDLES_DELETE_HANDLE_HPP |
| 21 | #define REPO_HANDLES_DELETE_HANDLE_HPP |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 22 | |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 23 | #include "base-handle.hpp" |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 24 | |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 25 | namespace repo { |
| 26 | |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 27 | class DeleteHandle : public BaseHandle |
| 28 | { |
| 29 | |
| 30 | public: |
| 31 | class Error : public BaseHandle::Error |
| 32 | { |
| 33 | public: |
| 34 | explicit |
| 35 | Error(const std::string& what) |
| 36 | : BaseHandle::Error(what) |
| 37 | { |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | public: |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame] | 42 | DeleteHandle(Face& face, RepoStorage& storageHandle, KeyChain& keyChain, |
Junxiao Shi | 047a6fb | 2017-06-08 16:16:05 +0000 | [diff] [blame^] | 43 | Scheduler& scheduler, Validator& validator); |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 44 | |
| 45 | virtual void |
| 46 | listen(const Name& prefix); |
| 47 | |
| 48 | private: |
| 49 | void |
| 50 | onInterest(const Name& prefix, const Interest& interest); |
| 51 | |
| 52 | void |
| 53 | onRegisterFailed(const Name& prefix, const std::string& reason); |
| 54 | |
| 55 | void |
Wentao Shang | a8f3c40 | 2014-10-30 14:03:27 -0700 | [diff] [blame] | 56 | onValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix); |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 57 | |
| 58 | void |
Wentao Shang | a8f3c40 | 2014-10-30 14:03:27 -0700 | [diff] [blame] | 59 | onValidationFailed(const std::shared_ptr<const Interest>& interest, const std::string& reason); |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 60 | |
| 61 | /** |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 62 | * @todo delete check has not been realized due to the while loop of segmented data deletion. |
| 63 | */ |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 64 | void |
| 65 | onCheckInterest(const Name& prefix, const Interest& interest); |
| 66 | |
| 67 | void |
| 68 | onCheckRegisterFailed(const Name& prefix, const std::string& reason); |
| 69 | |
| 70 | void |
| 71 | positiveReply(const Interest& interest, const RepoCommandParameter& parameter, |
| 72 | uint64_t statusCode, uint64_t nDeletedDatas); |
| 73 | |
| 74 | void |
| 75 | negativeReply(const Interest& interest, uint64_t statusCode); |
| 76 | |
| 77 | void |
| 78 | processSingleDeleteCommand(const Interest& interest, RepoCommandParameter& parameter); |
| 79 | |
| 80 | void |
| 81 | processSelectorDeleteCommand(const Interest& interest, RepoCommandParameter& parameter); |
| 82 | |
| 83 | void |
| 84 | processSegmentDeleteCommand(const Interest& interest, RepoCommandParameter& parameter); |
| 85 | |
| 86 | private: |
Junxiao Shi | 047a6fb | 2017-06-08 16:16:05 +0000 | [diff] [blame^] | 87 | Validator& m_validator; |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 88 | |
| 89 | }; |
| 90 | |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 91 | } // namespace repo |
Shuo Chen | 09f09bb | 2014-03-18 15:37:11 -0700 | [diff] [blame] | 92 | |
Alexander Afanasyev | 39d9807 | 2014-05-04 12:46:29 -0700 | [diff] [blame] | 93 | #endif // REPO_HANDLES_DELETE_HANDLE_HPP |