blob: 680e8dca654d2d6a32c9de6733baf4845670d512 [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"
24
25namespace repo {
26
27using std::vector;
28
29class DeleteHandle : public BaseHandle
30{
31
32public:
33 class Error : public BaseHandle::Error
34 {
35 public:
36 explicit
37 Error(const std::string& what)
38 : BaseHandle::Error(what)
39 {
40 }
41 };
42
43public:
44 DeleteHandle(Face& face, StorageHandle& storageHandle, KeyChain& keyChain,
45 Scheduler& scheduler, CommandInterestValidator& validator);
46
47 virtual void
48 listen(const Name& prefix);
49
50private:
51 void
52 onInterest(const Name& prefix, const Interest& interest);
53
54 void
55 onRegisterFailed(const Name& prefix, const std::string& reason);
56
57 void
58 onValidated(const shared_ptr<const Interest>& interest, const Name& prefix);
59
60 void
61 onValidationFailed(const shared_ptr<const Interest>& interest, const Name& prefix);
62
63 /**
64 * @todo delete check has not been realized due to the while loop of segmented data deletion.
65 */
66 void
67 onCheckInterest(const Name& prefix, const Interest& interest);
68
69 void
70 onCheckRegisterFailed(const Name& prefix, const std::string& reason);
71
72 void
73 positiveReply(const Interest& interest, const RepoCommandParameter& parameter,
74 uint64_t statusCode, uint64_t nDeletedDatas);
75
76 void
77 negativeReply(const Interest& interest, uint64_t statusCode);
78
79 void
80 processSingleDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
81
82 void
83 processSelectorDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
84
85 void
86 processSegmentDeleteCommand(const Interest& interest, RepoCommandParameter& parameter);
87
88private:
89 CommandInterestValidator& m_validator;
90
91};
92
Alexander Afanasyev39d98072014-05-04 12:46:29 -070093} // namespace repo
Shuo Chen09f09bb2014-03-18 15:37:11 -070094
Alexander Afanasyev39d98072014-05-04 12:46:29 -070095#endif // REPO_HANDLES_DELETE_HANDLE_HPP