NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
in-memory-storage-fifo.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
23 
24 namespace ndn {
25 namespace util {
26 
28  : InMemoryStorage(limit)
29 {
30 }
31 
32 InMemoryStorageFifo::InMemoryStorageFifo(boost::asio::io_service& ioService, size_t limit)
33  : InMemoryStorage(ioService, limit)
34 {
35 }
36 
38 {
39 }
40 
41 void
43 {
44  BOOST_ASSERT(m_cleanupIndex.size() <= size());
45  m_cleanupIndex.insert(entry);
46 }
47 
48 bool
50 {
51  if (!m_cleanupIndex.get<byArrival>().empty()) {
52  CleanupIndex::index<byArrival>::type::iterator it = m_cleanupIndex.get<byArrival>().begin();
53  eraseImpl((*it)->getFullName());
54  m_cleanupIndex.get<byArrival>().erase(it);
55  return true;
56  }
57 
58  return false;
59 }
60 
61 void
63 {
64  CleanupIndex::index<byEntity>::type::iterator it = m_cleanupIndex.get<byEntity>().find(entry);
65  if (it != m_cleanupIndex.get<byEntity>().end())
66  m_cleanupIndex.get<byEntity>().erase(it);
67 }
68 
69 } // namespace util
70 } // namespace ndn
Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< const Data > find(const Interest &interest)
Finds the best match Data for an Interest.
virtual bool evictItem()=0
Removes one Data packet from in-memory storage based on derived class implemented replacement policy...
void eraseImpl(const Name &name)
deletes in-memory storage entries by the Name with implicit digest.
Table::const_iterator iterator
Definition: cs-internal.hpp:41
InMemoryStorage::const_iterator begin() const
Returns begin iterator of the in-memory storage ordering by name with digest.
Represents in-memory storage.
Represents an in-memory storage entry.
virtual void afterInsert(InMemoryStorageEntry *entry)
Update the entry after a entry is successfully inserted, add it to the cleanupIndex.
virtual void beforeErase(InMemoryStorageEntry *entry)
Update the entry or other data structures before a entry is successfully erased, erase it from the cl...
void erase(const Name &prefix, const bool isPrefix=true)
Deletes in-memory storage entry by prefix by default.