blob: 265d5ef1d1f13070b7b904f0ddadefe06a30746a [file] [log] [blame]
Shuo Chen09f09bb2014-03-18 15:37:11 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shi047a6fb2017-06-08 16:16:05 +00003 * Copyright (c) 2014-2017, Regents of the University of California.
Alexander Afanasyeve1e6f2a2014-04-25 11:28:12 -07004 *
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 Chen09f09bb2014-03-18 15:37:11 -070018 */
19
Alexander Afanasyev39d98072014-05-04 12:46:29 -070020#ifndef REPO_HANDLES_DELETE_HANDLE_HPP
21#define REPO_HANDLES_DELETE_HANDLE_HPP
Shuo Chen09f09bb2014-03-18 15:37:11 -070022
Shuo Chen09f09bb2014-03-18 15:37:11 -070023#include "base-handle.hpp"
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070024
Shuo Chen09f09bb2014-03-18 15:37:11 -070025namespace repo {
26
Shuo Chen09f09bb2014-03-18 15:37:11 -070027class DeleteHandle : public BaseHandle
28{
29
30public:
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
41public:
Weiqi Shif0330d52014-07-09 10:54:27 -070042 DeleteHandle(Face& face, RepoStorage& storageHandle, KeyChain& keyChain,
Junxiao Shi047a6fb2017-06-08 16:16:05 +000043 Scheduler& scheduler, Validator& validator);
Shuo Chen09f09bb2014-03-18 15:37:11 -070044
45 virtual void
46 listen(const Name& prefix);
47
48private:
49 void
50 onInterest(const Name& prefix, const Interest& interest);
51
52 void
Wentao Shanga8f3c402014-10-30 14:03:27 -070053 onValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix);
Shuo Chen09f09bb2014-03-18 15:37:11 -070054
55 void
Wentao Shanga8f3c402014-10-30 14:03:27 -070056 onValidationFailed(const std::shared_ptr<const Interest>& interest, const std::string& reason);
Shuo Chen09f09bb2014-03-18 15:37:11 -070057
58 /**
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070059 * @todo delete check has not been realized due to the while loop of segmented data deletion.
60 */
Shuo Chen09f09bb2014-03-18 15:37:11 -070061 void
62 onCheckInterest(const Name& prefix, const Interest& interest);
63
64 void
Shuo Chen09f09bb2014-03-18 15:37:11 -070065 positiveReply(const Interest& interest, const RepoCommandParameter& parameter,
66 uint64_t statusCode, uint64_t nDeletedDatas);
67
68 void
69 negativeReply(const Interest& interest, uint64_t statusCode);
70
71 void
72 processSingleDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
73
74 void
75 processSelectorDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
76
77 void
78 processSegmentDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
79
80private:
Junxiao Shi047a6fb2017-06-08 16:16:05 +000081 Validator& m_validator;
Shuo Chen09f09bb2014-03-18 15:37:11 -070082
83};
84
Alexander Afanasyev39d98072014-05-04 12:46:29 -070085} // namespace repo
Shuo Chen09f09bb2014-03-18 15:37:11 -070086
Alexander Afanasyev39d98072014-05-04 12:46:29 -070087#endif // REPO_HANDLES_DELETE_HANDLE_HPP