Modifying implementation of content store to use new trie
diff --git a/model/ccnx-content-store-lru.cc b/model/ccnx-content-store-lru.cc
index 8c0d777..5546d84 100644
--- a/model/ccnx-content-store-lru.cc
+++ b/model/ccnx-content-store-lru.cc
@@ -33,8 +33,6 @@
 
 NS_OBJECT_ENSURE_REGISTERED (CcnxContentStoreLru);
 
-using namespace __ccnx_private;
-
 TypeId 
 CcnxContentStoreLru::GetTypeId (void)
 {
@@ -57,6 +55,7 @@
 CcnxContentStoreLru::SetMaxSize (uint32_t maxSize)
 {
   m_maxSize = maxSize;
+  m_contentStore.getPolicy ().set_max_size (maxSize);
 }
 
 uint32_t
@@ -73,12 +72,6 @@
  * \ingroup ccnx
  * \brief Typedef for hash index of content store container
  */
-struct CcnxContentStoreByPrefix
-{
-  typedef
-  CcnxContentStoreLruContainer::type::index<i_prefix>::type
-  type;
-};
 
 CcnxContentStoreLru::CcnxContentStoreLru ()
   : m_maxSize (100)
@@ -92,50 +85,45 @@
 CcnxContentStoreLru::Lookup (Ptr<const CcnxInterestHeader> interest)
 {
   NS_LOG_FUNCTION (this << interest->GetName ());
-  CcnxContentStoreLruContainer::type::iterator it = m_contentStore.get<i_prefix> ().find (interest->GetName ());
-  if (it != m_contentStore.end ())
-    {
-      // promote entry to the top
-      m_contentStore.get<i_mru> ().relocate (m_contentStore.get<i_mru> ().begin (),
-                                           m_contentStore.project<i_mru> (it));
 
-      m_cacheHitsTrace (interest, it->GetHeader ());
-      
-      // return fully formed CCNx packet
-      return boost::make_tuple (it->GetFullyFormedCcnxPacket (), it->GetHeader (), it->GetPacket ());
+  /// @todo Change to search with predicate
+  CcnxContentStoreLruContainer::iterator node =
+    m_contentStore.deepest_prefix_match (interest->GetName ());
+  
+  if (node != m_contentStore.end ())
+    {
+      m_cacheHitsTrace (interest, node->payload ()->GetHeader ());
+
+      NS_LOG_DEBUG ("cache hit with " << node->payload ()->GetHeader ()->GetName ());
+      return boost::make_tuple (node->payload ()->GetFullyFormedCcnxPacket (),
+                                node->payload ()->GetHeader (),
+                                node->payload ()->GetPacket ());
     }
-  m_cacheMissesTrace (interest);
-  return boost::tuple<Ptr<Packet>, Ptr<CcnxContentObjectHeader>, Ptr<Packet> > (0, 0, 0);
+  else
+    {
+      NS_LOG_DEBUG ("cache miss for " << interest->GetName ());
+      m_cacheMissesTrace (interest);
+      return boost::tuple<Ptr<Packet>, Ptr<CcnxContentObjectHeader>, Ptr<Packet> > (0, 0, 0);
+    }
 }   
     
 bool 
 CcnxContentStoreLru::Add (Ptr<CcnxContentObjectHeader> header, Ptr<const Packet> packet)
 {
   NS_LOG_FUNCTION (this << header->GetName ());
-  CcnxContentStoreLruContainer::type::iterator it = m_contentStore.get<i_prefix> ().find (header->GetName ());
-  if (it == m_contentStore.end ())
-    { // add entry to the top
-      m_contentStore.get<i_mru> ().push_front (CcnxContentStoreEntry (header, packet));
-      if (m_contentStore.size () > m_maxSize)
-        m_contentStore.get<i_mru> ().pop_back ();
-      return false;
-    }
-  else
-    {
-      /// @todo Wrong!!! Record should be updated and relocated, not just relocated
-      // promote entry to the top
-      m_contentStore.get<i_mru> ().relocate (m_contentStore.get<i_mru> ().begin (),
-                                             m_contentStore.project<i_mru> (it));
-      return true;
-    }
+
+  return
+    m_contentStore
+    .insert (header->GetName (), Create<CcnxContentStoreEntry> (header, packet))
+    .second;
 }
     
 void 
-CcnxContentStoreLru::Print() const
+CcnxContentStoreLru::Print () const
 {
-  BOOST_FOREACH (const CcnxContentStoreEntry &entry, m_contentStore.get<i_mru> ())
+  BOOST_FOREACH (const CcnxContentStoreLruContainer::parent_trie &item, m_contentStore.getPolicy ())
     {
-      NS_LOG_INFO (entry.GetName ());
+      NS_LOG_INFO (item.payload ()->GetName ());
     }
 }
 
diff --git a/model/ccnx-content-store-lru.h b/model/ccnx-content-store-lru.h
index b510646..277290a 100644
--- a/model/ccnx-content-store-lru.h
+++ b/model/ccnx-content-store-lru.h
@@ -23,45 +23,22 @@
 
 #include "ccnx-content-store.h"
 
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/tag.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/sequenced_index.hpp>
-#include <boost/multi_index/hashed_index.hpp>
-#include <boost/multi_index/mem_fun.hpp>
-
 #include "ccnx.h"
 #include "ccnx-name-components-hash-helper.h"
 
+#include "../utils/trie.h"
+
 namespace  ns3
 {
 /**
  * \ingroup ccnx
- * \brief Typedef for content store container implemented as a Boost.MultiIndex container
- *
- * - First index (tag<prefix>) is a unique hash index based on NDN prefix of the stored content.
- * - Second index (tag<mru>) is a sequential index used to maintain up to m_maxSize most recent used (MRU) entries in the content store
- *
- * \see http://www.boost.org/doc/libs/1_46_1/libs/multi_index/doc/ for more information on Boost.MultiIndex library
+ * \brief Typedef for content store container implemented as trie with configurable replacement policy
  */
-struct CcnxContentStoreLruContainer
-{
-  /// @cond include_hidden
-  typedef
-  boost::multi_index::multi_index_container<
-    CcnxContentStoreEntry,
-    boost::multi_index::indexed_by<
-      boost::multi_index::hashed_unique<
-        boost::multi_index::tag<__ccnx_private::i_prefix>,
-        boost::multi_index::const_mem_fun<CcnxContentStoreEntry,
-                                          const CcnxNameComponents&,
-                                          &CcnxContentStoreEntry::GetName>,
-        CcnxPrefixHash>,
-      boost::multi_index::sequenced<boost::multi_index::tag<__ccnx_private::i_mru> >
-      >
-    > type;
-  /// @endcond
-};
+typedef indexed_trie<CcnxNameComponents,
+                     CcnxContentStoreEntry, smart_pointer_payload_traits<CcnxContentStoreEntry>,
+                     lru_policy_traits<CcnxNameComponents,
+                                       CcnxContentStoreEntry,
+                                       smart_pointer_payload_traits<CcnxContentStoreEntry> > > CcnxContentStoreLruContainer;
 
 /**
  * \ingroup ccnx
@@ -116,7 +93,7 @@
    * \brief Content store implemented as a Boost.MultiIndex container
    * \internal
    */
-  CcnxContentStoreLruContainer::type m_contentStore;
+  CcnxContentStoreLruContainer m_contentStore;
 };
 
 } //namespace ns3
diff --git a/model/ccnx-content-store.h b/model/ccnx-content-store.h
index 97615db..07888e7 100644
--- a/model/ccnx-content-store.h
+++ b/model/ccnx-content-store.h
@@ -47,7 +47,7 @@
  *
  * GetFullyFormedCcnxPacket method provided as a convenience
  */
-class CcnxContentStoreEntry
+class CcnxContentStoreEntry : public SimpleRefCount<CcnxContentStoreEntry>
 {
 public:
   /**