model+cs: Now it is possible to get pointer to ContentStore from cs::Entry
In some cases it is desirable to know which ContentStore (=on which
Node) a particular cs::Entry belongs to. Now it is possible to
accomplish this task using cs::Entry::GetContentStore method.
diff --git a/model/cs/content-store-impl.h b/model/cs/content-store-impl.h
index cd277cc..ffbc925 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<const ContentObjectHeader> header, Ptr<const Packet> packet)
- : Entry (header, packet)
+ EntryImpl (Ptr<ContentStore> cs, Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet)
+ : Entry (cs, header, packet)
, item_ (0)
{
}
@@ -187,7 +187,7 @@
{
NS_LOG_FUNCTION (this << header->GetName ());
- Ptr< entry > newEntry = Create< entry > (header, packet);
+ Ptr< entry > newEntry = Create< entry > (this, header, packet);
std::pair< typename super::iterator, bool > result = super::insert (header->GetName (), newEntry);
if (result.first != super::end ())
diff --git a/model/cs/ndn-content-store.cc b/model/cs/ndn-content-store.cc
index 90a5699..fbe85ce 100644
--- a/model/cs/ndn-content-store.cc
+++ b/model/cs/ndn-content-store.cc
@@ -60,8 +60,9 @@
//////////////////////////////////////////////////////////////////////
-Entry::Entry (Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet)
- : m_header (header)
+Entry::Entry (Ptr<ContentStore> cs, Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet)
+ : m_cs (cs)
+ , m_header (header)
, m_packet (packet->Copy ())
{
}
@@ -95,6 +96,13 @@
return m_packet;
}
+Ptr<ContentStore>
+Entry::GetContentStore ()
+{
+ return m_cs;
+}
+
+
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/ndn-content-store.h b/model/cs/ndn-content-store.h
index 19ff996..f03e4c9 100644
--- a/model/cs/ndn-content-store.h
+++ b/model/cs/ndn-content-store.h
@@ -38,6 +38,8 @@
class InterestHeader;
class NameComponents;
+class ContentStore;
+
namespace cs {
/**
@@ -63,7 +65,7 @@
* The constructor will make a copy of the supplied packet and calls
* RemoveHeader and RemoveTail on the copy.
*/
- Entry (Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet);
+ Entry (Ptr<ContentStore> cs, Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet);
/**
* \brief Get prefix of the stored entry
@@ -93,7 +95,14 @@
Ptr<Packet>
GetFullyFormedNdnPacket () const;
+ /**
+ * @brief Get pointer to access store, to which this entry is added
+ */
+ Ptr<ContentStore>
+ GetContentStore ();
+
private:
+ Ptr<ContentStore> m_cs; ///< \brief content store to which entry is added
Ptr<const ContentObjectHeader> m_header; ///< \brief non-modifiable ContentObjectHeader
Ptr<Packet> m_packet; ///< \brief non-modifiable content of the ContentObject packet
};
@@ -123,7 +132,7 @@
*/
virtual
~ContentStore ();
-
+
/**
* \brief Find corresponding CS entry for the given interest
*
@@ -135,7 +144,7 @@
*/
virtual boost::tuple<Ptr<Packet>, Ptr<const ContentObjectHeader>, Ptr<const Packet> >
Lookup (Ptr<const InterestHeader> interest) = 0;
-
+
/**
* \brief Add a new content to the content store.
*
@@ -155,7 +164,7 @@
// */
// virtual bool
// Remove (Ptr<InterestHeader> header) = 0;
-
+
/**
* \brief Print out content store entries
*/
@@ -190,17 +199,17 @@
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
-
+
/**
* @brief Static call to cheat python bindings
*/
static inline Ptr<ContentStore>
GetContentStore (Ptr<Object> node);
-
+
protected:
TracedCallback<Ptr<const InterestHeader>,
Ptr<const ContentObjectHeader> > m_cacheHitsTrace; ///< @brief trace of cache hits
-
+
TracedCallback<Ptr<const InterestHeader> > m_cacheMissesTrace; ///< @brief trace of cache misses
};