23 #ifndef NDN_SEGMENT_FETCHER_HPP
24 #define NDN_SEGMENT_FETCHER_HPP
26 #include "../face.hpp"
87 class SegmentFetcher :
public ptr_lib::enable_shared_from_this<SegmentFetcher> {
91 DATA_HAS_NO_SEGMENT = 2,
92 SEGMENT_VERIFICATION_FAILED = 3
95 typedef func_lib::function<bool(const ptr_lib::shared_ptr<Data>&)> VerifySegment;
97 typedef func_lib::function<void(const Blob&)> OnComplete;
99 typedef func_lib::function<void
100 (ErrorCode errorCode,
const std::string& message)> OnError;
139 (
Face& face,
const Interest &baseInterest,
const VerifySegment& verifySegment,
140 const OnComplete& onComplete,
const OnError& onError);
156 (
Face& face,
const VerifySegment& verifySegment,
const OnComplete& onComplete,
157 const OnError& onError)
158 : face_(face), verifySegment_(verifySegment), onComplete_(onComplete),
164 fetchFirstSegment(
const Interest& baseInterest);
168 (
const Interest& originalInterest,
const Name& dataName, uint64_t segment);
172 (
const ptr_lib::shared_ptr<const Interest>& originalInterest,
173 const ptr_lib::shared_ptr<Data>& data);
176 onTimeout(
const ptr_lib::shared_ptr<const Interest>& interest);
184 endsWithSegmentNumber(
Name name)
186 return name.
size() >= 1 &&
187 name.
get(-1).getValue().size() >= 1 &&
188 name.
get(-1).getValue().buf()[0] == 0;
191 std::vector<Blob> contentParts_;
193 VerifySegment verifySegment_;
194 OnComplete onComplete_;
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
static bool DontVerifySegment(const ptr_lib::shared_ptr< Data > &data)
DontVerifySegment may be used in fetch to skip validation of Data packets.
Definition: segment-fetcher.cpp:36
The Face class provides the main methods for NDN communication.
Definition: face.hpp:86
static void fetch(Face &face, const Interest &baseInterest, const VerifySegment &verifySegment, const OnComplete &onComplete, const OnError &onError)
Initiate segment fetching.
Definition: segment-fetcher.cpp:43
SegmentFetcher is a utility class to the fetch latest version of segmented data.
Definition: segment-fetcher.hpp:87
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
size_t size() const
Get the number of components.
Definition: name.hpp:972
An Interest holds a Name and other fields for an interest.
Definition: interest.hpp:41
void get(NameLite &nameLite) const
Set nameLite to point to the components in this name, without copying any memory. ...
Definition: name.cpp:272