blob: 91ff244ff70883985ba9f43d406cd669566b11cc [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
28using std::vector;
29
30class DeleteHandle : public BaseHandle
31{
32
33public:
34 class Error : public BaseHandle::Error
35 {
36 public:
37 explicit
38 Error(const std::string& what)
39 : BaseHandle::Error(what)
40 {
41 }
42 };
43
44public:
Weiqi Shif0330d52014-07-09 10:54:27 -070045 DeleteHandle(Face& face, RepoStorage& storageHandle, KeyChain& keyChain,
Shuo Chen028dcd32014-06-21 16:36:44 +080046 Scheduler& scheduler, ValidatorConfig& validator);
Shuo Chen09f09bb2014-03-18 15:37:11 -070047
48 virtual void
49 listen(const Name& prefix);
50
51private:
52 void
53 onInterest(const Name& prefix, const Interest& interest);
54
55 void
56 onRegisterFailed(const Name& prefix, const std::string& reason);
57
58 void
59 onValidated(const shared_ptr<const Interest>& interest, const Name& prefix);
60
61 void
Shuo Chen028dcd32014-06-21 16:36:44 +080062 onValidationFailed(const shared_ptr<const Interest>& interest, const string& reason);
Shuo Chen09f09bb2014-03-18 15:37:11 -070063
64 /**
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070065 * @todo delete check has not been realized due to the while loop of segmented data deletion.
66 */
Shuo Chen09f09bb2014-03-18 15:37:11 -070067 void
68 onCheckInterest(const Name& prefix, const Interest& interest);
69
70 void
71 onCheckRegisterFailed(const Name& prefix, const std::string& reason);
72
73 void
74 positiveReply(const Interest& interest, const RepoCommandParameter& parameter,
75 uint64_t statusCode, uint64_t nDeletedDatas);
76
77 void
78 negativeReply(const Interest& interest, uint64_t statusCode);
79
80 void
81 processSingleDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
82
83 void
84 processSelectorDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
85
86 void
87 processSegmentDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
88
89private:
Shuo Chen028dcd32014-06-21 16:36:44 +080090 ValidatorConfig& m_validator;
Shuo Chen09f09bb2014-03-18 15:37:11 -070091
92};
93
Alexander Afanasyev39d98072014-05-04 12:46:29 -070094} // namespace repo
Shuo Chen09f09bb2014-03-18 15:37:11 -070095
Alexander Afanasyev39d98072014-05-04 12:46:29 -070096#endif // REPO_HANDLES_DELETE_HANDLE_HPP