blob: 5493d2ec529e88f36045b4004d29dac0d39beded [file] [log] [blame]
Shuo Chen09f09bb2014-03-18 15:37:11 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyeve1e6f2a2014-04-25 11:28:12 -07003 * Copyright (c) 2014, Regents of the University of California.
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 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"
Weiqi Shif0330d52014-07-09 10:54:27 -070024#include <ndn-cxx/security/validator-config.hpp>
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070025
Shuo Chen09f09bb2014-03-18 15:37:11 -070026namespace repo {
27
Shuo Chen09f09bb2014-03-18 15:37:11 -070028class DeleteHandle : public BaseHandle
29{
30
31public:
32 class Error : public BaseHandle::Error
33 {
34 public:
35 explicit
36 Error(const std::string& what)
37 : BaseHandle::Error(what)
38 {
39 }
40 };
41
42public:
Weiqi Shif0330d52014-07-09 10:54:27 -070043 DeleteHandle(Face& face, RepoStorage& storageHandle, KeyChain& keyChain,
Shuo Chen028dcd32014-06-21 16:36:44 +080044 Scheduler& scheduler, ValidatorConfig& validator);
Shuo Chen09f09bb2014-03-18 15:37:11 -070045
46 virtual void
47 listen(const Name& prefix);
48
49private:
50 void
51 onInterest(const Name& prefix, const Interest& interest);
52
53 void
54 onRegisterFailed(const Name& prefix, const std::string& reason);
55
56 void
Wentao Shanga8f3c402014-10-30 14:03:27 -070057 onValidated(const std::shared_ptr<const Interest>& interest, const Name& prefix);
Shuo Chen09f09bb2014-03-18 15:37:11 -070058
59 void
Wentao Shanga8f3c402014-10-30 14:03:27 -070060 onValidationFailed(const std::shared_ptr<const Interest>& interest, const std::string& reason);
Shuo Chen09f09bb2014-03-18 15:37:11 -070061
62 /**
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070063 * @todo delete check has not been realized due to the while loop of segmented data deletion.
64 */
Shuo Chen09f09bb2014-03-18 15:37:11 -070065 void
66 onCheckInterest(const Name& prefix, const Interest& interest);
67
68 void
69 onCheckRegisterFailed(const Name& prefix, const std::string& reason);
70
71 void
72 positiveReply(const Interest& interest, const RepoCommandParameter& parameter,
73 uint64_t statusCode, uint64_t nDeletedDatas);
74
75 void
76 negativeReply(const Interest& interest, uint64_t statusCode);
77
78 void
79 processSingleDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
80
81 void
82 processSelectorDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
83
84 void
85 processSegmentDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
86
87private:
Shuo Chen028dcd32014-06-21 16:36:44 +080088 ValidatorConfig& m_validator;
Shuo Chen09f09bb2014-03-18 15:37:11 -070089
90};
91
Alexander Afanasyev39d98072014-05-04 12:46:29 -070092} // namespace repo
Shuo Chen09f09bb2014-03-18 15:37:11 -070093
Alexander Afanasyev39d98072014-05-04 12:46:29 -070094#endif // REPO_HANDLES_DELETE_HANDLE_HPP