helper: Adds a new helper to create applications
This helper is primarily motivated to simplify creating applications for
unit tests, but can be used more in general simulation scenarios as
well.
Change-Id: I02db0c882a5b17e847bef0f10b7b69eb00d1fa45
diff --git a/helper/ndn-app-helper.cpp b/helper/ndn-app-helper.cpp
index 2efdee4..2556659 100644
--- a/helper/ndn-app-helper.cpp
+++ b/helper/ndn-app-helper.cpp
@@ -97,5 +97,35 @@
return app;
}
+////////////////////////////////////////////////////////////////////////////
+
+FactoryCallbackApp::FactoryCallbackApp(const FactoryCallback& factory)
+ : m_factory(factory)
+{
+}
+
+ApplicationContainer
+FactoryCallbackApp::Install(Ptr<Node> node, const FactoryCallback& factory)
+{
+ ApplicationContainer apps;
+ auto app = CreateObject<FactoryCallbackApp>(factory);
+ node->AddApplication(app);
+ apps.Add(app);
+ return apps;
+}
+
+void
+FactoryCallbackApp::StartApplication()
+{
+ m_impl = m_factory();
+}
+
+void
+FactoryCallbackApp::StopApplication()
+{
+ m_impl.reset();
+}
+
+
} // namespace ndn
} // namespace ns3