22 #ifndef NDN_UTIL_IN_MEMORY_STORAGE_HPP 23 #define NDN_UTIL_IN_MEMORY_STORAGE_HPP 25 #include "../common.hpp" 26 #include "../interest.hpp" 27 #include "../data.hpp" 31 #include <boost/multi_index/member.hpp> 32 #include <boost/multi_index_container.hpp> 33 #include <boost/multi_index/ordered_index.hpp> 34 #include <boost/multi_index/sequenced_index.hpp> 35 #include <boost/multi_index/identity.hpp> 36 #include <boost/multi_index/mem_fun.hpp> 52 typedef boost::multi_index_container<
54 boost::multi_index::indexed_by<
57 boost::multi_index::ordered_unique<
58 boost::multi_index::tag<byFullName>,
59 boost::multi_index::const_mem_fun<InMemoryStorageEntry,
const Name&,
104 class Error :
public std::runtime_error
107 Error() :
std::runtime_error(
"Cannot reduce the capacity of the in-memory storage!")
142 shared_ptr<const Data>
156 shared_ptr<const Data>
169 erase(
const Name& prefix,
const bool isPrefix =
true);
208 afterAccess(InMemoryStorageEntry* entry);
238 setCapacity(
size_t nMaxPackets);
254 return size() >= m_capacity;
292 InMemoryStorageEntry*
305 std::stack<InMemoryStorageEntry*> m_freeEntries;
311 #endif // NDN_UTIL_IN_MEMORY_STORAGE_HPP Copyright (c) 2011-2015 Regents of the University of California.
const Data * operator->()
void insert(const Data &data)
Inserts a Data packet.
bool isFull() const
returns true if the in-memory storage uses up the current capacity, false otherwise ...
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
InMemoryStorage(size_t limit=std::numeric_limits< size_t >::max())
shared_ptr< const Data > find(const Interest &interest)
Finds the best match Data for an Interest.
Represents a self-defined const_iterator for the in-memory storage.
represents an Interest packet
bool operator!=(const const_iterator &rhs)
InMemoryStorage::const_iterator end() const
Returns end iterator of the in-memory storage ordering by name with digest.
InMemoryStorage::const_iterator begin() const
Returns begin iterator of the in-memory storage ordering by name with digest.
virtual bool evictItem()=0
Removes one Data packet from in-memory storage based on derived class implemented replacement policy...
virtual void beforeErase(InMemoryStorageEntry *entry)
Update the entry or other data structures before a entry is successfully erased according to derived ...
void eraseImpl(const Name &name)
deletes in-memory storage entries by the Name with implicit digest.
Table::const_iterator iterator
const_iterator & operator++()
Represents in-memory storage.
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
size_t getCapacity() const
returns current capacity of in-memory storage (in packets)
const Name & getFullName() const
Returns the full name (including implicit digest) of the Data packet stored in the in-memory storage ...
Represents an in-memory storage entry.
Name abstraction to represent an absolute name.
const_iterator(const Data *ptr, const Cache *cache, Cache::index< byFullName >::type::iterator it)
virtual ~InMemoryStorage()
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...
InMemoryStorageEntry * selectChild(const Interest &interest, Cache::index< byFullName >::type::iterator startingPoint) const
Implements child selector (leftmost, rightmost, undeclared).
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
Represents an error might be thrown during reduce the current capacity of the in-memory storage throu...
void erase(const Name &prefix, const bool isPrefix=true)
Deletes in-memory storage entry by prefix by default.
void printCache(std::ostream &os) const
Prints contents of the in-memory storage.