Added expressInterest which takes the Interest directly.
diff --git a/ndn-cpp/face.hpp b/ndn-cpp/face.hpp
index 8db72a8..2b1a41a 100644
--- a/ndn-cpp/face.hpp
+++ b/ndn-cpp/face.hpp
@@ -43,11 +43,34 @@
: node_(host)
{
}
+
+ /**
+ * Send the Interest through the transport, read the entire response and call onData(interest, data).
+ * @param interest A reference to the Interest. This copies the Interest.
+ * @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
+ * use func_lib::ref() as appropriate.
+ * @param onTimeout A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it.
+ * This copies the function object, so you may need to use func_lib::ref() as appropriate.
+ */
+ void expressInterest(const Interest &interest, const OnData &onData, const OnTimeout &onTimeout)
+ {
+ node_.expressInterest(interest, onData, onTimeout);
+ }
+
+ /**
+ * Send the Interest through the transport, read the entire response and call onData(interest, data).
+ * @param interest A reference to the Interest. This copies the Interest.
+ * @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
+ * use func_lib::ref() as appropriate.
+ */
+ void expressInterest(const Interest &interest, const OnData &onData) {
+ node_.expressInterest(interest, onData);
+ }
/**
* Encode name as an Interest. If interestTemplate is not 0, use its interest selectors.
* Send the interest through the transport, read the entire response and call onData(interest, data).
- * @param name A reference to a Name for the interest. This does not keep a pointer to the Name object.
+ * @param name A reference to a Name for the interest. This copies the Name.
* @param interestTemplate if not 0, copy interest selectors from the template. This does not keep a pointer to the Interest object.
* @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
* use func_lib::ref() as appropriate.
@@ -62,7 +85,7 @@
/**
* Encode name as an Interest, using a default interest lifetime.
* Send the interest through the transport, read the entire response and call onData(interest, data).
- * @param name A reference to a Name for the interest. This does not keep a pointer to the Name object.
+ * @param name A reference to a Name for the interest. This copies the Name.
* @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
* use func_lib::ref() as appropriate.
* @param onTimeout A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it.
@@ -76,7 +99,7 @@
/**
* Encode name as an Interest. If interestTemplate is not 0, use its interest selectors.
* Send the interest through the transport, read the entire response and call onData(interest, data).
- * @param name A reference to a Name for the interest. This does not keep a pointer to the Name object.
+ * @param name A reference to a Name for the interest. This copies the Name.
* @param interestTemplate if not 0, copy interest selectors from the template. This does not keep a pointer to the Interest object.
* @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
* use func_lib::ref() as appropriate.
@@ -89,7 +112,7 @@
/**
* Encode name as an Interest, using a default interest lifetime.
* Send the interest through the transport, read the entire response and call onData(interest, data).
- * @param name A reference to a Name for the interest. This does not keep a pointer to the Name object.
+ * @param name A reference to a Name for the interest. This copies the Name.
* @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
* use func_lib::ref() as appropriate.
*/
diff --git a/ndn-cpp/node.cpp b/ndn-cpp/node.cpp
index 802b84a..5bee365 100644
--- a/ndn-cpp/node.cpp
+++ b/ndn-cpp/node.cpp
@@ -58,19 +58,9 @@
return false;
}
-void Node::expressInterest(const Name &name, const Interest *interestTemplate, const OnData &onData, const OnTimeout &onTimeout)
+void Node::expressInterest(const Interest &interest, const OnData &onData, const OnTimeout &onTimeout)
{
- shared_ptr<const Interest> interest;
- if (interestTemplate)
- interest.reset(new Interest
- (name, interestTemplate->getMinSuffixComponents(), interestTemplate->getMaxSuffixComponents(),
- interestTemplate->getPublisherPublicKeyDigest(), interestTemplate->getExclude(),
- interestTemplate->getChildSelector(), interestTemplate->getAnswerOriginKind(),
- interestTemplate->getScope(), interestTemplate->getInterestLifetimeMilliseconds()));
- else
- interest.reset(new Interest(name, 4000.0));
-
- shared_ptr<PitEntry> pitEntry(new PitEntry(interest, onData, onTimeout));
+ shared_ptr<PitEntry> pitEntry(new PitEntry(shared_ptr<const Interest>(new Interest(interest)), onData, onTimeout));
pit_.push_back(pitEntry);
shared_ptr<vector<unsigned char> > encoding = pitEntry->getInterest()->wireEncode();
@@ -82,6 +72,18 @@
transport_->send(*encoding);
}
+void Node::expressInterest(const Name &name, const Interest *interestTemplate, const OnData &onData, const OnTimeout &onTimeout)
+{
+ if (interestTemplate)
+ expressInterest(Interest
+ (name, interestTemplate->getMinSuffixComponents(), interestTemplate->getMaxSuffixComponents(),
+ interestTemplate->getPublisherPublicKeyDigest(), interestTemplate->getExclude(),
+ interestTemplate->getChildSelector(), interestTemplate->getAnswerOriginKind(),
+ interestTemplate->getScope(), interestTemplate->getInterestLifetimeMilliseconds()), onData, onTimeout);
+ else
+ expressInterest(Interest(name, 4000.0), onData, onTimeout);
+}
+
void Node::processEvents()
{
transport_->processEvents();
diff --git a/ndn-cpp/node.hpp b/ndn-cpp/node.hpp
index 911298b..277628f 100644
--- a/ndn-cpp/node.hpp
+++ b/ndn-cpp/node.hpp
@@ -57,9 +57,29 @@
}
/**
+ * Send the Interest through the transport, read the entire response and call onData(interest, data).
+ * @param interest A reference to the Interest. This copies the Interest.
+ * @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
+ * use func_lib::ref() as appropriate.
+ * @param onTimeout A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it.
+ * This copies the function object, so you may need to use func_lib::ref() as appropriate.
+ */
+ void expressInterest(const Interest &interest, const OnData &onData, const OnTimeout &onTimeout);
+
+ /**
+ * Send the Interest through the transport, read the entire response and call onData(interest, data).
+ * @param interest A reference to the Interest. This copies the Interest.
+ * @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
+ * use func_lib::ref() as appropriate.
+ */
+ void expressInterest(const Interest &interest, const OnData &onData) {
+ expressInterest(interest, onData, OnTimeout());
+ }
+
+ /**
* Encode name as an Interest. If interestTemplate is not 0, use its interest selectors.
* Send the interest through the transport, read the entire response and call onData(interest, data).
- * @param name A reference to a Name for the interest. This does not keep a pointer to the Name object.
+ * @param name A reference to a Name for the interest. This copies the Name.
* @param interestTemplate if not 0, copy interest selectors from the template. This does not keep a pointer to the Interest object.
* @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
* use func_lib::ref() as appropriate.
@@ -71,7 +91,7 @@
/**
* Encode name as an Interest, using a default interest lifetime.
* Send the interest through the transport, read the entire response and call onData(interest, data).
- * @param name A reference to a Name for the interest. This does not keep a pointer to the Name object.
+ * @param name A reference to a Name for the interest. This copies the Name.
* @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
* use func_lib::ref() as appropriate.
* @param onTimeout A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it.
@@ -85,7 +105,7 @@
/**
* Encode name as an Interest. If interestTemplate is not 0, use its interest selectors.
* Send the interest through the transport, read the entire response and call onData(interest, data).
- * @param name A reference to a Name for the interest. This does not keep a pointer to the Name object.
+ * @param name A reference to a Name for the interest. This copies the Name.
* @param interestTemplate if not 0, copy interest selectors from the template. This does not keep a pointer to the Interest object.
* @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
* use func_lib::ref() as appropriate.
@@ -98,7 +118,7 @@
/**
* Encode name as an Interest, using a default interest lifetime.
* Send the interest through the transport, read the entire response and call onData(interest, data).
- * @param name A reference to a Name for the interest. This does not keep a pointer to the Name object.
+ * @param name A reference to a Name for the interest. This copies the Name.
* @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to
* use func_lib::ref() as appropriate.
*/