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/helper/ndn-global-routing-helper.cc b/helper/ndn-global-routing-helper.cc
index d235185..7acf7d6 100644
--- a/helper/ndn-global-routing-helper.cc
+++ b/helper/ndn-global-routing-helper.cc
@@ -35,6 +35,7 @@
#include "ns3/names.h"
#include "ns3/node-list.h"
#include "ns3/channel-list.h"
+#include "ns3/object-factory.h"
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
@@ -279,9 +280,17 @@
BOOST_FOREACH (const Ptr<const NameComponents> &prefix, i->first->GetLocalPrefixes ())
{
Ptr<fib::Entry> entry = fib->Add (prefix, i->second.get<0> (), i->second.get<1> ());
- if (i->second.get<0> ()->GetLimits ().IsEnabled ())
+ Ptr<Limits> limits = i->second.get<0> ()->GetObject<Limits> ();
+
+ if (limits != 0 && limits->IsEnabled ())
{
- entry->GetLimits ().SetMaxLimit (i->second.get<0> ()->GetLimits ().GetMaxLimit ());
+ ObjectFactory limitsFactory;
+ limitsFactory.SetTypeId (limits->GetInstanceTypeId ());
+
+ Ptr<Limits> entryLimits = limitsFactory.Create<Limits> ();
+ entryLimits->SetMaxLimit (limits->GetMaxLimit ());
+
+ entry->AggregateObject (entryLimits);
}
}
}