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/src/management/controller.hpp b/src/management/controller.hpp
index f919489..f38e64a 100644
--- a/src/management/controller.hpp
+++ b/src/management/controller.hpp
@@ -14,7 +14,8 @@
namespace ndn {
-class Node;
+class Name;
+class Face;
class Controller
{
diff --git a/src/management/ndnd-controller.cpp b/src/management/ndnd-controller.cpp
index e95d85e..302699e 100644
--- a/src/management/ndnd-controller.cpp
+++ b/src/management/ndnd-controller.cpp
@@ -7,7 +7,7 @@
#include "common.hpp"
#include "ndnd-controller.hpp"
-#include "../node.hpp"
+#include "../face.hpp"
#include "../security/signature-sha256-with-rsa.hpp"
#include "../util/random.hpp"
@@ -18,7 +18,7 @@
namespace ndn {
namespace ndnd {
-Controller::Controller(Node& face)
+Controller::Controller(Face& face)
: m_face(face)
, m_faceId(-1)
{
@@ -64,12 +64,11 @@
void
-Controller::onNdnidFetched(const shared_ptr<const Interest>& interest,
- const shared_ptr<Data>& data)
+Controller::onNdnidFetched(const Interest& interest, Data& data)
{
- if (data->getName().size() > interest->getName().size())
+ if (data.getName().size() > interest.getName().size())
{
- m_ndndId = data->getName()[interest->getName().size()];
+ m_ndndId = data.getName()[interest.getName().size()];
for (FilterRequestList::iterator i = m_filterRequests.begin();
i != m_filterRequests.end();
@@ -169,11 +168,11 @@
}
void
-Controller::processFaceActionResponse(const shared_ptr<Data>& data,
+Controller::processFaceActionResponse(Data& data,
const FaceOperationSucceedCallback& onSuccess,
const FailCallback& onFail)
{
- Block content = data->getContent();
+ Block content = data.getContent();
content.parse();
if (content.getAll().empty())
@@ -215,11 +214,11 @@
}
void
-Controller::processPrefixActionResponse(const shared_ptr<Data>& data,
+Controller::processPrefixActionResponse(Data& data,
const PrefixOperationSucceedCallback& onSuccess,
const FailCallback& onFail)
{
- Block content = data->getContent();
+ Block content = data.getContent();
content.parse();
if (content.getAll().empty())
diff --git a/src/management/ndnd-controller.hpp b/src/management/ndnd-controller.hpp
index 319f995..a689d28 100644
--- a/src/management/ndnd-controller.hpp
+++ b/src/management/ndnd-controller.hpp
@@ -7,17 +7,9 @@
#ifndef NDN_MANAGEMENT_NDND_CONTROLLER_HPP
#define NDN_MANAGEMENT_NDND_CONTROLLER_HPP
-#include "../common.hpp"
#include "controller.hpp"
-#include "../name.hpp"
-#include "../interest.hpp"
-#include "../data.hpp"
-
namespace ndn {
-
-class Node;
-
namespace ndnd {
class FaceInstance;
@@ -37,7 +29,7 @@
/**
* @brief Construct ndnd::Control object
*/
- Controller(Node& face);
+ Controller(Face& face);
virtual void
selfRegisterPrefix(const Name& prefixToRegister,
@@ -62,26 +54,24 @@
private:
void
- onNdnidFetched(const shared_ptr<const Interest>& interest,
- const shared_ptr<Data>& data);
-
+ onNdnidFetched(const Interest& interest, Data& data);
void
recordSelfRegisteredFaceId(const ForwardingEntry& entry,
const SuccessCallback& onSuccess);
void
- processFaceActionResponse(const shared_ptr<Data>& data,
+ processFaceActionResponse(Data& data,
const FaceOperationSucceedCallback& onSuccess,
const FailCallback& onFail);
void
- processPrefixActionResponse(const shared_ptr<Data>& data,
+ processPrefixActionResponse(Data& data,
const PrefixOperationSucceedCallback& onSuccess,
const FailCallback& onFail);
private:
- Node& m_face;
+ Face& m_face;
Block m_ndndId;
int64_t m_faceId; // internal face ID (needed for prefix de-registration)
diff --git a/src/management/nfd-controller.cpp b/src/management/nfd-controller.cpp
index c72c5d3..b75f0e0 100644
--- a/src/management/nfd-controller.cpp
+++ b/src/management/nfd-controller.cpp
@@ -5,7 +5,7 @@
*/
#include "common.hpp"
-#include "../node.hpp"
+#include "../face.hpp"
#include "nfd-controller.hpp"
#include "nfd-fib-management-options.hpp"
@@ -14,7 +14,7 @@
namespace ndn {
namespace nfd {
-Controller::Controller(Node& face)
+Controller::Controller(Face& face)
: m_face(face)
, m_faceId(0)
{
@@ -82,18 +82,18 @@
}
// void
-// processFaceActionResponse(const shared_ptr<Data>& data,
+// processFaceActionResponse(Data& data,
// const FaceOperationSucceedCallback& onSuccess,
// const FailCallback& onFail);
void
-Controller::processFibCommandResponse(const shared_ptr<Data>& data,
+Controller::processFibCommandResponse(Data& data,
const FibCommandSucceedCallback& onSuccess,
const FailCallback& onFail)
{
try
{
- ControlResponse response(data->getContent().blockFromValue());
+ ControlResponse response(data.getContent().blockFromValue());
if (response.getCode() != 200)
return onFail(response.getText());
diff --git a/src/management/nfd-controller.hpp b/src/management/nfd-controller.hpp
index d5400c6..aa788a9 100644
--- a/src/management/nfd-controller.hpp
+++ b/src/management/nfd-controller.hpp
@@ -7,18 +7,12 @@
#ifndef NDN_MANAGEMENT_NFD_CONTROL_HPP
#define NDN_MANAGEMENT_NFD_CONTROL_HPP
-#include "../common.hpp"
#include "controller.hpp"
-#include "../name.hpp"
-#include "../interest.hpp"
-#include "../data.hpp"
#include "../security/key-chain.hpp"
namespace ndn {
-class Name;
-
namespace nfd {
class FibManagementOptions;
@@ -31,7 +25,7 @@
/**
* @brief Construct ndnd::Control object
*/
- Controller(Node& face);
+ Controller(Face& face);
virtual void
selfRegisterPrefix(const Name& prefixToRegister,
@@ -54,17 +48,17 @@
const SuccessCallback& onSuccess);
// void
- // processFaceActionResponse(const shared_ptr<Data>& data,
+ // processFaceActionResponse(Data& data,
// const FaceOperationSucceedCallback& onSuccess,
// const FailCallback& onFail);
void
- processFibCommandResponse(const shared_ptr<Data>& data,
+ processFibCommandResponse(Data& data,
const FibCommandSucceedCallback& onSuccess,
const FailCallback& onFail);
private:
- Node& m_face;
+ Face& m_face;
KeyChain m_keyChain;
uint64_t m_faceId; // internal face ID (needed for prefix de-registration)
};