NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
status-dataset-context.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_MGMT_STATUS_DATASET_CONTEXT_HPP
23 #define NDN_MGMT_STATUS_DATASET_CONTEXT_HPP
24 
25 #include "ndn-cxx/data.hpp"
26 #include "ndn-cxx/interest.hpp"
29 #include "ndn-cxx/util/time.hpp"
30 
31 namespace ndn {
32 namespace mgmt {
33 
36 class StatusDatasetContext : noncopyable
37 {
38 public:
41  const Name&
42  getPrefix() const;
43 
55  setPrefix(const Name& prefix);
56 
59  const time::milliseconds&
60  getExpiry() const;
61 
69  setExpiry(const time::milliseconds& expiry);
70 
74  void
75  append(const Block& block);
76 
80  void
81  end();
82 
91  void
92  reject(const ControlResponse& resp = ControlResponse().setCode(400));
93 
95  typedef std::function<void(const Name& dataName, const Block& content, time::milliseconds imsFresh,
96  bool isFinalBlock)> DataSender;
97  typedef std::function<void(const ControlResponse& resp)> NackSender;
98 
99  StatusDatasetContext(const Interest& interest,
100  const DataSender& dataSender,
101  const NackSender& nackSender);
102 
103 private:
104  friend class Dispatcher;
105 
106  const Interest& m_interest;
107  DataSender m_dataSender;
108  NackSender m_nackSender;
109  Name m_prefix;
110  time::milliseconds m_expiry;
111 
113  shared_ptr<EncodingBuffer> m_buffer;
114  uint64_t m_segmentNo;
115 
116  enum class State {
117  INITIAL,
118  RESPONDED,
119  FINALIZED
120  };
121  State m_state;
122 };
123 
124 } // namespace mgmt
125 } // namespace ndn
126 
127 #endif // NDN_MGMT_STATUS_DATASET_CONTEXT_HPP
ndn::mgmt::StatusDatasetContext::reject
void reject(const ControlResponse &resp=ControlResponse().setCode(400))
declare the non-existence of a response
Definition: status-dataset-context.cpp:108
ndn::mgmt::StatusDatasetContext::append
void append(const Block &block)
append a Block to the response
Definition: status-dataset-context.cpp:69
ndn::mgmt::StatusDatasetContext::NackSender
std::function< void(const ControlResponse &resp)> NackSender
Definition: status-dataset-context.hpp:97
ndn::nfd::ControlResponse
mgmt::ControlResponse ControlResponse
Definition: control-response.hpp:30
ndn::mgmt::StatusDatasetContext::StatusDatasetContext
StatusDatasetContext(const Interest &interest, const DataSender &dataSender, const NackSender &nackSender)
Definition: status-dataset-context.cpp:118
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::mgmt::StatusDatasetContext::getPrefix
const Name & getPrefix() const
Definition: status-dataset-context.cpp:30
ndn::mgmt::StatusDatasetContext
provides a context for generating response to a StatusDataset request
Definition: status-dataset-context.hpp:37
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
ndn::mgmt::ControlResponse
ControlCommand response.
Definition: control-response.hpp:33
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
ndn::mgmt::StatusDatasetContext::setPrefix
StatusDatasetContext & setPrefix(const Name &prefix)
change prefix of Data packets
Definition: status-dataset-context.cpp:36
interest.hpp
data.hpp
ndn::Block
Represents a TLV element of NDN packet format.
Definition: block.hpp:43
ndn::mgmt::Dispatcher
represents a dispatcher on server side of NFD Management protocol
Definition: dispatcher.hpp:131
ndn::mgmt::StatusDatasetContext::end
void end()
end the response successfully after appending zero or more blocks
Definition: status-dataset-context.cpp:95
ndn::mgmt::StatusDatasetContext::setExpiry
StatusDatasetContext & setExpiry(const time::milliseconds &expiry)
set expiration duration
Definition: status-dataset-context.cpp:62
ndn::mgmt::StatusDatasetContext::DataSender
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const Block time::milliseconds bool isFinalBlock DataSender
Definition: status-dataset-context.hpp:96
time.hpp
ndn::mgmt::StatusDatasetContext::getExpiry
const time::milliseconds & getExpiry() const
Definition: status-dataset-context.cpp:56
ndn::mgmt::StatusDatasetContext::imsFresh
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const Block time::milliseconds imsFresh
Definition: status-dataset-context.hpp:95
encoding-buffer.hpp
control-response.hpp
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::mgmt::StatusDatasetContext::content
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const Block & content
Definition: status-dataset-context.hpp:95