You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2016/03/31 01:11:33 UTC

qpid-proton git commit: PROTON-1153, PROTON-1153: [C++ binding] Align code with API doc - Remove sender/receiver/session member functions no longer needed - Removed sasl member functions not needed - Made private some sasl member functions that shouldn't

Repository: qpid-proton
Updated Branches:
  refs/heads/master 45390a9c5 -> c7dff22d4


PROTON-1153, PROTON-1153: [C++ binding] Align code with API doc
- Remove sender/receiver/session member functions no longer needed
- Removed sasl member functions not needed
- Made private some sasl member functions that shouldn't be exposed to API
- Made condition and sasl object not user creatable or copyable


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c7dff22d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c7dff22d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c7dff22d

Branch: refs/heads/master
Commit: c7dff22d4d4ab05ffd7f6375bfa64222fc148a05
Parents: 45390a9
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed Mar 30 17:33:29 2016 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Mar 30 19:05:34 2016 -0400

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/condition.hpp   | 19 ++++++++--
 .../bindings/cpp/include/proton/receiver.hpp    |  3 --
 proton-c/bindings/cpp/include/proton/sasl.hpp   | 38 +++++++++-----------
 proton-c/bindings/cpp/include/proton/sender.hpp | 13 -------
 .../bindings/cpp/include/proton/session.hpp     | 19 ----------
 proton-c/bindings/cpp/src/container_impl.cpp    | 10 ++----
 proton-c/bindings/cpp/src/receiver.cpp          |  4 ---
 proton-c/bindings/cpp/src/sasl.cpp              |  2 --
 proton-c/bindings/cpp/src/sender.cpp            |  4 ---
 proton-c/bindings/cpp/src/session.cpp           | 18 +++-------
 proton-c/bindings/cpp/src/transport.cpp         |  2 +-
 11 files changed, 40 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/include/proton/condition.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/condition.hpp b/proton-c/bindings/cpp/include/proton/condition.hpp
index 9e157f3..f6067a5 100644
--- a/proton-c/bindings/cpp/include/proton/condition.hpp
+++ b/proton-c/bindings/cpp/include/proton/condition.hpp
@@ -25,6 +25,8 @@
 #include "proton/export.hpp"
 #include "proton/value.hpp"
 
+#include "proton/config.hpp"
+
 #include <string>
 
 struct pn_condition_t;
@@ -32,13 +34,26 @@ struct pn_condition_t;
 namespace proton {
 
 /// Describes an endpoint error state.
+///
+/// This class has only one purpose: it can be used to get access to information about why
+/// an endpoint (a link, session, connection) or a transport has closed.
+///
+/// The information that is requuired (for instance the condition name and/or description)
+/// should be extracted immediately from the condition in order to enforce this conditions
+/// cannot be copied or assigned.
 class condition {
     /// @cond INTERNAL
     condition(pn_condition_t* c) : condition_(c) {}
     /// @endcond
 
   public:
-    condition() : condition_(0) {}
+#if PN_CPP_HAS_CPP11
+    condition() = delete;
+    condition(const condition&) = delete;
+    condition(condition&&) = default;
+    condition& operator=(const condition&) = delete;
+    condition& operator=(condition&&) = delete;
+#endif
 
     /// No condition set.
     PN_CPP_EXTERN bool operator!() const;
@@ -63,7 +78,7 @@ class condition {
 
     /// @cond INTERNAL
   private:
-    pn_condition_t* condition_;
+    pn_condition_t* const condition_;
 
     friend class transport;
     friend class connection;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/include/proton/receiver.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/receiver.hpp b/proton-c/bindings/cpp/include/proton/receiver.hpp
index 7a363ef..ce29844 100644
--- a/proton-c/bindings/cpp/include/proton/receiver.hpp
+++ b/proton-c/bindings/cpp/include/proton/receiver.hpp
@@ -42,9 +42,6 @@ PN_CPP_CLASS_EXTERN receiver : public link {
   public:
     receiver() : link(0) {}
 
-    /// Add credit to the link
-    PN_CPP_EXTERN void flow(int count);
-
   /// @cond INTERNAL
   friend class link;
   friend class session;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/include/proton/sasl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/sasl.hpp b/proton-c/bindings/cpp/include/proton/sasl.hpp
index a4db546..6e93001 100644
--- a/proton-c/bindings/cpp/include/proton/sasl.hpp
+++ b/proton-c/bindings/cpp/include/proton/sasl.hpp
@@ -23,6 +23,7 @@
  */
 
 #include "proton/export.hpp"
+#include "proton/config.hpp"
 #include "proton/sasl.h"
 #include <string>
 
@@ -35,7 +36,13 @@ class sasl {
     /// @endcond
 
   public:
-    sasl() : object_(0) {}
+#if PN_CPP_HAS_CPP11
+    sasl() = delete;
+    sasl(const sasl&) = delete;
+    sasl(sasl&&) = default;
+    sasl& operator=(const sasl&) = delete;
+    sasl& operator=(sasl&&) = delete;
+#endif
 
     /// The result of the SASL negotiation.
     enum outcome {
@@ -47,12 +54,6 @@ class sasl {
         TEMP = PN_SASL_TEMP    ///< Failed due to transient error
     };
 
-    /// @cond INTERNAL
-    /// XXX need to discuss
-    PN_CPP_EXTERN static bool extended();
-    PN_CPP_EXTERN void done(enum outcome);
-    /// @endcond
-
     /// Get the outcome.
     PN_CPP_EXTERN enum outcome outcome() const;
 
@@ -63,23 +64,16 @@ class sasl {
     PN_CPP_EXTERN std::string mech() const;
 
     /// @cond INTERNAL
-    PN_CPP_EXTERN void allow_insecure_mechs(bool);
-    /// @endcond
-
-    /// True if insecure mechanisms are permitted.
-    PN_CPP_EXTERN bool allow_insecure_mechs();
-
-    /// @cond INTERNAL
-    /// XXX setters? versus connection options
-    PN_CPP_EXTERN void allowed_mechs(const std::string &);
-    PN_CPP_EXTERN void config_name(const std::string&);
-    PN_CPP_EXTERN void config_path(const std::string&);
-    /// @endcond
-
-    /// @cond INTERNAL
   private:
-    pn_sasl_t* object_;
+    void allow_insecure_mechs(bool);
+    bool allow_insecure_mechs();
+    void allowed_mechs(const std::string &);
+    void config_name(const std::string&);
+    void config_path(const std::string&);
+
+    pn_sasl_t* const object_;
 
+    friend class connection_options;
     friend class transport;
     /// @endcond
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/include/proton/sender.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/sender.hpp b/proton-c/bindings/cpp/include/proton/sender.hpp
index 71f2ae3..0642c5a 100644
--- a/proton-c/bindings/cpp/include/proton/sender.hpp
+++ b/proton-c/bindings/cpp/include/proton/sender.hpp
@@ -48,19 +48,6 @@ PN_CPP_CLASS_EXTERN sender : public link
     /// Send a message on the link.
     PN_CPP_EXTERN delivery send(const message &m);
 
-    /// @cond INTERNAL
-    /// XXX undiscussed
-
-    /// The number of deliveries that might be able to be sent if
-    /// sufficient credit were issued on the link.  See
-    /// sender::offered().  Maintained by the application.
-    PN_CPP_EXTERN int available();
-
-    /// Set the availability of deliveries for a sender.
-    PN_CPP_EXTERN void offered(int c);
-
-    /// @endcond
-
   /// @cond INTERNAL
   friend class link;
   friend class session;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/include/proton/session.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/session.hpp b/proton-c/bindings/cpp/include/proton/session.hpp
index 014ab2a..24ada91 100644
--- a/proton-c/bindings/cpp/include/proton/session.hpp
+++ b/proton-c/bindings/cpp/include/proton/session.hpp
@@ -69,25 +69,6 @@ PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endp
     /// Get the connection this session belongs to.
     PN_CPP_EXTERN class connection connection() const;
 
-    /// @cond INTERNAL
-    /// XXX consider removing
-
-    /// An unopened receiver link, you can set link properties before calling open().
-    ///
-    /// @param name if specified must be unique, by default the
-    /// container generates a name of the form: <hex-digits> + "@" +
-    /// container.id()
-    PN_CPP_EXTERN receiver create_receiver(const std::string& name="");
-
-    /// An unopened sender link, you can set link properties before calling open().
-    ///
-    /// @param name if specified must be unique, by default the
-    /// container generates a name of the form: <hex-digits> + "@" +
-    /// container.id()
-    PN_CPP_EXTERN sender create_sender(const std::string& name="");
-
-    /// @endcond
-
     /// Open a sender for `addr`.
     PN_CPP_EXTERN sender open_sender(const std::string &addr, const link_options &opts = link_options());
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/src/container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.cpp b/proton-c/bindings/cpp/src/container_impl.cpp
index 979c20c..6a47294 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -169,10 +169,7 @@ sender container_impl::open_sender(const proton::url &url, const proton::link_op
     copts.update(o2);
     connection conn = connect(url, copts);
     std::string path = url.path();
-    sender snd = conn.default_session().create_sender();
-    snd.local_target().address(path);
-    snd.open(lopts);
-    return snd;
+    return conn.default_session().open_sender(path, lopts);
 }
 
 receiver container_impl::open_receiver(const proton::url &url, const proton::link_options &o1, const connection_options &o2) {
@@ -182,10 +179,7 @@ receiver container_impl::open_receiver(const proton::url &url, const proton::lin
     copts.update(o2);
     connection conn = connect(url, copts);
     std::string path = url.path();
-    receiver rcv = conn.default_session().create_receiver();
-    rcv.local_source().address(path);
-    rcv.open(lopts);
-    return rcv;
+    return conn.default_session().open_receiver(path, lopts);
 }
 
 acceptor container_impl::listen(const proton::url& url, const connection_options &user_opts) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/src/receiver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/receiver.cpp b/proton-c/bindings/cpp/src/receiver.cpp
index dec9fa6..2331bdb 100644
--- a/proton-c/bindings/cpp/src/receiver.cpp
+++ b/proton-c/bindings/cpp/src/receiver.cpp
@@ -29,8 +29,4 @@
 
 namespace proton {
 
-void receiver::flow(int count) {
-    pn_link_flow(pn_object(), count);
-}
-
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/src/sasl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/sasl.cpp b/proton-c/bindings/cpp/src/sasl.cpp
index edccebe..5ce7454 100644
--- a/proton-c/bindings/cpp/src/sasl.cpp
+++ b/proton-c/bindings/cpp/src/sasl.cpp
@@ -23,8 +23,6 @@
 
 namespace proton {
 
-bool sasl::extended() { return pn_sasl_extended(); }
-void sasl::done(enum outcome outcome0) { pn_sasl_done(object_, static_cast<pn_sasl_outcome_t>(outcome0)); }
 enum sasl::outcome sasl::outcome() const { return static_cast<enum outcome>(pn_sasl_outcome(object_)); }
 
 std::string sasl::user() const {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/src/sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/sender.cpp b/proton-c/bindings/cpp/src/sender.cpp
index 6761f4e..f79537b 100644
--- a/proton-c/bindings/cpp/src/sender.cpp
+++ b/proton-c/bindings/cpp/src/sender.cpp
@@ -54,8 +54,4 @@ delivery sender::send(const message &message) {
     return dlv;
 }
 
-int sender::available() { return pn_link_available(pn_object()); }
-void sender::offered(int c) { pn_link_offered(pn_object(), c); }
-
-
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/src/session.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/session.cpp b/proton-c/bindings/cpp/src/session.cpp
index 545869f..e5c1f82 100644
--- a/proton-c/bindings/cpp/src/session.cpp
+++ b/proton-c/bindings/cpp/src/session.cpp
@@ -41,23 +41,13 @@ connection session::connection() const {
 }
 
 namespace {
-std::string link_name(const std::string& name, session* s) {
-    if (!name.empty()) return name;
-    std::string gen(connection_context::get(s->connection()).link_gen.next());
-    return gen;
+std::string next_link_name(const connection& c) {
+    return connection_context::get(c).link_gen.next();
 }
 }
 
-receiver session::create_receiver(const std::string& name) {
-    return pn_receiver(pn_object(), link_name(name, this).c_str());
-}
-
-sender session::create_sender(const std::string& name) {
-    return pn_sender(pn_object(), link_name(name, this).c_str());
-}
-
 sender session::open_sender(const std::string &addr, const link_options &lo) {
-    sender snd = create_sender();
+    sender snd = pn_sender(pn_object(), next_link_name(connection()).c_str());
     snd.local_target().address(addr);
     snd.open(lo);
     return snd;
@@ -65,7 +55,7 @@ sender session::open_sender(const std::string &addr, const link_options &lo) {
 
 receiver session::open_receiver(const std::string &addr, const link_options &lo)
 {
-    receiver rcv = create_receiver();
+    receiver rcv = pn_receiver(pn_object(), next_link_name(connection()).c_str());
     rcv.local_source().address(addr);
     rcv.open(lo);
     return rcv;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7dff22d/proton-c/bindings/cpp/src/transport.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/transport.cpp b/proton-c/bindings/cpp/src/transport.cpp
index 8883806..cbaab6e 100644
--- a/proton-c/bindings/cpp/src/transport.cpp
+++ b/proton-c/bindings/cpp/src/transport.cpp
@@ -42,7 +42,7 @@ class ssl transport::ssl() const {
 }
 
 class sasl transport::sasl() const {
-    return proton::sasl(pn_sasl(pn_object()));
+    return pn_sasl(pn_object());
 }
 
 condition transport::condition() const {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org