PROTON-1153: [C++ binding] Tidy up link - This involved some tidying up of delivery and message too
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3b62bf91 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3b62bf91 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3b62bf91 Branch: refs/heads/master Commit: 3b62bf91b8fb12ec47f0062a8b0720e820555775 Parents: e3e1d7d Author: Andrew Stitcher <[email protected]> Authored: Thu Feb 25 18:40:22 2016 -0500 Committer: Andrew Stitcher <[email protected]> Committed: Wed Mar 2 10:35:22 2016 -0500 ---------------------------------------------------------------------- .../bindings/cpp/include/proton/delivery.hpp | 3 ++ proton-c/bindings/cpp/include/proton/link.hpp | 42 ++++++++++---------- .../bindings/cpp/include/proton/message.hpp | 21 ++++------ .../bindings/cpp/include/proton/message_id.hpp | 2 + proton-c/bindings/cpp/src/delivery.cpp | 3 ++ proton-c/bindings/cpp/src/message.cpp | 3 +- proton-c/bindings/cpp/src/messaging_adapter.cpp | 2 +- 7 files changed, 41 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3b62bf91/proton-c/bindings/cpp/include/proton/delivery.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/delivery.hpp b/proton-c/bindings/cpp/include/proton/delivery.hpp index fddee95..8170357 100644 --- a/proton-c/bindings/cpp/include/proton/delivery.hpp +++ b/proton-c/bindings/cpp/include/proton/delivery.hpp @@ -41,6 +41,9 @@ class delivery : public object<pn_delivery_t> { public: delivery() : object<pn_delivery_t>(0) {} + /// Return the link for this delivery + PN_CPP_EXTERN class link link() const; + /// Delivery state values. enum state { NONE = 0, ///< Unknown state http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3b62bf91/proton-c/bindings/cpp/include/proton/link.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/link.hpp b/proton-c/bindings/cpp/include/proton/link.hpp index 07c1ebf..e5dd2f1 100644 --- a/proton-c/bindings/cpp/include/proton/link.hpp +++ b/proton-c/bindings/cpp/include/proton/link.hpp @@ -42,11 +42,13 @@ class condition; /// class for sender and receiver. class PN_CPP_CLASS_EXTERN link : public object<pn_link_t> , public endpoint { - public: /// @cond INTERNAL - link(pn_link_t* l=0) : object<pn_link_t>(l) {} + link(pn_link_t* l) : object<pn_link_t>(l) {} /// @endcond + public: + link() : object<pn_link_t>(0) {} + // Endpoint behaviours /// Get the state of this link. @@ -120,34 +122,34 @@ PN_CPP_CLASS_EXTERN link : public object<pn_link_t> , public endpoint { /// Session that owns this link. PN_CPP_EXTERN class session session() const; - /// @cond INTERNAL - /// XXX settle open questions - remove from API - - /// Set a custom handler for this link. - PN_CPP_EXTERN void handler(proton_handler &); - - /// Unset any custom handler. - PN_CPP_EXTERN void detach_handler(); - /// XXX local versus remote, mutability - /// XXX - remove setters /// XXX - local_sender_settle_mode and local_receiver_settle_mode PN_CPP_EXTERN link_options::sender_settle_mode sender_settle_mode(); - PN_CPP_EXTERN void sender_settle_mode(link_options::sender_settle_mode); PN_CPP_EXTERN link_options::receiver_settle_mode receiver_settle_mode(); - PN_CPP_EXTERN void receiver_settle_mode(link_options::receiver_settle_mode); PN_CPP_EXTERN link_options::sender_settle_mode remote_sender_settle_mode(); PN_CPP_EXTERN link_options::receiver_settle_mode remote_receiver_settle_mode(); - /// @endcond - private: - PN_CPP_EXTERN ssize_t recv(char* buffer, size_t size); - PN_CPP_EXTERN bool advance(); - PN_CPP_EXTERN link next(endpoint::state) const; - /// @cond INTERNAL + private: + // Used by link_options + void handler(proton_handler &); + void detach_handler(); + void sender_settle_mode(link_options::sender_settle_mode); + void receiver_settle_mode(link_options::receiver_settle_mode); + // Used by message to decode message from a delivery + ssize_t recv(char* buffer, size_t size); + bool advance(); + // Used by link_iterator + link next(endpoint::state) const; + + friend class connection; + friend class delivery; + friend class receiver; + friend class sender; friend class message; + friend class proton_event; friend class link_iterator; + friend class link_options; /// @endcond }; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3b62bf91/proton-c/bindings/cpp/include/proton/message.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp index 6981ac4..9ab851f 100644 --- a/proton-c/bindings/cpp/include/proton/message.hpp +++ b/proton-c/bindings/cpp/include/proton/message.hpp @@ -102,15 +102,6 @@ class message { /// Decode from string data into the message. PN_CPP_EXTERN void decode(const std::vector<char> &bytes); - /// @cond INTERNAL - /// XXX should a delivery know its own link already? - /// XXX also, determine the use case for this - /// XXX decision - 1) lose the link arg, 2) make private - /// - /// Decode the message corresponding to a delivery from a link. - PN_CPP_EXTERN void decode(proton::link, proton::delivery); - /// @endcond - /// @} /// @name Routing @@ -266,6 +257,7 @@ class message { /// @} + /// @cond INTERNAL private: pn_message_t *pn_msg() const; @@ -275,13 +267,16 @@ class message { mutable annotation_map message_annotations_; mutable annotation_map delivery_annotations_; - /// @cond INTERNAL - /// XXX settle necessity (there were some other options) - /// XXX decision - declare this separately; it is part of the api - friend PN_CPP_EXTERN void swap(message&, message&); + /// Decode the message corresponding to a delivery from a link. + void decode(proton::delivery); + + friend void swap(message&, message&); + friend class messaging_adapter; /// @endcond }; +PN_CPP_EXTERN void swap(message&, message&); + } #endif // PROTON_CPP_MESSAGE_H http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3b62bf91/proton-c/bindings/cpp/include/proton/message_id.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/message_id.hpp b/proton-c/bindings/cpp/include/proton/message_id.hpp index 3140f55..8d74c51 100644 --- a/proton-c/bindings/cpp/include/proton/message_id.hpp +++ b/proton-c/bindings/cpp/include/proton/message_id.hpp @@ -76,10 +76,12 @@ class message_id : public restricted_scalar { friend PN_CPP_EXTERN encoder operator<<(encoder, const message_id&); friend PN_CPP_EXTERN decoder operator>>(decoder, message_id&); + /// @cond INTERNAL private: message_id(const pn_atom_t& a): restricted_scalar(a) {} friend class message; + /// @endcond }; } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3b62bf91/proton-c/bindings/cpp/src/delivery.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/delivery.cpp b/proton-c/bindings/cpp/src/delivery.cpp index e6c5a54..761d17a 100644 --- a/proton-c/bindings/cpp/src/delivery.cpp +++ b/proton-c/bindings/cpp/src/delivery.cpp @@ -20,10 +20,13 @@ */ #include "proton/delivery.hpp" +#include <proton/link.hpp> + #include "proton/delivery.h" namespace proton { +link delivery::link() const { return pn_delivery_link(pn_object()); } bool delivery::settled() const { return pn_delivery_settled(pn_object()); } void delivery::settle() { pn_delivery_settle(pn_object()); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3b62bf91/proton-c/bindings/cpp/src/message.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp index 2a93ac0..167c553 100644 --- a/proton-c/bindings/cpp/src/message.cpp +++ b/proton-c/bindings/cpp/src/message.cpp @@ -273,9 +273,10 @@ void message::decode(const std::vector<char> &s) { check(pn_message_decode(pn_msg(), &s[0], s.size())); } -void message::decode(proton::link link, proton::delivery delivery) { +void message::decode(proton::delivery delivery) { std::vector<char> buf; buf.resize(delivery.pending()); + proton::link link = delivery.link(); ssize_t n = link.recv(const_cast<char *>(&buf[0]), buf.size()); if (n != ssize_t(buf.size())) throw error(MSG("link read failure")); clear(); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3b62bf91/proton-c/bindings/cpp/src/messaging_adapter.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp index 538d419..4265644 100644 --- a/proton-c/bindings/cpp/src/messaging_adapter.cpp +++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp @@ -116,7 +116,7 @@ void messaging_adapter::on_delivery(proton_event &pe) { // See PROTON-998 class message &msg(ctx.event_message); mevent.message_ = &msg; - mevent.message_->decode(lnk, dlv); + mevent.message_->decode(dlv); if (pn_link_state(lnk) & PN_LOCAL_CLOSED) { if (auto_accept_) dlv.release(); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
