status-dataset-context.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_MGMT_STATUS_DATASET_CONTEXT_HPP
23 #define NDN_MGMT_STATUS_DATASET_CONTEXT_HPP
24 
25 #include "../interest.hpp"
26 #include "../data.hpp"
27 #include "../util/time.hpp"
28 #include "../encoding/encoding-buffer.hpp"
29 #include "control-response.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
void reject(const ControlResponse &resp=ControlResponse().setCode(400))
declare the non-existence of a response
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:66
StatusDatasetContext & setExpiry(const time::milliseconds &expiry)
set expiration duration
represents a dispatcher on server side of NFD Management protocol
Definition: dispatcher.hpp:129
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
represents an Interest packet
Definition: interest.hpp:42
mgmt::ControlResponse ControlResponse
void end()
end the response successfully after appending zero or more blocks
Represents an absolute name.
Definition: name.hpp:42
StatusDatasetContext & setPrefix(const Name &prefix)
change prefix of Data packets
void append(const Block &block)
append a Block to the response
ControlCommand response.
provides a context for generating response to a StatusDataset request
const time::milliseconds & getExpiry() const