-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathndngetfile.hpp
63 lines (62 loc) · 1.55 KB
/
ndngetfile.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef REPO_NG_TOOLS_NDNGETFILE_HPP
#define REPO_NG_TOOLS_NDNGETFILE_HPP
#include <ndn-cxx/face.hpp>
#include "pipe.h"
namespace repo {
class Consumer : boost::noncopyable
{
public:
Consumer(const std::string& dataName, std::ostream& os, pipe_producer_t* _pro,
bool verbose, bool versioned, bool single,
int interestLifetime, int timeout,
bool mustBeFresh = false)
: m_dataName(dataName)
, m_os(os)
, m_pipe_pro(_pro)
, m_verbose(verbose)
, m_hasVersion(versioned)
, m_isSingle(single)
, m_isFinished(false)
, m_isFirst(true)
, m_interestLifetime(interestLifetime)
, m_timeout(timeout)
, m_nextSegment(0)
, m_totalSize(0)
, m_retryCount(0)
, m_mustBeFresh(mustBeFresh)
{
}
void
run();
private:
void
fetchData(const ndn::Name& name);
void
onVersionedData(const ndn::Interest& interest, ndn::Data& data);
void
onUnversionedData(const ndn::Interest& interest, ndn::Data& data);
void
onTimeout(const ndn::Interest& interest);
void
readData(const ndn::Data& data);
void
fetchNextData(const ndn::Name& name, const ndn::Data& data);
private:
ndn::Face m_face;
ndn::Name m_dataName;
std::ostream& m_os;
pipe_producer_t* m_pipe_pro;
bool m_verbose;
bool m_hasVersion;
bool m_isSingle;
bool m_isFinished;
bool m_isFirst;
ndn::time::milliseconds m_interestLifetime;
ndn::time::milliseconds m_timeout;
uint64_t m_nextSegment;
int m_totalSize;
int m_retryCount;
bool m_mustBeFresh;
};
} // namespace repo
#endif // REPO_NG_TOOLS_NDNGETFILE_HPP