NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
in-memory-storage-lru.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 
33 {
34 }
35 
36 void
38 {
39  BOOST_ASSERT(m_cleanupIndex.size() <= size());
40  InMemoryStorageEntry* ptr = entry;
41  m_cleanupIndex.insert(ptr);
42 }
43 
44 bool
46 {
47  if (!m_cleanupIndex.get<byUsedTime>().empty()) {
48  CleanupIndex::index<byUsedTime>::type::iterator it = m_cleanupIndex.get<byUsedTime>().begin();
49  eraseImpl((*it)->getFullName());
50  m_cleanupIndex.get<byUsedTime>().erase(it);
51  return true;
52  }
53 
54  return false;
55 }
56 
57 void
59 {
60  CleanupIndex::index<byEntity>::type::iterator it = m_cleanupIndex.get<byEntity>().find(entry);
61  if (it != m_cleanupIndex.get<byEntity>().end())
62  m_cleanupIndex.get<byEntity>().erase(it);
63 }
64 
65 void
67 {
68  beforeErase(entry);
69  afterInsert(entry);
70 }
71 
72 } // namespace util
73 } // 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 void beforeErase(InMemoryStorageEntry *entry)
Update the entry or other data structures before a entry is successfully erased, erase it from the cl...
InMemoryStorage::const_iterator begin() const
Returns begin iterator of the in-memory storage ordering by name with digest.
virtual void afterAccess(InMemoryStorageEntry *entry)
Update the entry when the entry is returned by the find() function, update the last used time accordi...
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
Represents in-memory storage.
virtual void afterInsert(InMemoryStorageEntry *entry)
Update the entry after a entry is successfully inserted, add it to the cleanupIndex.
Represents an in-memory storage entry.
void erase(const Name &prefix, const bool isPrefix=true)
Deletes in-memory storage entry by prefix by default.