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.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'libtransport/src/hicn/transport/core/pending_interest.h') diff --git a/libtransport/src/hicn/transport/core/pending_interest.h b/libtransport/src/hicn/transport/core/pending_interest.h index cbcafb5d9..58b51db79 100644 --- a/libtransport/src/hicn/transport/core/pending_interest.h +++ b/libtransport/src/hicn/transport/core/pending_interest.h @@ -34,6 +34,8 @@ class RawSocketInterface; template class Portal; +typedef std::function OnContentObjectCallback; +typedef std::function OnInterestTimeoutCallback; typedef std::function TimerCallback; class PendingInterest { @@ -47,9 +49,12 @@ class PendingInterest { PendingInterest(Interest::Ptr &&interest, std::unique_ptr &&timer); - ~PendingInterest(); + PendingInterest(Interest::Ptr &&interest, + const OnContentObjectCallback &&on_content_object, + const OnInterestTimeoutCallback &&on_interest_timeout, + std::unique_ptr &&timer); - bool isReceived() const; + ~PendingInterest(); template TRANSPORT_ALWAYS_INLINE void startCountdown(Handler &&cb) { @@ -62,17 +67,23 @@ class PendingInterest { void setReceived(); + bool isReceived() const; + Interest::Ptr &&getInterest(); - void setReceived(bool received); + const OnContentObjectCallback &getOnDataCallback() const; + + void setOnDataCallback(const OnContentObjectCallback &on_content_object); - bool isValid() const; + const OnInterestTimeoutCallback &getOnTimeoutCallback() const; - void setValid(bool valid); + void setOnTimeoutCallback(const OnInterestTimeoutCallback &on_interest_timeout); private: Interest::Ptr interest_; std::unique_ptr timer_; + OnContentObjectCallback on_content_object_callback_; + OnInterestTimeoutCallback on_interest_timeout_callback_; bool received_; }; -- cgit 1.2.3-korg