blob: 9e64b3d06f704bb6c3252028d19348946895861b [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
20#ifndef REPO_NDN_HANDLE_DELETE_HANDLE_HPP
21#define REPO_NDN_HANDLE_DELETE_HANDLE_HPP
22
23#include "ndn-handle-common.hpp"
24#include "base-handle.hpp"
25
26namespace 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:
45 DeleteHandle(Face& face, StorageHandle& storageHandle, KeyChain& keyChain,
46 Scheduler& scheduler, CommandInterestValidator& validator);
47
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
62 onValidationFailed(const shared_ptr<const Interest>& interest, const Name& prefix);
63
64 /**
65 * @todo delete check has not been realized due to the while loop of segmented data deletion.
66 */
67 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:
90 CommandInterestValidator& m_validator;
91
92};
93
94} //namespace repo
95
96#endif // REPO_NDN_HANDLE_DELETE_HANDLE_HPP