diff options
author | Mauro Sardara <msardara@cisco.com> | 2020-02-27 16:47:49 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2020-02-27 16:53:55 +0100 |
commit | 443f9e81c2f721898c1e7edf2940172fef6f55fe (patch) | |
tree | 5d12420e99676f690bd658f64f094840870da2db /libtransport/src/core | |
parent | bd8380012c308a79861e2e52919e9ff6326d45dc (diff) |
[HICN-539] Expose portal APIs to applications
Change-Id: Icbaad69981193119714f5689faf3518d2e152e11
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport/src/core')
-rw-r--r-- | libtransport/src/core/pending_interest.h | 7 | ||||
-rw-r--r-- | libtransport/src/core/portal.h | 54 |
2 files changed, 7 insertions, 54 deletions
diff --git a/libtransport/src/core/pending_interest.h b/libtransport/src/core/pending_interest.h index 87fed5073..d9ec2ed40 100644 --- a/libtransport/src/core/pending_interest.h +++ b/libtransport/src/core/pending_interest.h @@ -19,6 +19,7 @@ #include <hicn/transport/core/content_object.h> #include <hicn/transport/core/interest.h> #include <hicn/transport/core/name.h> +#include <hicn/transport/interfaces/portal.h> #include <hicn/transport/portability/portability.h> #include <utils/deadline_timer.h> @@ -36,10 +37,8 @@ class RawSocketInterface; template <typename ForwarderInt> class Portal; -typedef std::function<void(Interest::Ptr &&, ContentObject::Ptr &&)> - OnContentObjectCallback; -typedef std::function<void(Interest::Ptr &&)> OnInterestTimeoutCallback; -typedef std::function<void(const std::error_code &)> TimerCallback; +using OnContentObjectCallback = interface::Portal::OnContentObjectCallback; +using OnInterestTimeoutCallback = interface::Portal::OnInterestTimeoutCallback; class PendingInterest { friend class Portal<HicnForwarderInterface>; diff --git a/libtransport/src/core/portal.h b/libtransport/src/core/portal.h index d7c463dfd..cf1010068 100644 --- a/libtransport/src/core/portal.h +++ b/libtransport/src/core/portal.h @@ -21,6 +21,7 @@ #include <hicn/transport/core/name.h> #include <hicn/transport/core/prefix.h> #include <hicn/transport/errors/errors.h> +#include <hicn/transport/interfaces/portal.h> #include <hicn/transport/portability/portability.h> #include <hicn/transport/utils/log.h> @@ -39,8 +40,6 @@ #include <queue> #include <unordered_map> -#define UNSET_CALLBACK 0 - namespace transport { namespace core { @@ -230,36 +229,7 @@ class Pool { using PendingInterestHashTable = std::unordered_map<uint32_t, PendingInterest::Ptr>; -template <typename PrefixType> -class BasicBindConfig { - static_assert(std::is_same<Prefix, PrefixType>::value, - "Prefix must be a Prefix type."); - - const uint32_t standard_cs_reserved = 5000; - - public: - template <typename T> - BasicBindConfig(T &&prefix) - : prefix_(std::forward<T &&>(prefix)), - content_store_reserved_(standard_cs_reserved) {} - - template <typename T> - BasicBindConfig(T &&prefix, uint32_t cs_reserved) - : prefix_(std::forward<T &&>(prefix)), - content_store_reserved_(cs_reserved) {} - - TRANSPORT_ALWAYS_INLINE const PrefixType &prefix() const { return prefix_; } - - TRANSPORT_ALWAYS_INLINE uint32_t csReserved() const { - return content_store_reserved_; - } - - private: - PrefixType prefix_; - uint32_t content_store_reserved_; -}; - -using BindConfig = BasicBindConfig<Prefix>; +using interface::BindConfig; /** * Portal is a opaque class which is used for sending/receiving interest/data @@ -290,24 +260,8 @@ class Portal { "ForwarderInt must inherit from ForwarderInterface!"); public: - /** - * Consumer callback is an abstract class containing two methods to be - * implemented by a consumer application. - */ - class ConsumerCallback { - public: - virtual void onContentObject(Interest::Ptr &&i, ContentObject::Ptr &&c) = 0; - virtual void onTimeout(Interest::Ptr &&i) = 0; - }; - - /** - * Producer callback is an abstract class containing two methods to be - * implemented by a producer application. - */ - class ProducerCallback { - public: - virtual void onInterest(Interest::Ptr &&i) = 0; - }; + using ConsumerCallback = interface::Portal::ConsumerCallback; + using ProducerCallback = interface::Portal::ProducerCallback; Portal() : Portal(internal_io_service_) {} |