model+ndn.cxx+apps: New application template (CallbackBasedApp) that can be used to prototype NS-3 applications in python

The current code allows simulating in python using ApiFace (passed basic tests)

Refs #1005 (http://redmine.named-data.net/)
diff --git a/apps/callback-based-app.cc b/apps/callback-based-app.cc
new file mode 100644
index 0000000..34c3de6
--- /dev/null
+++ b/apps/callback-based-app.cc
@@ -0,0 +1,79 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ *                     Alexander Afanasyev
+ *                     Zhenkai Zhu
+ *
+ * GNU v3.0 license, See the LICENSE file for more information
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "callback-based-app.h"
+
+#include <ns3/log.h>
+
+NS_LOG_COMPONENT_DEFINE ("CallbackBasedApp");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (CallbackBasedApp);
+    
+TypeId
+CallbackBasedApp::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::CallbackBasedApp")
+    .SetGroupName ("Ndn")
+    .SetParent<Application> ()
+    .AddConstructor<CallbackBasedApp> ()
+
+    .AddAttribute ("OnStart", "OnStart callback",
+                   CallbackValue (),
+                   MakeCallbackAccessor (&CallbackBasedApp::m_onStart),
+                   MakeCallbackChecker ())
+
+    .AddAttribute ("OnStop", "OnStop callback",
+                   CallbackValue (),
+                   MakeCallbackAccessor (&CallbackBasedApp::m_onStop),
+                   MakeCallbackChecker ())
+    ;
+  return tid;
+}
+
+CallbackBasedApp::CallbackBasedApp ()
+{
+}
+
+CallbackBasedApp::~CallbackBasedApp ()
+{
+}
+
+void
+CallbackBasedApp::SetOnStartCallback (Callback< void, Ptr<Application> > onStart)
+{
+  m_onStart = onStart;
+}
+
+void
+CallbackBasedApp::SetOnStopCallback (Callback< void, Ptr<Application> > onStop)
+{
+  m_onStop = onStop;
+}
+
+void
+CallbackBasedApp::StartApplication ()
+{
+  NS_LOG_FUNCTION (this);
+  if (!m_onStart.IsNull ())
+    m_onStart (this);
+}
+
+void
+CallbackBasedApp::StopApplication ()
+{
+  NS_LOG_FUNCTION (this);
+  if (!m_onStop.IsNull ())
+    m_onStop (this);
+}
+
+}
diff --git a/apps/callback-based-app.h b/apps/callback-based-app.h
new file mode 100644
index 0000000..8cec638
--- /dev/null
+++ b/apps/callback-based-app.h
@@ -0,0 +1,68 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ *                     Alexander Afanasyev
+ *                     Zhenkai Zhu
+ *
+ * GNU v3.0 license, See the LICENSE file for more information
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef NDN_CALLBACK_BASED_APP_H
+#define NDN_CALLBACK_BASED_APP_H
+
+#include "ns3/application.h"
+#include "ns3/ptr.h"
+#include "ns3/callback.h"
+
+namespace ns3 {
+
+/**
+ * @ingroup ndn
+ * @brief A meta application that can be used to create custom apps within Python bindings 
+ */
+class CallbackBasedApp: public Application
+{
+public:
+  static TypeId GetTypeId ();
+
+  /**
+   * @brief Default constructor
+   */
+  CallbackBasedApp ();
+
+  /**
+   * @brief Virtual destructor
+   */
+  virtual
+  ~CallbackBasedApp ();
+
+  /**
+   * @brief Define callback that will be fired when application need to start its work
+   */
+  void
+  SetOnStartCallback (Callback< void, Ptr<Application> > onStart);
+
+  /**
+   * @brief Define callback that will be fired when application need to stop its work
+   */
+  void
+  SetOnStopCallback (Callback< void, Ptr<Application> > onStart);
+
+protected:
+  // inherited from Application base class. Originally they were private
+  virtual void
+  StartApplication ();    ///< @brief Called at time specified by Start
+
+  virtual void
+  StopApplication ();     ///< @brief Called at time specified by Stop
+
+private:
+  Callback< void, Ptr<Application> > m_onStart;
+  Callback< void, Ptr<Application> > m_onStop;
+};
+
+} // ns3
+
+#endif // NDN_CALLBACK_BASED_APP_H