From 03371e2e47523dcbadb9a4a79969ecd225b3ff3d Mon Sep 17 00:00:00 2001 From: michele papalini Date: Fri, 25 Jan 2019 14:58:31 +0100 Subject: [HICN-13] sendInterest with customized callbacks Change-Id: Ie4b2aac7f5f356f8afc7aaf83b723596dcbb4532 Signed-off-by: michele papalini --- .../src/hicn/transport/core/pending_interest.cc | 40 ++++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'libtransport/src/hicn/transport/core/pending_interest.cc') diff --git a/libtransport/src/hicn/transport/core/pending_interest.cc b/libtransport/src/hicn/transport/core/pending_interest.cc index 8f6de1839..a2df9ba44 100644 --- a/libtransport/src/hicn/transport/core/pending_interest.cc +++ b/libtransport/src/hicn/transport/core/pending_interest.cc @@ -20,12 +20,28 @@ namespace transport { namespace core { PendingInterest::PendingInterest() - : interest_(nullptr, nullptr), timer_(), received_(false) {} + : interest_(nullptr, nullptr), + timer_(), + on_content_object_callback_(), + on_interest_timeout_callback_(), + received_(false) {} PendingInterest::PendingInterest(Interest::Ptr &&interest, std::unique_ptr &&timer) : interest_(std::move(interest)), timer_(std::move(timer)), + on_content_object_callback_(), + on_interest_timeout_callback_(), + received_(false) {} + +PendingInterest::PendingInterest(Interest::Ptr &&interest, + const OnContentObjectCallback &&on_content_object, + const OnInterestTimeoutCallback &&on_interest_timeout, + std::unique_ptr &&timer) + : interest_(std::move(interest)), + timer_(std::move(timer)), + on_content_object_callback_(std::move(on_content_object)), + on_interest_timeout_callback_(std::move(on_interest_timeout)), received_(false) {} PendingInterest::~PendingInterest() { @@ -34,16 +50,28 @@ PendingInterest::~PendingInterest() { void PendingInterest::cancelTimer() { timer_->cancel(); } -bool PendingInterest::isReceived() const { return received_; } - void PendingInterest::setReceived() { received_ = true; } +bool PendingInterest::isReceived() const { return received_; } + Interest::Ptr &&PendingInterest::getInterest() { return std::move(interest_); } -void PendingInterest::setReceived(bool received) { - PendingInterest::received_ = received; +const OnContentObjectCallback &PendingInterest::getOnDataCallback() const { + return on_content_object_callback_; +} + +void PendingInterest::setOnDataCallback(const OnContentObjectCallback &on_content_object) { + PendingInterest::on_content_object_callback_ = on_content_object; +} + +const OnInterestTimeoutCallback &PendingInterest::getOnTimeoutCallback() const { + return on_interest_timeout_callback_; +} + +void PendingInterest::setOnTimeoutCallback(const OnInterestTimeoutCallback &on_interest_timeout) { + PendingInterest::on_interest_timeout_callback_ = on_interest_timeout; } } // end namespace core -} // end namespace transport \ No newline at end of file +} // end namespace transport -- cgit 1.2.3-korg