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/examples/consumer-with-timer.cpp b/examples/consumer-with-timer.cpp
index b8415d0..9af81da 100644
--- a/examples/consumer-with-timer.cpp
+++ b/examples/consumer-with-timer.cpp
@@ -10,24 +10,17 @@
#include "face.hpp"
#include "util/scheduler.hpp"
-#include <stdexcept>
-
-#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
-
void
onData(ndn::Face &face,
- const ndn::ptr_lib::shared_ptr<const ndn::Interest> &interest, const ndn::ptr_lib::shared_ptr<ndn::Data> &data)
+ const ndn::Interest& interest, ndn::Data& data)
{
- std::cout << "I: " << interest->toUri() << std::endl;
- std::cout << "D: " << data->getName().toUri() << std::endl;
+ std::cout << "I: " << interest.toUri() << std::endl;
+ std::cout << "D: " << data.getName().toUri() << std::endl;
}
void
onTimeout(ndn::Face &face,
- const ndn::ptr_lib::shared_ptr<const ndn::Interest> &interest)
+ const ndn::Interest& interest)
{
std::cout << "Timeout" << std::endl;
}
diff --git a/examples/consumer.cpp b/examples/consumer.cpp
index bba9a7f..4dd1036 100644
--- a/examples/consumer.cpp
+++ b/examples/consumer.cpp
@@ -9,30 +9,23 @@
// #include <ndn-cpp-dev/face.hpp>
#include "face.hpp"
-#include <stdexcept>
-
-#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
-
void
onData(ndn::Face &face,
- const ndn::ptr_lib::shared_ptr<const ndn::Interest> &interest, const ndn::ptr_lib::shared_ptr<ndn::Data> &data)
+ const ndn::Interest& interest, ndn::Data& data)
{
- std::cout << "I: " << interest->toUri() << std::endl;
- std::cout << "D: " << data->getName().toUri() << std::endl;
+ std::cout << "I: " << interest.toUri() << std::endl;
+ std::cout << "D: " << data.getName().toUri() << std::endl;
}
void
onTimeout(ndn::Face &face,
- const ndn::ptr_lib::shared_ptr<const ndn::Interest> &interest)
+ const ndn::Interest& interest)
{
std::cout << "Timeout" << std::endl;
}
void
-BlockPrinter(const ndn::Block &block, const std::string &indent="")
+BlockPrinter(const ndn::Block& block, const std::string& indent="")
{
std::cout << indent << block.type() << " (" << block.value_size() << ") [[";
std::cout.write(reinterpret_cast<const char *>(block.value()), block.value_size());
@@ -56,8 +49,8 @@
ndn::Face face;
face.expressInterest(i,
- ndn::func_lib::bind(onData, boost::ref(face), _1, _2),
- ndn::func_lib::bind(onTimeout, boost::ref(face), _1));
+ ndn::bind(onData, boost::ref(face), _1, _2),
+ ndn::bind(onTimeout, boost::ref(face), _1));
// processEvents will block until the requested data received or timeout occurs
face.processEvents();
diff --git a/examples/producer.cpp b/examples/producer.cpp
index 53ccdc0..d081cb3 100644
--- a/examples/producer.cpp
+++ b/examples/producer.cpp
@@ -12,33 +12,21 @@
#include "face.hpp"
#include "security/key-chain.hpp"
-#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
-
using namespace ndn;
class Producer
{
public:
- ////////////////////////////////////////////////////////////////////////////////////////
- // CREATE TEST KEYCHAIN (THIS CODE IS ONLY FOR DEBUGGING, NOT TO BE USED IN REAL APPS //
- ////////////////////////////////////////////////////////////////////////////////////////
Producer()
- : keyChain_()
{
}
- ////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////
void
- onInterest(const ptr_lib::shared_ptr<const Name> &name, const ptr_lib::shared_ptr<const Interest> &interest)
+ onInterest(const Name& name, const Interest& interest)
{
- std::cout << "<< I: " << *interest << std::endl;
+ std::cout << "<< I: " << interest << std::endl;
- ndn::Data data(ndn::Name(interest->getName()).append("testApp").appendVersion());
+ ndn::Data data(ndn::Name(interest.getName()).append("testApp").appendVersion());
data.setFreshnessPeriod(1000); // 10 sec
data.setContent((const uint8_t*)"HELLO KITTY", sizeof("HELLO KITTY"));