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/ndn.cxx/detail/timeouts-policy.h b/ndn.cxx/detail/timeouts-policy.h
index 7398d44..26d0c0f 100644
--- a/ndn.cxx/detail/timeouts-policy.h
+++ b/ndn.cxx/detail/timeouts-policy.h
@@ -145,7 +145,8 @@
inline void
ProcessTimeoutEntry (typename parent_trie::iterator item)
{
- item->payload ()->m_timeoutCallback (item->payload ()->GetInterest ());
+ if (!item->payload ()->m_timeoutCallback.IsNull ())
+ item->payload ()->m_timeoutCallback (item->payload ()->GetInterest ());
m_base.erase (item);
}
diff --git a/ndn.cxx/ndn-api-face.cc b/ndn.cxx/ndn-api-face.cc
index 6adfe99..578f424 100644
--- a/ndn.cxx/ndn-api-face.cc
+++ b/ndn.cxx/ndn-api-face.cc
@@ -186,8 +186,9 @@
{
return false;
}
-
- entry->payload ()->m_callback (entry->payload ()->GetPrefix (), interest);
+
+ if (!entry->payload ()->m_callback.IsNull ())
+ entry->payload ()->m_callback (entry->payload ()->GetPrefix (), interest);
return true;
}
@@ -197,7 +198,6 @@
// data has been send out from NDN stack towards the application
NS_LOG_DEBUG ("<< D " << data->GetName ());
-
NS_LOG_FUNCTION (this << data);
if (!IsUp ())
@@ -213,7 +213,8 @@
while (entry != m_this->m_pendingInterests.end ())
{
- entry->payload ()->m_dataCallback (entry->payload ()->GetInterest (), data);
+ if (!entry->payload ()->m_dataCallback.IsNull ())
+ entry->payload ()->m_dataCallback (entry->payload ()->GetInterest (), data);
m_this->m_pendingInterests.erase (entry);
entry = m_this->m_pendingInterests.longest_prefix_match (data->GetName ());
diff --git a/ndn.cxx/ndn-api-face.h b/ndn.cxx/ndn-api-face.h
index 160540e..4b88f51 100644
--- a/ndn.cxx/ndn-api-face.h
+++ b/ndn.cxx/ndn-api-face.h
@@ -28,6 +28,8 @@
#include <ns3/callback.h>
#include <ns3/ndn-face.h>
#include <ns3/ndn-name.h>
+#include <ns3/ndn-interest.h>
+#include <ns3/ndn-content-object.h>
namespace ns3 {
namespace ndn {
@@ -58,7 +60,7 @@
/**
* @brief Shutdown the API face
*/
- void
+ virtual void
Shutdown ();
/**
@@ -115,6 +117,15 @@
ApiFacePriv *m_this;
};
+
+/// @cond include_hidden
+#ifdef PYTHON_SCAN
+struct CallbackVoidNameInterest : public Callback<void, Ptr<const Name>, Ptr<const Interest> > { };
+struct CallbackVoidInterestContentObject : public Callback<void, Ptr<const Interest>, Ptr<const ContentObject> > { };
+struct CallbackVoidInterest : public Callback<void, Ptr<const Interest> > { };
+#endif
+/// @endcond
+
}
}