|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
22 #ifndef NDN_IMS_IN_MEMORY_STORAGE_HPP
23 #define NDN_IMS_IN_MEMORY_STORAGE_HPP
31 #include <boost/multi_index_container.hpp>
32 #include <boost/multi_index/identity.hpp>
33 #include <boost/multi_index/mem_fun.hpp>
34 #include <boost/multi_index/member.hpp>
35 #include <boost/multi_index/ordered_index.hpp>
36 #include <boost/multi_index/sequenced_index.hpp>
48 typedef boost::multi_index_container<
50 boost::multi_index::indexed_by<
53 boost::multi_index::ordered_unique<
54 boost::multi_index::tag<byFullName>,
77 Cache::index<byFullName>::type::iterator it);
100 Cache::index<byFullName>::type::iterator m_it;
106 class Error :
public std::runtime_error
110 : std::runtime_error(
"Cannot reduce the capacity of the in-memory storage!")
126 size_t limit = std::numeric_limits<size_t>::max());
159 shared_ptr<const Data>
173 shared_ptr<const Data>
187 erase(
const Name& prefix,
const bool isPrefix =
true);
256 setCapacity(
size_t nMaxPackets);
272 return size() >= m_capacity;
294 freeEntry(Cache::iterator it);
312 Cache::index<byFullName>::type::iterator startingPoint)
const;
319 Cache::index<byFullName>::type::iterator
320 findNextFresh(Cache::index<byFullName>::type::iterator startingPoint)
const;
330 static const time::milliseconds ZERO_WINDOW;
337 const size_t m_initCapacity = 16;
343 std::stack<InMemoryStorageEntry*> m_freeEntries;
345 unique_ptr<scheduler::Scheduler> m_scheduler;
350 #endif // NDN_IMS_IN_MEMORY_STORAGE_HPP
InMemoryStorage::const_iterator begin() const
Returns begin iterator of the in-memory storage ordering by name with digest.
InMemoryStorageEntry * selectChild(const Interest &interest, Cache::index< byFullName >::type::iterator startingPoint) const
Implements child selector (leftmost, rightmost, undeclared).
void insert(const Data &data, const time::milliseconds &mustBeFreshProcessingWindow=INFINITE_WINDOW)
Inserts a Data packet.
shared_ptr< const Data > find(const Interest &interest)
Finds the best match Data for an Interest.
boost::multi_index_container< InMemoryStorageEntry *, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< byFullName >, boost::multi_index::const_mem_fun< InMemoryStorageEntry, const Name &, &InMemoryStorageEntry::getFullName >, std::less< Name > > > > Cache
const_iterator & operator++()
std::ptrdiff_t difference_type
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
void erase(const Name &prefix, const bool isPrefix=true)
Deletes in-memory storage entry by prefix by default.
void eraseImpl(const Name &name)
deletes in-memory storage entries by the Name with implicit digest.
Cache::index< byFullName >::type::iterator findNextFresh(Cache::index< byFullName >::type::iterator startingPoint) const
Get the next iterator (include startingPoint) that satisfies MustBeFresh requirement.
Represents an absolute name.
Represents an in-memory storage entry.
bool isFull() const
returns true if the in-memory storage uses up the current capacity, false otherwise
InMemoryStorage(size_t limit=std::numeric_limits< size_t >::max())
Create a InMemoryStorage with up to limit entries The InMemoryStorage created through this method wil...
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
bool operator!=(const const_iterator &rhs)
static const time::milliseconds INFINITE_WINDOW
virtual bool evictItem()=0
Removes one Data packet from in-memory storage based on derived class implemented replacement policy.
Represents an Interest packet.
std::input_iterator_tag iterator_category
Represents a Data packet.
const Name & getFullName() const
Returns the full name (including implicit digest) of the Data packet stored in the in-memory storage ...
void printCache(std::ostream &os) const
Prints contents of the in-memory storage.
InMemoryStorage::const_iterator end() const
Returns end iterator of the in-memory storage ordering by name with digest.
virtual ~InMemoryStorage()
const_iterator(const Data *ptr, const Cache *cache, Cache::index< byFullName >::type::iterator it)
Represents a self-defined const_iterator for the in-memory storage.
virtual void beforeErase(InMemoryStorageEntry *entry)
Update the entry or other data structures before a entry is successfully erased according to derived ...
bool operator==(const const_iterator &rhs)
virtual void afterInsert(InMemoryStorageEntry *entry)
Update the entry or other data structures after a entry is successfully inserted according to derived...
size_t getCapacity() const
returns current capacity of in-memory storage (in packets)
Represents in-memory storage.
Represents an error might be thrown during reduce the current capacity of the in-memory storage throu...
Copyright (c) 2011-2015 Regents of the University of California.