api: Major API change. OnInterest/OnData callbacks now use just references, not shared pointers
If shared pointer is necessary, it can be obtained using
.shared_from_this() on Interest or Data object.
This commit also corrects all internal uses of expressInterest/setIntersetFilter.
Change-Id: I20207a5789fd189902f2c6e3827260b6b27a2514
diff --git a/tools/ndncatchunks3.cpp b/tools/ndncatchunks3.cpp
index 6bac64a..c912f26 100644
--- a/tools/ndncatchunks3.cpp
+++ b/tools/ndncatchunks3.cpp
@@ -21,14 +21,6 @@
#include "face.hpp"
-#include <stdexcept>
-#include <iostream>
-
-#if NDN_CPP_HAVE_CXX11
-// In the std library, the placeholders are in a different namespace than boost.
-using namespace ndn::func_lib::placeholders;
-#endif
-
class Consumer
{
public:
@@ -51,11 +43,10 @@
private:
void
- on_data (const ndn::ptr_lib::shared_ptr<const ndn::Interest> &interest,
- const ndn::ptr_lib::shared_ptr<ndn::Data> &data);
+ on_data (const ndn::Interest& interest, ndn::Data& data);
void
- on_timeout (const ndn::ptr_lib::shared_ptr<const ndn::Interest> &interest);
+ on_timeout (const ndn::Interest& interest);
ndn::Face m_face;
ndn::Name m_data_name;
@@ -83,8 +74,8 @@
inst.setMustBeFresh (m_mustBeFresh);
m_face.expressInterest (inst,
- ndn::func_lib::bind (&Consumer::on_data, this, _1, _2),
- ndn::func_lib::bind (&Consumer::on_timeout, this, _1));
+ ndn::bind (&Consumer::on_data, this, _1, _2),
+ ndn::bind (&Consumer::on_timeout, this, _1));
}
// processEvents will block until the requested data received or timeout occurs
@@ -97,10 +88,10 @@
}
void
-Consumer::on_data (const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, const ndn::ptr_lib::shared_ptr<ndn::Data>& data)
+Consumer::on_data (const ndn::Interest& interest, ndn::Data& data)
{
- const ndn::Block& content = data->getContent ();
- const ndn::Name& name = data->getName ();
+ const ndn::Block& content = data.getContent ();
+ const ndn::Name& name = data.getName ();
if (m_output)
{
@@ -124,14 +115,14 @@
inst.setMustBeFresh (m_mustBeFresh);
m_face.expressInterest (inst,
- ndn::func_lib::bind (&Consumer::on_data, this, _1, _2),
- ndn::func_lib::bind (&Consumer::on_timeout, this, _1));
+ ndn::bind (&Consumer::on_data, this, _1, _2),
+ ndn::bind (&Consumer::on_timeout, this, _1));
}
}
void
-Consumer::on_timeout (const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest)
+Consumer::on_timeout (const ndn::Interest& interest)
{
//XXX: currently no retrans
std::cerr << "TIMEOUT: last interest sent for segment #" << (m_next_seg - 1) << std::endl;
diff --git a/tools/ndnputchunks3.cpp b/tools/ndnputchunks3.cpp
index d3a96f5..be03453 100644
--- a/tools/ndnputchunks3.cpp
+++ b/tools/ndnputchunks3.cpp
@@ -55,12 +55,12 @@
}
void
- onInterest (const ndn::shared_ptr<const ndn::Name>& name, const ndn::shared_ptr<const ndn::Interest>& interest)
+ onInterest (const ndn::Name& name, const ndn::Interest& interest)
{
if (m_verbose)
- std::cerr << "<< I: " << *interest << std::endl;
+ std::cerr << "<< I: " << interest << std::endl;
- size_t segnum = static_cast<size_t>(interest->getName ().rbegin ()->toSegment ());
+ size_t segnum = static_cast<size_t>(interest.getName ().rbegin ()->toSegment ());
if (segnum < m_store.size())
{