model: Major API changes
Interest and ContentObject are no longer derived from Header class.
Instead, they are encapsulating payload and, optionally, wire-formatted
Packet object.
Refs #1005 (http://redmine.named-data.net/)
diff --git a/model/cs/content-store-impl.h b/model/cs/content-store-impl.h
index ffe8038..9cd934e 100644
--- a/model/cs/content-store-impl.h
+++ b/model/cs/content-store-impl.h
@@ -44,8 +44,8 @@
typedef Entry base_type;
public:
- EntryImpl (Ptr<ContentStore> cs, Ptr<const ContentObject> header, Ptr<const Packet> packet)
- : Entry (cs, header, packet)
+ EntryImpl (Ptr<ContentStore> cs, Ptr<const ContentObject> data)
+ : Entry (cs, data)
, item_ (0)
{
}
@@ -86,11 +86,11 @@
// from ContentStore
- virtual inline boost::tuple<Ptr<Packet>, Ptr<const ContentObject>, Ptr<const Packet> >
+ virtual inline Ptr<ContentObject>
Lookup (Ptr<const Interest> interest);
virtual inline bool
- Add (Ptr<const ContentObject> header, Ptr<const Packet> packet);
+ Add (Ptr<const ContentObject> data);
// virtual bool
// Remove (Ptr<Interest> header);
@@ -156,7 +156,7 @@
}
template<class Policy>
-boost::tuple<Ptr<Packet>, Ptr<const ContentObject>, Ptr<const Packet> >
+Ptr<const ContentObject>
ContentStoreImpl<Policy>::Lookup (Ptr<const Interest> interest)
{
NS_LOG_FUNCTION (this << interest->GetName ());
@@ -166,29 +166,27 @@
if (node != this->end ())
{
- this->m_cacheHitsTrace (interest, node->payload ()->GetHeader ());
+ this->m_cacheHitsTrace (interest, node->payload ()->GetData ());
- // NS_LOG_DEBUG ("cache hit with " << node->payload ()->GetHeader ()->GetName ());
- return boost::make_tuple (node->payload ()->GetFullyFormedNdnPacket (),
- node->payload ()->GetHeader (),
- node->payload ()->GetPacket ());
+ Ptr<ContentObject> copy = Create<ContentObject> (node->payload ()->GetData ());
+ ConstCast<Packet> (copy->GetPayload ())->RemoveAllPacketTags ();
+ return copy;
}
else
{
- // NS_LOG_DEBUG ("cache miss for " << interest->GetName ());
this->m_cacheMissesTrace (interest);
- return boost::tuple<Ptr<Packet>, Ptr<ContentObject>, Ptr<Packet> > (0, 0, 0);
+ return 0;
}
}
template<class Policy>
bool
-ContentStoreImpl<Policy>::Add (Ptr<const ContentObject> header, Ptr<const Packet> packet)
+ContentStoreImpl<Policy>::Add (Ptr<const ContentObject> data)
{
- NS_LOG_FUNCTION (this << header->GetName ());
+ NS_LOG_FUNCTION (this << data->GetName ());
- Ptr< entry > newEntry = Create< entry > (this, header, packet);
- std::pair< typename super::iterator, bool > result = super::insert (header->GetName (), newEntry);
+ Ptr< entry > newEntry = Create< entry > (this, data);
+ std::pair< typename super::iterator, bool > result = super::insert (data->GetName (), newEntry);
if (result.first != super::end ())
{
diff --git a/model/cs/content-store-nocache.cc b/model/cs/content-store-nocache.cc
index 8814c13..c5749e2 100644
--- a/model/cs/content-store-nocache.cc
+++ b/model/cs/content-store-nocache.cc
@@ -55,15 +55,15 @@
{
}
-boost::tuple<Ptr<Packet>, Ptr<const ContentObject>, Ptr<const Packet> >
+Ptr<ContentObject>
Nocache::Lookup (Ptr<const Interest> interest)
{
this->m_cacheMissesTrace (interest);
- return boost::tuple<Ptr<Packet>, Ptr<const ContentObject>, Ptr<const Packet> > (0, 0, 0);
+ return 0;
}
bool
-Nocache::Add (Ptr<const ContentObject> header, Ptr<const Packet> packet)
+Nocache::Add (Ptr<const ContentObject> data)
{
return false;
}
diff --git a/model/cs/content-store-nocache.h b/model/cs/content-store-nocache.h
index 6d38f40..79d1284 100644
--- a/model/cs/content-store-nocache.h
+++ b/model/cs/content-store-nocache.h
@@ -54,11 +54,11 @@
virtual
~Nocache ();
- virtual boost::tuple<Ptr<Packet>, Ptr<const ContentObject>, Ptr<const Packet> >
+ virtual Ptr<ContentObject>
Lookup (Ptr<const Interest> interest);
virtual bool
- Add (Ptr<const ContentObject> header, Ptr<const Packet> packet);
+ Add (Ptr<const ContentObject> data);
virtual void
Print (std::ostream &os) const;
diff --git a/model/cs/content-store-with-freshness.h b/model/cs/content-store-with-freshness.h
index 81f8856..3ba871c 100644
--- a/model/cs/content-store-with-freshness.h
+++ b/model/cs/content-store-with-freshness.h
@@ -90,9 +90,9 @@
template<class Policy>
inline bool
-ContentStoreWithFreshness< Policy >::Add (Ptr<const ContentObject> header, Ptr<const Packet> packet)
+ContentStoreWithFreshness< Policy >::Add (Ptr<const ContentObject> data)
{
- bool ok = super::Add (header, packet);
+ bool ok = super::Add (data);
if (!ok) return false;
NS_LOG_DEBUG (header->GetName () << " added to cache");
diff --git a/model/cs/ndn-content-store.cc b/model/cs/ndn-content-store.cc
index c99d7ed..cfe362e 100644
--- a/model/cs/ndn-content-store.cc
+++ b/model/cs/ndn-content-store.cc
@@ -34,7 +34,7 @@
NS_OBJECT_ENSURE_REGISTERED (ContentStore);
-TypeId
+TypeId
ContentStore::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::ndn::ContentStore")
@@ -60,24 +60,12 @@
//////////////////////////////////////////////////////////////////////
-Entry::Entry (Ptr<ContentStore> cs, Ptr<const ContentObject> header, Ptr<const Packet> packet)
+Entry::Entry (Ptr<ContentStore> cs, Ptr<const ContentObject> data)
: m_cs (cs)
- , m_header (header)
- , m_packet (packet->Copy ())
+ , m_data (data)
{
}
-Ptr<Packet>
-Entry::GetFullyFormedNdnPacket () const
-{
- static ContentObjectTail tail; ///< \internal for optimization purposes
-
- Ptr<Packet> packet = m_packet->Copy ();
- packet->AddHeader (*m_header);
- packet->AddTrailer (tail);
- return packet;
-}
-
const Name&
Entry::GetName () const
{
@@ -85,15 +73,9 @@
}
Ptr<const ContentObject>
-Entry::GetHeader () const
+Entry::GetData () const
{
- return m_header;
-}
-
-Ptr<const Packet>
-Entry::GetPacket () const
-{
- return m_packet;
+ return m_data;
}
Ptr<ContentStore>
diff --git a/model/cs/ndn-content-store.h b/model/cs/ndn-content-store.h
index 54901d9..66e7667 100644
--- a/model/cs/ndn-content-store.h
+++ b/model/cs/ndn-content-store.h
@@ -36,13 +36,7 @@
class ContentObject;
class Interest;
-
-typedef Interest InterestHeader;
-typedef ContentObject ContentObjectHeader;
-
class Name;
-typedef Name NameComponents;
-
class ContentStore;
namespace cs {
@@ -50,13 +44,6 @@
/**
* \ingroup ndn
* \brief NDN content store entry
- *
- * Content store entry stores separately pseudo header and content of
- * ContentObject packet. It is responsibility of the caller to
- * construct a fully formed NDN Packet by calling Copy(), AddHeader(),
- * AddTail() on the packet received by GetPacket() method.
- *
- * GetFullyFormedNdnPacket method provided as a convenience
*/
class Entry : public SimpleRefCount<Entry>
{
@@ -70,7 +57,7 @@
* The constructor will make a copy of the supplied packet and calls
* RemoveHeader and RemoveTail on the copy.
*/
- Entry (Ptr<ContentStore> cs, Ptr<const ContentObject> header, Ptr<const Packet> packet);
+ Entry (Ptr<ContentStore> cs, Ptr<const ContentObject> data);
/**
* \brief Get prefix of the stored entry
@@ -84,21 +71,7 @@
* \returns ContentObject of the stored entry
*/
Ptr<const ContentObject>
- GetHeader () const;
-
- /**
- * \brief Get content of the stored entry
- * \returns content of the stored entry
- */
- Ptr<const Packet>
- GetPacket () const;
-
- /**
- * \brief Convenience method to create a fully formed Ndn packet from stored header and content
- * \returns A read-write copy of the packet with ContentObject and ContentObjectTail
- */
- Ptr<Packet>
- GetFullyFormedNdnPacket () const;
+ GetData () const;
/**
* @brief Get pointer to access store, to which this entry is added
@@ -108,8 +81,7 @@
private:
Ptr<ContentStore> m_cs; ///< \brief content store to which entry is added
- Ptr<const ContentObject> m_header; ///< \brief non-modifiable ContentObject
- Ptr<Packet> m_packet; ///< \brief non-modifiable content of the ContentObject packet
+ Ptr<const ContentObject> m_data; ///< \brief non-modifiable ContentObject
};
} // namespace cs
@@ -147,7 +119,7 @@
* If an entry is found, it is promoted to the top of most recent
* used entries index, \see m_contentStore
*/
- virtual boost::tuple<Ptr<Packet>, Ptr<const ContentObject>, Ptr<const Packet> >
+ virtual Ptr<ContentObject>
Lookup (Ptr<const Interest> interest) = 0;
/**
@@ -159,7 +131,7 @@
* @returns true if an existing entry was updated, false otherwise
*/
virtual bool
- Add (Ptr<const ContentObject> header, Ptr<const Packet> packet) = 0;
+ Add (Ptr<const ContentObject> data) = 0;
// /*
// * \brief Add a new content to the content store.