apps: small improvement with ndn::ConsumerBatches
diff --git a/apps/ndn-consumer-batches.cc b/apps/ndn-consumer-batches.cc
index ddc2e85..584c04f 100644
--- a/apps/ndn-consumer-batches.cc
+++ b/apps/ndn-consumer-batches.cc
@@ -48,7 +48,7 @@
.AddAttribute ("Batches", "Batches to schedule. Should be vector, containing pairs of time and amount",
// TypeId::ATTR_SET,
StringValue (""),
- MakeBatchesAccessor (&ConsumerBatches::GetBatch, &ConsumerBatches::SetBatch),
+ MakeBatchesAccessor (&ConsumerBatches::m_batches),
MakeBatchesChecker ())
;
@@ -61,12 +61,14 @@
}
void
-ConsumerBatches::SetBatch (const Batches &batches)
+ConsumerBatches::StartApplication ()
{
+ Consumer::StartApplication ();
+
// std::cout << "Batches: " << batches << "\n";
- for (Batches::const_iterator i = batches.begin (); i != batches.end (); i++)
+ for (Batches::const_iterator i = m_batches.begin (); i != m_batches.end (); i++)
{
- Simulator::Schedule (i->get<0> (), &ConsumerBatches::AddBatch, this, i->get<1> ());
+ Simulator::ScheduleWithContext (GetNode ()->GetId (), i->get<0> (), &ConsumerBatches::AddBatch, this, i->get<1> ());
}
}
diff --git a/apps/ndn-consumer-batches.h b/apps/ndn-consumer-batches.h
index 6f9167d..a8c67b7 100644
--- a/apps/ndn-consumer-batches.h
+++ b/apps/ndn-consumer-batches.h
@@ -57,11 +57,8 @@
// OnTimeout (uint32_t sequenceNumber);
private:
- Batches
- GetBatch () const { return Batches(); }
-
- void
- SetBatch (const Batches &batch);
+ virtual void
+ StartApplication (); ///< @brief Called at time specified by Start
void
AddBatch (uint32_t amount);
@@ -74,6 +71,8 @@
private:
bool m_initial;
+
+ Batches m_batches;
};
} // namespace ndn