22 #ifndef NDN_MEMORY_CONTENT_CACHE_HPP
23 #define NDN_MEMORY_CONTENT_CACHE_HPP
27 #include "../face.hpp"
68 (
const ptr_lib::shared_ptr<const Interest>& interest,
Face& face);
74 const ptr_lib::shared_ptr<const Interest>&
101 return timeoutTimeMilliseconds_ >= 0.0 &&
102 nowMilliseconds >= timeoutTimeMilliseconds_;
106 ptr_lib::shared_ptr<const Interest> interest_;
142 onDataNotFoundForPrefix_[prefix.
toUri()] = onDataNotFound;
146 (prefix, (
const OnInterestCallback&)func_lib::ref(*
this), onRegisterFailed, flags, wireFormat);
148 registeredPrefixIdList_.push_back(registeredPrefixId);
193 (
const ptr_lib::shared_ptr<const Interest>& interest,
Face& face);
205 return storePendingInterestCallback_;
222 std::vector<ptr_lib::shared_ptr<const PendingInterest> >& pendingInterests);
235 (
const ptr_lib::shared_ptr<const Name>& prefix,
236 const ptr_lib::shared_ptr<const Interest>& interest,
Face& face,
237 uint64_t interestFilterId,
238 const ptr_lib::shared_ptr<const InterestFilter>& filter);
252 Content(
const Data& data)
254 : name_(data.getName()), dataEncoding_(data.wireEncode())
258 getName()
const {
return name_; }
261 getDataEncoding()
const {
return dataEncoding_; }
272 class StaleTimeContent :
public Content {
280 StaleTimeContent(
const Data& data);
291 return staleTimeMilliseconds_ <= nowMilliseconds;
301 (
const ptr_lib::shared_ptr<const StaleTimeContent>& x,
302 const ptr_lib::shared_ptr<const StaleTimeContent>& y)
const
304 return x->staleTimeMilliseconds_ < y->staleTimeMilliseconds_;
329 storePendingInterestCallback
330 (
const ptr_lib::shared_ptr<const Name>& prefix,
331 const ptr_lib::shared_ptr<const Interest>& interest,
Face& face,
332 uint64_t interestFilterId,
333 const ptr_lib::shared_ptr<const InterestFilter>& filter)
341 std::map<std::string, OnInterestCallback> onDataNotFoundForPrefix_;
342 std::vector<uint64_t> registeredPrefixIdList_;
343 std::vector<ptr_lib::shared_ptr<const Content> > noStaleTimeCache_;
345 std::deque<ptr_lib::shared_ptr<const StaleTimeContent> > staleTimeCache_;
346 StaleTimeContent::Compare contentCompare_;
348 std::vector<ptr_lib::shared_ptr<const PendingInterest> > pendingInterestTable_;
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:111
PendingInterest(const ptr_lib::shared_ptr< const Interest > &interest, Face &face)
Create a new PendingInterest and set the timeoutTime_ based on the current time and the interest life...
Definition: memory-content-cache.cpp:224
Copyright (C) 2013-2015 Regents of the University of California.
Definition: common.hpp:35
A MemoryContentCache holds a set of Data packets and answers an Interest to return the correct Data p...
Definition: memory-content-cache.hpp:38
std::string toUri(bool includeScheme=false) const
Encode this name as a URI.
Definition: name.cpp:324
void getPendingInterestsForName(const Name &name, std::vector< ptr_lib::shared_ptr< const PendingInterest > > &pendingInterests)
Remove timed-out pending interests, then for each pending interest which matches according to Interes...
Definition: memory-content-cache.cpp:108
The Face class provides the main methods for NDN communication.
Definition: face.hpp:72
void storePendingInterest(const ptr_lib::shared_ptr< const Interest > &interest, Face &face)
Store an interest from an OnInterest callback in the internal pending interest table (normally becaus...
Definition: memory-content-cache.cpp:100
Face & getFace() const
Return the face given to the constructor.
Definition: memory-content-cache.hpp:90
A ForwardingFlags object holds the flags which specify how the forwarding daemon should forward an in...
Definition: forwarding-flags.hpp:34
bool isTimedOut(MillisecondsSince1970 nowMilliseconds) const
Check if this interest is timed out.
Definition: memory-content-cache.hpp:99
const ptr_lib::shared_ptr< const Interest > & getInterest() const
Return the interest given to the constructor.
Definition: memory-content-cache.hpp:75
A PendingInterest holds an interest which onInterest received but could not satisfy.
Definition: memory-content-cache.hpp:57
A Name::Component holds a read-only name component value.
Definition: name.hpp:47
void unregisterAll()
Call Face.removeRegisteredPrefix for all the prefixes given to the registerPrefix method on this Memo...
Definition: memory-content-cache.cpp:44
MemoryContentCache(Face *face, Milliseconds cleanupIntervalMilliseconds=1000.0)
Create a new MemoryContentCache to use the given Face.
Definition: memory-content-cache.cpp:33
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:42
void registerPrefix(const Name &prefix, const OnRegisterFailed &onRegisterFailed, const OnInterestCallback &onDataNotFound=OnInterestCallback(), const ForwardingFlags &flags=ForwardingFlags(), WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Call registerPrefix on the Face given to the constructor so that this MemoryContentCache will answer ...
Definition: memory-content-cache.hpp:137
const OnInterestCallback & getStorePendingInterest()
Return a callback to use for onDataNotFound in registerPrefix which simply calls storePendingInterest...
Definition: memory-content-cache.hpp:203
double MillisecondsSince1970
The calendar time represented as the number of milliseconds since 1/1/1970.
Definition: common.hpp:116
void add(const Data &data)
Add the Data packet to the cache so that it is available to use to answer interests.
Definition: memory-content-cache.cpp:55
func_lib::function< void(const ptr_lib::shared_ptr< const Name > &, const ptr_lib::shared_ptr< const Interest > &, Face &, uint64_t, const ptr_lib::shared_ptr< const InterestFilter > &)> OnInterestCallback
An OnInterestCallback function object is used to pass a callback to setInterestFilter and optionally ...
Definition: face.hpp:59
uint64_t registerPrefix(const Name &prefix, const OnInterestCallback &onInterest, const OnRegisterFailed &onRegisterFailed, const ForwardingFlags &flags=ForwardingFlags(), WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Register prefix with the connected NDN hub and call onInterest when a matching interest is received...
Definition: face.cpp:132
Compare shared_ptrs to Content based only on staleTimeMilliseconds_.
Definition: memory-content-cache.hpp:297
func_lib::function< void(const ptr_lib::shared_ptr< const Name > &)> OnRegisterFailed
An OnRegisterFailed function object is used to report when registerPrefix fails.
Definition: face.hpp:64
MillisecondsSince1970 getTimeoutPeriodStart() const
Return the time when this pending interest entry was created (the time when the unsatisfied interest ...
Definition: memory-content-cache.hpp:84