20 #ifndef NDN_CONTENT_STORE_IMPL_H_    21 #define NDN_CONTENT_STORE_IMPL_H_    23 #include "ns3/ndnSIM/model/ndn-common.hpp"    27 #include "ns3/packet.h"    28 #include <boost/foreach.hpp>    31 #include "ns3/uinteger.h"    32 #include "ns3/string.h"    34 #include "../../utils/trie/trie-with-policy.hpp"    50   EntryImpl(Ptr<ContentStore> cs, shared_ptr<const Data> data)
    67   typename CS::super::const_iterator
    81 template<
class Policy>
    85       trie_with_policy<Name,
    86                        ndnSIM::smart_pointer_payload_traits<EntryImpl<ContentStoreImpl<Policy>>,
    91     trie_with_policy<Name, ndnSIM::smart_pointer_payload_traits<EntryImpl<ContentStoreImpl<Policy>>,
   105   virtual inline shared_ptr<Data>
   106   Lookup(shared_ptr<const Interest> interest);
   109   Add(shared_ptr<const Data> data);
   115   Print(std::ostream& os) 
const;
   126   virtual Ptr<Entry> Next(Ptr<Entry>);
   128   const typename super::policy_container&
   131     return super::getPolicy();
   134   typename super::policy_container&
   137     return super::getPolicy();
   141   typedef void (*CsEntryCallback)(Ptr<const Entry>);
   145   SetMaxSize(uint32_t maxSize);
   151   static LogComponent g_log; 
   155   TracedCallback<Ptr<const Entry>> m_didAddEntry;
   162 template<
class Policy>
   165 template<
class Policy>
   170     TypeId((
"ns3::ndn::cs::" + Policy::GetName()).c_str())
   174       .AddAttribute(
"MaxSize",
   175                     "Set maximum number of entries in ContentStore. If 0, limit is not enforced",
   178                     MakeUintegerChecker<uint32_t>())
   180       .AddTraceSource(
"DidAddEntry",
   181                       "Trace fired every time entry is successfully added to the cache",
   183                       "ns3::ndn::cs::ContentStoreImpl::CsEntryCallback");
   197     return !m_exclude.isExcluded(comp);
   204 template<
class Policy>
   208   NS_LOG_FUNCTION(
this << interest->getName());
   210   typename super::const_iterator node;
   211   if (interest->getExclude().empty()) {
   212     node = this->deepest_prefix_match(interest->getName());
   215     node = this->deepest_prefix_match_if_next_level(interest->getName(),
   219   if (node != this->end()) {
   220     this->m_cacheHitsTrace(interest, node->payload()->GetData());
   222     shared_ptr<Data> copy = make_shared<Data>(*node->payload()->GetData());
   226     this->m_cacheMissesTrace(interest);
   231 template<
class Policy>
   235   NS_LOG_FUNCTION(
this << data->getName());
   237   Ptr<entry> newEntry = Create<entry>(
this, data);
   238   std::pair<typename super::iterator, bool> result = super::insert(data->getName(), newEntry);
   240   if (result.first != super::end()) {
   242       newEntry->SetTrie(result.first);
   244       m_didAddEntry(newEntry);
   257 template<
class Policy>
   261   for (
typename super::policy_container::const_iterator item = this->getPolicy().begin();
   262        item != this->getPolicy().end(); item++) {
   263     os << item->payload ()->GetName () << std::endl;
   267 template<
class Policy>
   271   this->getPolicy().set_max_size(maxSize);
   274 template<
class Policy>
   278   return this->getPolicy().get_max_size();
   281 template<
class Policy>
   285   return this->getPolicy().size();
   288 template<
class Policy>
   292   typename super::parent_trie::recursive_iterator item(super::getTrie()), end(0);
   293   for (; item != end; item++) {
   294     if (item->payload() == 0)
   302     return item->payload();
   305 template<
class Policy>
   312 template<
class Policy>
   319   typename super::parent_trie::recursive_iterator item(*StaticCast<entry>(from)->
to_iterator()),
   322   for (item++; item != end; item++) {
   323     if (item->payload() == 0)
   331     return item->payload();
   338 #endif // NDN_CONTENT_STORE_IMPL_H_ 
virtual Ptr< Entry > Begin()
Return first element of content store (no order guaranteed) 
 
Copyright (c) 2011-2015 Regents of the University of California. 
 
void SetTrie(typename CS::super::iterator item)
 
virtual shared_ptr< Data > Lookup(shared_ptr< const Interest > interest)
Find corresponding CS entry for the given interest. 
 
EntryImpl(Ptr< ContentStore > cs, shared_ptr< const Data > data)
 
EntryImpl< ContentStoreImpl< Policy > > entry
 
super::policy_container & GetPolicy()
 
static TypeId GetTypeId()
 
ndnSIM::trie_with_policy< Name, ndnSIM::smart_pointer_payload_traits< EntryImpl< ContentStoreImpl< Policy > >, Entry >, Policy > super
 
bool operator()(const name::Component &comp) const 
 
Cache entry implementation with additional references to the base container. 
 
const super::policy_container & GetPolicy() const 
 
CS::super::iterator to_iterator()
 
Table::const_iterator iterator
 
Copyright (c) 2011-2015 Regents of the University of California. 
 
CS::super::const_iterator to_iterator() const 
 
virtual Ptr< Entry > End()
Return item next after last (no order guaranteed) 
 
virtual bool Add(shared_ptr< const Data > data)
Add a new content to the content store. 
 
virtual void Print(std::ostream &os) const 
Print out content store entries. 
 
isNotExcluded(const Exclude &exclude)
 
Component holds a read-only name component value. 
 
Base implementation of NDN content store. 
 
virtual Ptr< Entry > Next(Ptr< Entry >)
 
virtual ~ContentStoreImpl()
 
virtual uint32_t GetSize() const 
Get number of entries in content store. 
 
Base class for NDN content store.