model: Small extension of printing out entries of the content store
(printing more specific data for specialized versions of the content stores)
diff --git a/model/cs/content-store-with-freshness.h b/model/cs/content-store-with-freshness.h
index dab654c..81f8856 100644
--- a/model/cs/content-store-with-freshness.h
+++ b/model/cs/content-store-with-freshness.h
@@ -42,6 +42,9 @@
static TypeId
GetTypeId ();
+ virtual inline void
+ Print (std::ostream &os) const;
+
virtual inline bool
Add (Ptr<const ContentObject> header, Ptr<const Packet> packet);
@@ -156,6 +159,22 @@
RescheduleCleaning ();
}
+template<class Policy>
+void
+ContentStoreWithFreshness< Policy >::Print (std::ostream &os) const
+{
+ // const freshness_policy_container &freshness = this->getPolicy ().template get<freshness_policy_container> ();
+
+ for (typename super::policy_container::const_iterator item = this->getPolicy ().begin ();
+ item != this->getPolicy ().end ();
+ item++)
+ {
+ Time ttl = freshness_policy_container::policy_base::get_freshness (&(*item)) - Simulator::Now ();
+ os << item->payload ()->GetName () << "(left: " << ttl.ToDouble (Time::S) << "s)" << std::endl;
+ }
+}
+
+
} // namespace cs
} // namespace ndn
diff --git a/model/cs/content-store-with-stats.h b/model/cs/content-store-with-stats.h
index 8d4a71d..3bdb9ec 100644
--- a/model/cs/content-store-with-stats.h
+++ b/model/cs/content-store-with-stats.h
@@ -37,6 +37,8 @@
public:
typedef ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< Policy, ndnSIM::lifetime_stats_policy_traits > > > super;
+ typedef typename super::policy_container::template index<1>::type lifetime_stats_container;
+
ContentStoreWithStats ()
{
// connect traceback to the policy
@@ -46,6 +48,9 @@
static TypeId
GetTypeId ();
+ virtual inline void
+ Print (std::ostream &os) const;
+
private:
static LogComponent g_log; ///< @brief Logging variable
@@ -81,6 +86,22 @@
return tid;
}
+template<class Policy>
+void
+ContentStoreWithStats< Policy >::Print (std::ostream &os) const
+{
+ // const freshness_policy_container &freshness = this->getPolicy ().template get<freshness_policy_container> ();
+
+ for (typename super::policy_container::const_iterator item = this->getPolicy ().begin ();
+ item != this->getPolicy ().end ();
+ item++)
+ {
+ Time alive = lifetime_stats_container::policy_base::get_time (&(*item)) - Simulator::Now ();
+ os << item->payload ()->GetName () << "(alive: " << alive.ToDouble (Time::S) << "s)" << std::endl;
+ }
+}
+
+
} // namespace cs
} // namespace ndn