21 #ifndef NDN_CONTENT_STORE_IMPL_H_ 
   22 #define NDN_CONTENT_STORE_IMPL_H_ 
   24 #include "ndn-content-store.h" 
   25 #include "ns3/packet.h" 
   26 #include "ns3/ndn-interest.h" 
   27 #include "ns3/ndn-data.h" 
   28 #include <boost/foreach.hpp> 
   31 #include "ns3/uinteger.h" 
   32 #include "ns3/string.h" 
   34 #include "../../utils/trie/trie-with-policy.h" 
   51   EntryImpl (Ptr<ContentStore> cs, Ptr<const Data> data)
 
   58   SetTrie (
typename CS::super::iterator item)
 
   63   typename CS::super::iterator to_iterator () { 
return item_; }
 
   64   typename CS::super::const_iterator to_iterator ()
 const { 
return item_; }
 
   67   typename CS::super::iterator item_;
 
   76 template<
class Policy>
 
   79                                                              ndnSIM::smart_pointer_payload_traits< EntryImpl< ContentStoreImpl< Policy > >, Entry >,
 
   97   virtual inline Ptr<Data>
 
   98   Lookup (Ptr<const Interest> interest);
 
  101   Add (Ptr<const Data> data);
 
  107   Print (std::ostream &os) 
const;
 
  121   const typename super::policy_container &
 
  122   GetPolicy ()
 const { 
return super::getPolicy (); }
 
  124   typename super::policy_container &
 
  125   GetPolicy () { 
return super::getPolicy (); }
 
  129   SetMaxSize (uint32_t maxSize);
 
  135   static LogComponent g_log; 
 
  138   TracedCallback< Ptr<const Entry> > m_didAddEntry;
 
  146 template<
class Policy>
 
  150 template<
class Policy>
 
  154   static TypeId tid = TypeId ((
"ns3::ndn::cs::"+Policy::GetName ()).c_str ())
 
  155     .SetGroupName (
"Ndn")
 
  158     .AddAttribute (
"MaxSize",
 
  159                    "Set maximum number of entries in ContentStore. If 0, limit is not enforced",
 
  163                    MakeUintegerChecker<uint32_t> ())
 
  165     .AddTraceSource (
"DidAddEntry", 
"Trace fired every time entry is successfully added to the cache",
 
  176     : m_exclude (exclude)
 
  190 template<
class Policy>
 
  194   NS_LOG_FUNCTION (
this << interest->GetName ());
 
  197   if (interest->GetExclude () == 0)
 
  199       node = this->deepest_prefix_match (interest->GetName ());
 
  203       node = this->deepest_prefix_match_if_next_level (interest->GetName (),
 
  207   if (node != this->end ())
 
  209       this->m_cacheHitsTrace (interest, node->payload ()->GetData ());
 
  211       Ptr<Data> copy = Create<Data> (*node->payload ()->GetData ());
 
  212       ConstCast<Packet> (copy->GetPayload ())->RemoveAllPacketTags ();
 
  217       this->m_cacheMissesTrace (interest);
 
  222 template<
class Policy>
 
  226   NS_LOG_FUNCTION (
this << data->GetName ());
 
  228   Ptr< entry > newEntry = Create< entry > (
this, data);
 
  229   std::pair< typename super::iterator, bool > result = super::insert (data->GetName (), newEntry);
 
  231   if (result.first != super::end ())
 
  235           newEntry->SetTrie (result.first);
 
  237           m_didAddEntry (newEntry);
 
  251 template<
class Policy>
 
  256        item != this->getPolicy ().end ();
 
  259       os << item->payload ()->GetName () << std::endl;
 
  263 template<
class Policy>
 
  267   this->getPolicy ().set_max_size (maxSize);
 
  270 template<
class Policy>
 
  272 ContentStoreImpl<Policy>::GetMaxSize ()
 const 
  274   return this->getPolicy ().get_max_size ();
 
  277 template<
class Policy>
 
  281   return this->getPolicy ().size ();
 
  284 template<
class Policy>
 
  288   typename super::parent_trie::recursive_iterator item (super::getTrie ()), end (0);
 
  289   for (; item != end; item++)
 
  291       if (item->payload () == 0) 
continue;
 
  298     return item->payload ();
 
  301 template<
class Policy>
 
  308 template<
class Policy>
 
  312   if (from == 0) 
return 0;
 
  314   typename super::parent_trie::recursive_iterator
 
  315     item (*StaticCast< entry > (from)->to_iterator ()),
 
  318   for (item++; item != end; item++)
 
  320       if (item->payload () == 0) 
continue;
 
  327     return item->payload ();
 
  335 #endif // NDN_CONTENT_STORE_IMPL_H_ 
bool isExcluded(const name::Component &comp) const 
Check if name component is excluded. 
 
Base class for NDN content store. 
 
Class to represent Exclude component in NDN interests. 
 
virtual Ptr< Data > Lookup(Ptr< const Interest > interest)
Find corresponding CS entry for the given interest. 
 
virtual bool Add(Ptr< const Data > data)
Add a new content to the content store. 
 
virtual Ptr< Entry > End()
Return item next after last (no order guaranteed) 
 
virtual uint32_t GetSize() const 
Get number of entries in content store. 
 
Base implementation of NDN content store. 
 
Cache entry implementation with additional references to the base container. 
 
Class to representing binary blob of NDN name component. 
 
virtual Ptr< Entry > Begin()
Return first element of content store (no order guaranteed) 
 
virtual void Print(std::ostream &os) const 
Print out content store entries. 
 
Entry(Ptr< ContentStore > cs, Ptr< const Data > data)
Construct content store entry.