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/04/21 22:03:53 UTC

qpid-proton git commit: PROTON-1153: [C++ binding] Simplify proton_event - Remove unecessary type member - Remove unused name() member - Remove unused link, session, connection, transport accessors As this is an internal API they can just be substitute

Repository: qpid-proton
Updated Branches:
  refs/heads/master 4971ac573 -> 27cea74f9


PROTON-1153: [C++ binding] Simplify proton_event
- Remove unecessary type member
- Remove unused name() member
- Remove unused link, session, connection, transport accessors
  As this is an internal API they can just be substituted with
  direct access to proton-c calls.
- Moved trivial accessors to header file - this is internal only
  so doesn't leak any proton-c to the API user.


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

Branch: refs/heads/master
Commit: 27cea74f960e3e19d1e19a09ca7038ac23b1da43
Parents: 4971ac5
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Apr 21 15:24:07 2016 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Apr 21 15:52:37 2016 -0400

----------------------------------------------------------------------
 proton-c/bindings/cpp/src/connector.cpp         |  4 +-
 proton-c/bindings/cpp/src/container_impl.cpp    |  4 +-
 .../bindings/cpp/src/io/connection_engine.cpp   |  2 +-
 proton-c/bindings/cpp/src/proton_event.cpp      | 57 ++------------------
 proton-c/bindings/cpp/src/proton_event.hpp      | 29 ++++------
 5 files changed, 18 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/27cea74f/proton-c/bindings/cpp/src/connector.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connector.cpp b/proton-c/bindings/cpp/src/connector.cpp
index 8df766f..9aca9a0 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -91,11 +91,11 @@ void connector::on_transport_tail_closed(proton_event &e) {
     on_transport_closed(e);
 }
 
-void connector::on_transport_closed(proton_event &e) {
+void connector::on_transport_closed(proton_event &) {
     if (!connection_) return;
     if (connection_.active()) {
         if (reconnect_timer_) {
-            e.connection().transport().unbind();
+            connection_.transport().unbind();
             transport_configured_ = false;
             int delay = reconnect_timer_->next_delay(timestamp::now());
             if (delay >= 0) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/27cea74f/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 c8e8968..1848734 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -63,10 +63,10 @@ struct handler_context {
      * should be small and free of indirect malloc/free/new/delete.
      */
 
-    static void dispatch(pn_handler_t *c_handler, pn_event_t *c_event, pn_event_type_t type)
+    static void dispatch(pn_handler_t *c_handler, pn_event_t *c_event, pn_event_type_t)
     {
         handler_context& hc(handler_context::get(c_handler));
-        proton_event pevent(c_event, type, hc.container_);
+        proton_event pevent(c_event, hc.container_);
         pevent.dispatch(*hc.handler_);
         return;
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/27cea74f/proton-c/bindings/cpp/src/io/connection_engine.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/io/connection_engine.cpp b/proton-c/bindings/cpp/src/io/connection_engine.cpp
index a38ec81..b3aa223 100644
--- a/proton-c/bindings/cpp/src/io/connection_engine.cpp
+++ b/proton-c/bindings/cpp/src/io/connection_engine.cpp
@@ -108,7 +108,7 @@ bool connection_engine::dispatch() {
          e;
          e = pn_collector_peek(collector_.get()))
     {
-        proton_event(e, pn_event_type(e), 0).dispatch(h);
+        proton_event(e, 0).dispatch(h);
         pn_collector_pop(collector_.get());
     }
     return !(pn_transport_closed(transport_.pn_object()) ||

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/27cea74f/proton-c/bindings/cpp/src/proton_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_event.cpp b/proton-c/bindings/cpp/src/proton_event.cpp
index ade1ecd..40bd93d 100644
--- a/proton-c/bindings/cpp/src/proton_event.cpp
+++ b/proton-c/bindings/cpp/src/proton_event.cpp
@@ -21,67 +21,16 @@
 
 #include "proton_event.hpp"
 
-#include "proton/container.hpp"
-#include "proton/delivery.hpp"
 #include "proton/error.hpp"
-#include "proton/receiver.hpp"
-#include "proton/sender.hpp"
-#include "proton/transport.hpp"
 
 #include "msg.hpp"
-#include "contexts.hpp"
 #include "proton_handler.hpp"
 
-#include "proton/reactor.h"
-#include "proton/link.h"
-
 namespace proton {
 
-proton_event::proton_event(pn_event_t *ce, pn_event_type_t t, class container *c) :
-    pn_event_(ce),
-    type_(event_type(t)),
-    container_(c)
-{}
-
-proton_event::event_type proton_event::type() const { return type_; }
-
-std::string proton_event::name() const { return pn_event_type_name(pn_event_type_t(type_)); }
-
-pn_event_t *proton_event::pn_event() const { return pn_event_; }
-
-container* proton_event::container() const {
-    return container_;
-}
-
-transport proton_event::transport() const {
-    pn_transport_t *t = pn_event_transport(pn_event());
-    if (!t)
-        throw error(MSG("No transport context for this event"));
-    return t;
-}
-
-connection proton_event::connection() const {
-    pn_connection_t *conn = pn_event_connection(pn_event());
-    if (!conn)
-        throw error(MSG("No connection context for this event"));
-    return conn;
-}
-
-session proton_event::session() const {
-    pn_session_t *sess = pn_event_session(pn_event());
-    if (!sess)
-        throw error(MSG("No session context for this event"));
-    return sess;
-}
-
-link proton_event::link() const {
-    class link lnk = pn_event_link(pn_event());
-    if (!lnk) throw error(MSG("No link context for this event"));
-    return lnk;
-}
-
 void proton_event::dispatch(proton_handler &handler) {
-    switch(type_) {
+    pn_event_type_t type = pn_event_type(pn_event_);
+    switch(type) {
 
       case PN_REACTOR_INIT: handler.on_reactor_init(*this); break;
       case PN_REACTOR_QUIESCED: handler.on_reactor_quiesced(*this); break;
@@ -131,7 +80,7 @@ void proton_event::dispatch(proton_handler &handler) {
       case PN_SELECTABLE_ERROR: handler.on_selectable_error(*this); break;
       case PN_SELECTABLE_FINAL: handler.on_selectable_final(*this); break;
       default:
-        throw error(MSG("Invalid Proton event type " << type_));
+        throw error(MSG("Invalid Proton event type " << type));
     }
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/27cea74f/proton-c/bindings/cpp/src/proton_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_event.hpp b/proton-c/bindings/cpp/src/proton_event.hpp
index 37ba63d..2d6b37f 100644
--- a/proton-c/bindings/cpp/src/proton_event.hpp
+++ b/proton-c/bindings/cpp/src/proton_event.hpp
@@ -21,7 +21,6 @@
  * under the License.
  *
  */
-#include "proton/link.hpp"
 
 #include "proton/event.h"
 
@@ -29,8 +28,6 @@ namespace proton {
 
 class proton_handler;
 class container;
-class connection;
-class connection_engine;
 
 /** Event information for a proton::proton_handler */
 class proton_event
@@ -267,27 +264,21 @@ class proton_event
     };
     ///@}
 
-    proton_event(pn_event_t *, pn_event_type_t, class container*);
+    proton_event(pn_event_t *ce, class container *c) :
+      pn_event_(ce),
+      container_(c)
+    {}
 
-    std::string name() const;
+    pn_event_t* pn_event() const { return pn_event_; }
+    class container* container() const { return container_; }
 
-    void dispatch(proton_handler& h);
-
-    class container* container() const;
-
-    class transport transport() const;
-    class connection connection() const;
-    class session session() const;
-    class link link() const;
+    /// Get type of event
+    event_type type() const { return event_type(pn_event_type(pn_event_)); }
 
-    /** Get type of event */
-    event_type type() const;
-
-    pn_event_t* pn_event() const;
+    void dispatch(proton_handler& h);
 
   private:
-    mutable pn_event_t *pn_event_;
-    event_type type_;
+    pn_event_t *pn_event_;
     class container *container_;
 };
 


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