limits: Introducing modularity for Interest limits

Now ndn::Limits object can be aggregated on a face/FIB entry. A
forwarding strategy module is responsible in creating an appropriate
implementation of the Interest limits module.
diff --git a/model/fw/ndn-forwarding-strategy.cc b/model/fw/ndn-forwarding-strategy.cc
index 9fc4d29..b04d48e 100644
--- a/model/fw/ndn-forwarding-strategy.cc
+++ b/model/fw/ndn-forwarding-strategy.cc
@@ -528,6 +528,11 @@
   // do nothing for now. may be need to do some logging
 }
 
+void
+ForwardingStrategy::AddFace (Ptr<Face> face)
+{
+  // do nothing here
+}
 
 void
 ForwardingStrategy::RemoveFace (Ptr<Face> face)
diff --git a/model/fw/ndn-forwarding-strategy.h b/model/fw/ndn-forwarding-strategy.h
index 3f0a147..fbf2295 100644
--- a/model/fw/ndn-forwarding-strategy.h
+++ b/model/fw/ndn-forwarding-strategy.h
@@ -90,6 +90,13 @@
   WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
 
   /**
+   * @brief Event fired every time face is added to NDN stack
+   * @param face face to be removed
+   */
+  virtual void
+  AddFace (Ptr<Face> face);
+  
+  /**
    * @brief Event fired every time face is removed from NDN stack
    * @param face face to be removed
    *
diff --git a/model/fw/simple-limits.cc b/model/fw/simple-window-limits.cc
similarity index 68%
rename from model/fw/simple-limits.cc
rename to model/fw/simple-window-limits.cc
index 803d608..8939fa9 100644
--- a/model/fw/simple-limits.cc
+++ b/model/fw/simple-window-limits.cc
@@ -18,7 +18,7 @@
  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#include "simple-limits.h"
+#include "simple-window-limits.h"
 
 #include "ns3/ndn-l3-protocol.h"
 #include "ns3/ndn-interest-header.h"
@@ -32,20 +32,23 @@
 namespace ndn {
 namespace fw {
 
-typedef SimpleLimits<BestRoute> SimpleLimitsBestRoute;
+template class SimpleWindowLimits<BestRoute>;
+typedef SimpleWindowLimits<BestRoute> SimpleLimitsBestRoute;
 NS_OBJECT_ENSURE_REGISTERED (SimpleLimitsBestRoute);
 
-typedef SimpleLimits<Flooding> SimpleLimitsFlooding;
+template class SimpleWindowLimits<Flooding>;
+typedef SimpleWindowLimits<Flooding> SimpleLimitsFlooding;
 NS_OBJECT_ENSURE_REGISTERED (SimpleLimitsFlooding);
 
-typedef SimpleLimits<SmartFlooding> SimpleLimitsSmartFlooding;
+template class SimpleWindowLimits<SmartFlooding>;
+typedef SimpleWindowLimits<SmartFlooding> SimpleLimitsSmartFlooding;
 NS_OBJECT_ENSURE_REGISTERED (SimpleLimitsSmartFlooding);
 
 #ifdef DOXYGEN
 
-class SimpleLimitsBestRoute : public SimpleLimits<BestRoute> { };
-class SimpleLimitsFlooding : public SimpleLimits<Flooding> { };
-class SimpleLimitsSmartFlooding : public SimpleLimits<SmartFlooding> { };
+class SimpleWindowLimitsBestRoute : public SimpleWindowLimits<BestRoute> { };
+class SimpleWindowLimitsFlooding : public SimpleWindowLimits<Flooding> { };
+class SimpleWindowLimitsSmartFlooding : public SimpleWindowLimits<SmartFlooding> { };
 
 #endif
 
diff --git a/model/fw/simple-limits.h b/model/fw/simple-window-limits.h
similarity index 71%
rename from model/fw/simple-limits.h
rename to model/fw/simple-window-limits.h
index 22a94ed..69fcd19 100644
--- a/model/fw/simple-limits.h
+++ b/model/fw/simple-window-limits.h
@@ -19,8 +19,8 @@
  */
 
 
-#ifndef NDNSIM_SIMPLE_LIMITS_H
-#define NDNSIM_SIMPLE_LIMITS_H
+#ifndef NDNSIM_SIMPLE_WINDOW_LIMITS_H
+#define NDNSIM_SIMPLE_WINDOW_LIMITS_H
 
 #include "ns3/event-id.h"
 #include "ns3/ndn-pit.h"
@@ -29,6 +29,9 @@
 
 #include "ns3/ndn-forwarding-strategy.h"
 
+#include "../../utils/ndn-limits-window.h"
+
+
 namespace ns3 {
 namespace ndn {
 namespace fw {
@@ -38,7 +41,7 @@
  * \brief Strategy implementing per-FIB entry limits
  */
 template<class Parent>
-class SimpleLimits :
+class SimpleWindowLimits :
     public Parent
 {
 private:
@@ -51,13 +54,21 @@
   /**
    * @brief Default constructor
    */
-  SimpleLimits ()
-  {
-  }
+  SimpleWindowLimits ()
+  { }
   
   virtual void
   WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
 
+  virtual void
+  AddFace (Ptr<Face> face)
+  {
+    Ptr<Limits> limits = CreateObject<LimitsWindow> ();
+    face->AggregateObject (limits);
+
+    super::AddFace (face);
+  }
+  
 protected:
   virtual bool
   TrySendOutInterest (Ptr<Face> inFace,
@@ -74,23 +85,23 @@
 
 template<class Parent>
 TypeId
-SimpleLimits<Parent>::GetTypeId (void)
+SimpleWindowLimits<Parent>::GetTypeId (void)
 {
-  static TypeId tid = TypeId ((super::GetTypeId ().GetName ()+"::SimpleLimits").c_str ())
+  static TypeId tid = TypeId ((super::GetTypeId ().GetName ()+"::SimpleWindowLimits").c_str ())
     .SetGroupName ("Ndn")
     .template SetParent <super> ()
-    .template AddConstructor <SimpleLimits> ()
+    .template AddConstructor <SimpleWindowLimits> ()
     ;
   return tid;
 }
 
 template<class Parent>
 bool
-SimpleLimits<Parent>::TrySendOutInterest (Ptr<Face> inFace,
-                                          Ptr<Face> outFace,
-                                          Ptr<const InterestHeader> header,
-                                          Ptr<const Packet> origPacket,
-                                          Ptr<pit::Entry> pitEntry)
+SimpleWindowLimits<Parent>::TrySendOutInterest (Ptr<Face> inFace,
+                                                Ptr<Face> outFace,
+                                                Ptr<const InterestHeader> header,
+                                                Ptr<const Packet> origPacket,
+                                                Ptr<pit::Entry> pitEntry)
 {
   // NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
   // totally override all (if any) parent processing
@@ -104,7 +115,7 @@
       return false;
     }
 
-  if (outFace->GetLimits ().IsBelowLimit ())
+  if (outFace->template GetObject<LimitsWindow> ()->IsBelowLimit ())
     {
       pitEntry->AddOutgoing (outFace);
 
@@ -125,7 +136,7 @@
 
 template<class Parent>
 void
-SimpleLimits<Parent>::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
+SimpleWindowLimits<Parent>::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
 {
   // NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
 
@@ -133,7 +144,7 @@
        face != pitEntry->GetOutgoing ().end ();
        face ++)
     {
-      face->m_face->GetLimits ().RemoveOutstanding ();
+      face->m_face->GetObject<LimitsWindow> ()->RemoveOutstanding ();
     }
 
   super::WillEraseTimedOutPendingInterest (pitEntry);
@@ -142,8 +153,8 @@
 
 template<class Parent>
 void
-SimpleLimits<Parent>::WillSatisfyPendingInterest (Ptr<Face> inFace,
-                                                  Ptr<pit::Entry> pitEntry)
+SimpleWindowLimits<Parent>::WillSatisfyPendingInterest (Ptr<Face> inFace,
+                                                        Ptr<pit::Entry> pitEntry)
 {
   // NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
 
@@ -151,7 +162,7 @@
        face != pitEntry->GetOutgoing ().end ();
        face ++)
     {
-      face->m_face->GetLimits ().RemoveOutstanding ();
+      face->m_face->GetObject<LimitsWindow> ()->RemoveOutstanding ();
     }
   
   super::WillSatisfyPendingInterest (inFace, pitEntry);
@@ -161,4 +172,4 @@
 } // namespace ndn
 } // namespace ns3
 
-#endif // NDNSIM_SIMPLE_LIMITS_H
+#endif // NDNSIM_SIMPLE_WINDOW_LIMITS_H