qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject [1/5] qpid-proton git commit: PROTON-1083: [C++ binding] Completely separate internal/API handlers and events - There is now no inheritance relationship between proton_handler and messaging_handler - API handlers are messaging_handler/library internal is
Date Wed, 20 Jan 2016 15:05:51 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 701e8d07c -> 3a034abbd


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/messaging_handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_handler.cpp b/proton-c/bindings/cpp/src/messaging_handler.cpp
index b68ece5..6071ea2 100644
--- a/proton-c/bindings/cpp/src/messaging_handler.cpp
+++ b/proton-c/bindings/cpp/src/messaging_handler.cpp
@@ -19,65 +19,19 @@
  *
  */
 #include "proton/messaging_handler.hpp"
+
 #include "proton_event.hpp"
-#include "proton/messaging_adapter.hpp"
+#include "messaging_adapter.hpp"
+
 #include "proton/handlers.h"
+
 #include <algorithm>
 
 namespace proton {
 
-namespace {
-class c_flow_controller : public proton_handler
-{
-  public:
-    pn_handler_t *flowcontroller;
-
-    // TODO: pn_flowcontroller requires a window > 1.
-    c_flow_controller(int window) : flowcontroller(pn_flowcontroller(std::max(window, 2)))
{}
-    ~c_flow_controller() {
-        pn_decref(flowcontroller);
-    }
-
-    void redirect(event &e) {
-        proton_event *pne = dynamic_cast<proton_event *>(&e);
-        pn_handler_dispatch(flowcontroller, pne->pn_event(), pn_event_type_t(pne->type()));
-    }
-
-    virtual void on_link_local_open(event &e) { redirect(e); }
-    virtual void on_link_remote_open(event &e) { redirect(e); }
-    virtual void on_link_flow(event &e) { redirect(e); }
-    virtual void on_delivery(event &e) { redirect(e); }
-};
-
-} // namespace
-
-
-
-
 messaging_handler::messaging_handler(int prefetch0, bool auto_accept0, bool auto_settle0,
bool peer_close_is_error0) :
-    prefetch_(prefetch0), auto_accept_(auto_accept0), auto_settle_(auto_settle0),
-    peer_close_iserror_(peer_close_is_error0)
-{
-    create_helpers();
-}
-
-messaging_handler::messaging_handler(bool raw_handler, int prefetch0, bool auto_accept0,
bool auto_settle0, bool peer_close_is_error0) :
-    prefetch_(prefetch0), auto_accept_(auto_accept0), auto_settle_(auto_settle0),
-    peer_close_iserror_(peer_close_is_error0)
-{
-    if (!raw_handler) {
-        create_helpers();
-    }
-}
-
-void messaging_handler::create_helpers() {
-    if (prefetch_ > 0) {
-        flow_controller_.reset(new c_flow_controller(prefetch_));
-        add_child_handler(*flow_controller_);
-    }
-    messaging_adapter_.reset(new messaging_adapter(*this));
-    add_child_handler(*messaging_adapter_);
-}
+    messaging_adapter_(new messaging_adapter(*this, prefetch0, auto_accept0, auto_settle0,
peer_close_is_error0))
+{}
 
 messaging_handler::~messaging_handler(){}
 
@@ -103,4 +57,6 @@ void messaging_handler::on_transaction_abort(event &e) { on_unhandled(e);
}
 void messaging_handler::on_transaction_commit(event &e) { on_unhandled(e); }
 void messaging_handler::on_transaction_declare(event &e) { on_unhandled(e); }
 
+void messaging_handler::on_unhandled(event &) {}
+void messaging_handler::on_unhandled_error(event &) {}
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/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 fca96c4..d7230da 100644
--- a/proton-c/bindings/cpp/src/proton_event.cpp
+++ b/proton-c/bindings/cpp/src/proton_event.cpp
@@ -19,30 +19,30 @@
  *
  */
 
-#include "proton/reactor.h"
-#include "proton/event.h"
-#include "proton/link.h"
+#include "proton_event.hpp"
 
 #include "proton/container.hpp"
 #include "proton/delivery.hpp"
 #include "proton/error.hpp"
-#include "proton_event.hpp"
-#include "proton/proton_handler.hpp"
 #include "proton/receiver.hpp"
 #include "proton/sender.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, proton_event::event_type t, class container *c)
:
+proton_event::proton_event(pn_event_t *ce, pn_event_type_t t, class container *c) :
     pn_event_(ce),
-    type_(t),
+    type_(event_type(t)),
     container_(c)
 {}
 
-int proton_event::type() const { return type_; }
+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_));
}
 
@@ -83,112 +83,64 @@ delivery proton_event::delivery() const {
     return dlv;
 }
 
-void proton_event::dispatch(handler &h) {
-    proton_handler *handler = dynamic_cast<proton_handler*>(&h);
-
-    if (handler) {
-        switch(type_) {
-
-          case PN_REACTOR_INIT: handler->on_reactor_init(*this); break;
-          case PN_REACTOR_QUIESCED: handler->on_reactor_quiesced(*this); break;
-          case PN_REACTOR_FINAL: handler->on_reactor_final(*this); break;
-
-          case PN_TIMER_TASK: handler->on_timer_task(*this); break;
-
-          case PN_CONNECTION_INIT: handler->on_connection_init(*this); break;
-          case PN_CONNECTION_BOUND: handler->on_connection_bound(*this); break;
-          case PN_CONNECTION_UNBOUND: handler->on_connection_unbound(*this); break;
-          case PN_CONNECTION_LOCAL_OPEN: handler->on_connection_local_open(*this); break;
-          case PN_CONNECTION_LOCAL_CLOSE: handler->on_connection_local_close(*this); break;
-          case PN_CONNECTION_REMOTE_OPEN: handler->on_connection_remote_open(*this); break;
-          case PN_CONNECTION_REMOTE_CLOSE: handler->on_connection_remote_close(*this);
break;
-          case PN_CONNECTION_FINAL: handler->on_connection_final(*this); break;
-
-          case PN_SESSION_INIT: handler->on_session_init(*this); break;
-          case PN_SESSION_LOCAL_OPEN: handler->on_session_local_open(*this); break;
-          case PN_SESSION_LOCAL_CLOSE: handler->on_session_local_close(*this); break;
-          case PN_SESSION_REMOTE_OPEN: handler->on_session_remote_open(*this); break;
-          case PN_SESSION_REMOTE_CLOSE: handler->on_session_remote_close(*this); break;
-          case PN_SESSION_FINAL: handler->on_session_final(*this); break;
-
-          case PN_LINK_INIT: handler->on_link_init(*this); break;
-          case PN_LINK_LOCAL_OPEN: handler->on_link_local_open(*this); break;
-          case PN_LINK_LOCAL_CLOSE: handler->on_link_local_close(*this); break;
-          case PN_LINK_LOCAL_DETACH: handler->on_link_local_detach(*this); break;
-          case PN_LINK_REMOTE_OPEN: handler->on_link_remote_open(*this); break;
-          case PN_LINK_REMOTE_CLOSE: handler->on_link_remote_close(*this); break;
-          case PN_LINK_REMOTE_DETACH: handler->on_link_remote_detach(*this); break;
-          case PN_LINK_FLOW: handler->on_link_flow(*this); break;
-          case PN_LINK_FINAL: handler->on_link_final(*this); break;
-
-          case PN_DELIVERY: handler->on_delivery(*this); break;
-
-          case PN_TRANSPORT: handler->on_transport(*this); break;
-          case PN_TRANSPORT_ERROR: handler->on_transport_error(*this); break;
-          case PN_TRANSPORT_HEAD_CLOSED: handler->on_transport_head_closed(*this); break;
-          case PN_TRANSPORT_TAIL_CLOSED: handler->on_transport_tail_closed(*this); break;
-          case PN_TRANSPORT_CLOSED: handler->on_transport_closed(*this); break;
-
-          case PN_SELECTABLE_INIT: handler->on_selectable_init(*this); break;
-          case PN_SELECTABLE_UPDATED: handler->on_selectable_updated(*this); break;
-          case PN_SELECTABLE_READABLE: handler->on_selectable_readable(*this); break;
-          case PN_SELECTABLE_WRITABLE: handler->on_selectable_writable(*this); break;
-          case PN_SELECTABLE_EXPIRED: handler->on_selectable_expired(*this); break;
-          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_));
-        }
-    } else {
-        h.on_unhandled(*this);
+void proton_event::dispatch(proton_handler &handler) {
+    switch(type_) {
+
+      case PN_REACTOR_INIT: handler.on_reactor_init(*this); break;
+      case PN_REACTOR_QUIESCED: handler.on_reactor_quiesced(*this); break;
+      case PN_REACTOR_FINAL: handler.on_reactor_final(*this); break;
+
+      case PN_TIMER_TASK: handler.on_timer_task(*this); break;
+
+      case PN_CONNECTION_INIT: handler.on_connection_init(*this); break;
+      case PN_CONNECTION_BOUND: handler.on_connection_bound(*this); break;
+      case PN_CONNECTION_UNBOUND: handler.on_connection_unbound(*this); break;
+      case PN_CONNECTION_LOCAL_OPEN: handler.on_connection_local_open(*this); break;
+      case PN_CONNECTION_LOCAL_CLOSE: handler.on_connection_local_close(*this); break;
+      case PN_CONNECTION_REMOTE_OPEN: handler.on_connection_remote_open(*this); break;
+      case PN_CONNECTION_REMOTE_CLOSE: handler.on_connection_remote_close(*this); break;
+      case PN_CONNECTION_FINAL: handler.on_connection_final(*this); break;
+
+      case PN_SESSION_INIT: handler.on_session_init(*this); break;
+      case PN_SESSION_LOCAL_OPEN: handler.on_session_local_open(*this); break;
+      case PN_SESSION_LOCAL_CLOSE: handler.on_session_local_close(*this); break;
+      case PN_SESSION_REMOTE_OPEN: handler.on_session_remote_open(*this); break;
+      case PN_SESSION_REMOTE_CLOSE: handler.on_session_remote_close(*this); break;
+      case PN_SESSION_FINAL: handler.on_session_final(*this); break;
+
+      case PN_LINK_INIT: handler.on_link_init(*this); break;
+      case PN_LINK_LOCAL_OPEN: handler.on_link_local_open(*this); break;
+      case PN_LINK_LOCAL_CLOSE: handler.on_link_local_close(*this); break;
+      case PN_LINK_LOCAL_DETACH: handler.on_link_local_detach(*this); break;
+      case PN_LINK_REMOTE_OPEN: handler.on_link_remote_open(*this); break;
+      case PN_LINK_REMOTE_CLOSE: handler.on_link_remote_close(*this); break;
+      case PN_LINK_REMOTE_DETACH: handler.on_link_remote_detach(*this); break;
+      case PN_LINK_FLOW: handler.on_link_flow(*this); break;
+      case PN_LINK_FINAL: handler.on_link_final(*this); break;
+
+      case PN_DELIVERY: handler.on_delivery(*this); break;
+
+      case PN_TRANSPORT: handler.on_transport(*this); break;
+      case PN_TRANSPORT_ERROR: handler.on_transport_error(*this); break;
+      case PN_TRANSPORT_HEAD_CLOSED: handler.on_transport_head_closed(*this); break;
+      case PN_TRANSPORT_TAIL_CLOSED: handler.on_transport_tail_closed(*this); break;
+      case PN_TRANSPORT_CLOSED: handler.on_transport_closed(*this); break;
+
+      case PN_SELECTABLE_INIT: handler.on_selectable_init(*this); break;
+      case PN_SELECTABLE_UPDATED: handler.on_selectable_updated(*this); break;
+      case PN_SELECTABLE_READABLE: handler.on_selectable_readable(*this); break;
+      case PN_SELECTABLE_WRITABLE: handler.on_selectable_writable(*this); break;
+      case PN_SELECTABLE_EXPIRED: handler.on_selectable_expired(*this); break;
+      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_));
     }
 
     // recurse through children
-    for (handler::iterator child = h.children_.begin(); child != h.children_.end(); ++child)
{
+    for (proton_handler::iterator child = handler.children_.begin(); child != handler.children_.end();
++child) {
         dispatch(**child);
     }
 }
 
-const proton_event::event_type proton_event::EVENT_NONE=PN_EVENT_NONE;
-const proton_event::event_type proton_event::REACTOR_INIT=PN_REACTOR_INIT;
-const proton_event::event_type proton_event::REACTOR_QUIESCED=PN_REACTOR_QUIESCED;
-const proton_event::event_type proton_event::REACTOR_FINAL=PN_REACTOR_FINAL;
-const proton_event::event_type proton_event::TIMER_TASK=PN_TIMER_TASK;
-const proton_event::event_type proton_event::CONNECTION_INIT=PN_CONNECTION_INIT;
-const proton_event::event_type proton_event::CONNECTION_BOUND=PN_CONNECTION_BOUND;
-const proton_event::event_type proton_event::CONNECTION_UNBOUND=PN_CONNECTION_UNBOUND;
-const proton_event::event_type proton_event::CONNECTION_LOCAL_OPEN=PN_CONNECTION_LOCAL_OPEN;
-const proton_event::event_type proton_event::CONNECTION_REMOTE_OPEN=PN_CONNECTION_REMOTE_OPEN;
-const proton_event::event_type proton_event::CONNECTION_LOCAL_CLOSE=PN_CONNECTION_LOCAL_CLOSE;
-const proton_event::event_type proton_event::CONNECTION_REMOTE_CLOSE=PN_CONNECTION_REMOTE_CLOSE;
-const proton_event::event_type proton_event::CONNECTION_FINAL=PN_CONNECTION_FINAL;
-const proton_event::event_type proton_event::SESSION_INIT=PN_SESSION_INIT;
-const proton_event::event_type proton_event::SESSION_LOCAL_OPEN=PN_SESSION_LOCAL_OPEN;
-const proton_event::event_type proton_event::SESSION_REMOTE_OPEN=PN_SESSION_REMOTE_OPEN;
-const proton_event::event_type proton_event::SESSION_LOCAL_CLOSE=PN_SESSION_LOCAL_CLOSE;
-const proton_event::event_type proton_event::SESSION_REMOTE_CLOSE=PN_SESSION_REMOTE_CLOSE;
-const proton_event::event_type proton_event::SESSION_FINAL=PN_SESSION_FINAL;
-const proton_event::event_type proton_event::LINK_INIT=PN_LINK_INIT;
-const proton_event::event_type proton_event::LINK_LOCAL_OPEN=PN_LINK_LOCAL_OPEN;
-const proton_event::event_type proton_event::LINK_REMOTE_OPEN=PN_LINK_REMOTE_OPEN;
-const proton_event::event_type proton_event::LINK_LOCAL_CLOSE=PN_LINK_LOCAL_CLOSE;
-const proton_event::event_type proton_event::LINK_REMOTE_CLOSE=PN_LINK_REMOTE_CLOSE;
-const proton_event::event_type proton_event::LINK_LOCAL_DETACH=PN_LINK_LOCAL_DETACH;
-const proton_event::event_type proton_event::LINK_REMOTE_DETACH=PN_LINK_REMOTE_DETACH;
-const proton_event::event_type proton_event::LINK_FLOW=PN_LINK_FLOW;
-const proton_event::event_type proton_event::LINK_FINAL=PN_LINK_FINAL;
-const proton_event::event_type proton_event::DELIVERY=PN_DELIVERY;
-const proton_event::event_type proton_event::TRANSPORT=PN_TRANSPORT;
-const proton_event::event_type proton_event::TRANSPORT_AUTHENTICATED=PN_TRANSPORT_AUTHENTICATED;
-const proton_event::event_type proton_event::TRANSPORT_ERROR=PN_TRANSPORT_ERROR;
-const proton_event::event_type proton_event::TRANSPORT_HEAD_CLOSED=PN_TRANSPORT_HEAD_CLOSED;
-const proton_event::event_type proton_event::TRANSPORT_TAIL_CLOSED=PN_TRANSPORT_TAIL_CLOSED;
-const proton_event::event_type proton_event::TRANSPORT_CLOSED=PN_TRANSPORT_CLOSED;
-const proton_event::event_type proton_event::SELECTABLE_INIT=PN_SELECTABLE_INIT;
-const proton_event::event_type proton_event::SELECTABLE_UPDATED=PN_SELECTABLE_UPDATED;
-const proton_event::event_type proton_event::SELECTABLE_READABLE=PN_SELECTABLE_READABLE;
-const proton_event::event_type proton_event::SELECTABLE_WRITABLE=PN_SELECTABLE_WRITABLE;
-const proton_event::event_type proton_event::SELECTABLE_ERROR=PN_SELECTABLE_ERROR;
-const proton_event::event_type proton_event::SELECTABLE_EXPIRED=PN_SELECTABLE_EXPIRED;
-const proton_event::event_type proton_event::SELECTABLE_FINAL=PN_SELECTABLE_FINAL;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/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 d65dc70..f40e02a 100644
--- a/proton-c/bindings/cpp/src/proton_event.hpp
+++ b/proton-c/bindings/cpp/src/proton_event.hpp
@@ -24,269 +24,267 @@
 #include "proton/event.hpp"
 #include "proton/link.hpp"
 
-struct pn_event_t;
+#include "proton/event.h"
 
 namespace proton {
 
-class handler;
+class proton_handler;
 class container;
 class connection;
 
 /** Event information for a proton::proton_handler */
-class proton_event : public event
+class proton_event
 {
   public:
-
-    std::string name() const;
-
+    /// The type of an event
+    enum event_type {
     ///@name Event types
     ///@{
 
-    /// The type of an event
-    typedef int event_type;
-
-    /**
-     * Defined as a programming convenience. No event of this type will
-     * ever be generated.
-     */
-    static const event_type EVENT_NONE;
-
-    /**
-     * A reactor has been started. Events of this type point to the reactor.
-     */
-    static const event_type REACTOR_INIT;
-
-    /**
-     * A reactor has no more events to process. Events of this type
-     * point to the reactor.
-     */
-    static const event_type REACTOR_QUIESCED;
-
-    /**
-     * A reactor has been stopped. Events of this type point to the reactor.
-     */
-    static const event_type REACTOR_FINAL;
-
-    /**
-     * A timer event has occurred.
-     */
-    static const event_type TIMER_TASK;
-
-    /**
-     * The connection has been created. This is the first event that
-     * will ever be issued for a connection. Events of this type point
-     * to the relevant connection.
-     */
-    static const event_type CONNECTION_INIT;
-
-    /**
-     * The connection has been bound to a transport. This event is
-     * issued when the transport::bind() is called.
-     */
-    static const event_type CONNECTION_BOUND;
-
-    /**
-     * The connection has been unbound from its transport. This event is
-     * issued when transport::unbind() is called.
-     */
-    static const event_type CONNECTION_UNBOUND;
-
-    /**
-     * The local connection endpoint has been closed. Events of this
-     * type point to the relevant connection.
-     */
-    static const event_type CONNECTION_LOCAL_OPEN;
-
-    /**
-     * The remote endpoint has opened the connection. Events of this
-     * type point to the relevant connection.
-     */
-    static const event_type CONNECTION_REMOTE_OPEN;
-
-    /**
-     * The local connection endpoint has been closed. Events of this
-     * type point to the relevant connection.
-     */
-    static const event_type CONNECTION_LOCAL_CLOSE;
-
-    /**
-     *  The remote endpoint has closed the connection. Events of this
-     *  type point to the relevant connection.
-     */
-    static const event_type CONNECTION_REMOTE_CLOSE;
-
-    /**
-     * The connection has been freed and any outstanding processing has
-     * been completed. This is the final event that will ever be issued
-     * for a connection.
-     */
-    static const event_type CONNECTION_FINAL;
-
-    /**
-     * The session has been created. This is the first event that will
-     * ever be issued for a session.
-     */
-    static const event_type SESSION_INIT;
-
-    /**
-     * The local session endpoint has been opened. Events of this type
-     * point to the relevant session.
-     */
-    static const event_type SESSION_LOCAL_OPEN;
-
-    /**
-     * The remote endpoint has opened the session. Events of this type
-     * point to the relevant session.
-     */
-    static const event_type SESSION_REMOTE_OPEN;
-
-    /**
-     * The local session endpoint has been closed. Events of this type
-     * point ot the relevant session.
-     */
-    static const event_type SESSION_LOCAL_CLOSE;
-
-    /**
-     * The remote endpoint has closed the session. Events of this type
-     * point to the relevant session.
-     */
-    static const event_type SESSION_REMOTE_CLOSE;
-
-    /**
-     * The session has been freed and any outstanding processing has
-     * been completed. This is the final event that will ever be issued
-     * for a session.
-     */
-    static const event_type SESSION_FINAL;
-
-    /**
-     * The link has been created. This is the first event that will ever
-     * be issued for a link.
-     */
-    static const event_type LINK_INIT;
-
-    /**
-     * The local link endpoint has been opened. Events of this type
-     * point ot the relevant link.
-     */
-    static const event_type LINK_LOCAL_OPEN;
-
-    /**
-     * The remote endpoint has opened the link. Events of this type
-     * point to the relevant link.
-     */
-    static const event_type LINK_REMOTE_OPEN;
-
-    /**
-     * The local link endpoint has been closed. Events of this type
-     * point ot the relevant link.
-     */
-    static const event_type LINK_LOCAL_CLOSE;
-
-    /**
-     * The remote endpoint has closed the link. Events of this type
-     * point to the relevant link.
-     */
-    static const event_type LINK_REMOTE_CLOSE;
-
-    /**
-     * The local link endpoint has been detached. Events of this type
-     * point to the relevant link.
-     */
-    static const event_type LINK_LOCAL_DETACH;
-
-    /**
-     * The remote endpoint has detached the link. Events of this type
-     * point to the relevant link.
-     */
-    static const event_type LINK_REMOTE_DETACH;
-
-    /**
-     * The flow control state for a link has changed. Events of this
-     * type point to the relevant link.
-     */
-    static const event_type LINK_FLOW;
-
-    /**
-     * The link has been freed and any outstanding processing has been
-     * completed. This is the final event that will ever be issued for a
-     * link. Events of this type point to the relevant link.
-     */
-    static const event_type LINK_FINAL;
-
-    /**
-     * A delivery has been created or updated. Events of this type point
-     * to the relevant delivery.
-     */
-    static const event_type DELIVERY;
-
-    /**
-     * The transport has new data to read and/or write. Events of this
-     * type point to the relevant transport.
-     */
-    static const event_type TRANSPORT;
-
-    /**
-     * The transport has authenticated, if this is received by a server
-     * the associated transport has authenticated an incoming connection
-     * and transport::user() can be used to obtain the authenticated
-     * user.
-     */
-    static const event_type TRANSPORT_AUTHENTICATED;
-
-    /**
-     * Indicates that a transport error has occurred. Use
-     * transport::condition() to access the details of the error
-     * from the associated transport.
-     */
-    static const event_type TRANSPORT_ERROR;
-
-    /**
-     * Indicates that the head of the transport has been closed. This
-     * means the transport will never produce more bytes for output to
-     * the network. Events of this type point to the relevant transport.
-     */
-    static const event_type TRANSPORT_HEAD_CLOSED;
-
-    /**
-     * Indicates that the tail of the transport has been closed. This
-     * means the transport will never be able to process more bytes from
-     * the network. Events of this type point to the relevant transport.
-     */
-    static const event_type TRANSPORT_TAIL_CLOSED;
-
-    /**
-     * Indicates that the both the head and tail of the transport are
-     * closed. Events of this type point to the relevant transport.
-     */
-    static const event_type TRANSPORT_CLOSED;
-
-    static const event_type SELECTABLE_INIT;
-    static const event_type SELECTABLE_UPDATED;
-    static const event_type SELECTABLE_READABLE;
-    static const event_type SELECTABLE_WRITABLE;
-    static const event_type SELECTABLE_ERROR;
-    static const event_type SELECTABLE_EXPIRED;
-    static const event_type SELECTABLE_FINAL;
-
+      /**
+      * Defined as a programming convenience. No event of this type will
+      * ever be generated.
+      */
+      EVENT_NONE=PN_EVENT_NONE,
+
+      /**
+      * A reactor has been started. Events of this type point to the reactor.
+      */
+      REACTOR_INIT=PN_REACTOR_INIT,
+
+      /**
+      * A reactor has no more events to process. Events of this type
+      * point to the reactor.
+      */
+      REACTOR_QUIESCED=PN_REACTOR_QUIESCED,
+
+      /**
+      * A reactor has been stopped. Events of this type point to the reactor.
+      */
+      REACTOR_FINAL=PN_REACTOR_FINAL,
+
+      /**
+      * A timer event has occurred.
+      */
+      TIMER_TASK=PN_TIMER_TASK,
+
+      /**
+      * The connection has been created. This is the first event that
+      * will ever be issued for a connection. Events of this type point
+      * to the relevant connection.
+      */
+      CONNECTION_INIT=PN_CONNECTION_INIT,
+
+      /**
+      * The connection has been bound to a transport. This event is
+      * issued when the transport::bind() is called.
+      */
+      CONNECTION_BOUND=PN_CONNECTION_BOUND,
+
+      /**
+      * The connection has been unbound from its transport. This event is
+      * issued when transport::unbind() is called.
+      */
+      CONNECTION_UNBOUND=PN_CONNECTION_UNBOUND,
+
+      /**
+      * The local connection endpoint has been closed. Events of this
+      * type point to the relevant connection.
+      */
+      CONNECTION_LOCAL_OPEN=PN_CONNECTION_LOCAL_OPEN,
+
+      /**
+      * The remote endpoint has opened the connection. Events of this
+      * type point to the relevant connection.
+      */
+      CONNECTION_REMOTE_OPEN=PN_CONNECTION_REMOTE_OPEN,
+
+      /**
+      * The local connection endpoint has been closed. Events of this
+      * type point to the relevant connection.
+      */
+      CONNECTION_LOCAL_CLOSE=PN_CONNECTION_LOCAL_CLOSE,
+
+      /**
+      *  The remote endpoint has closed the connection. Events of this
+      *  type point to the relevant connection.
+      */
+      CONNECTION_REMOTE_CLOSE=PN_CONNECTION_REMOTE_CLOSE,
+
+      /**
+      * The connection has been freed and any outstanding processing has
+      * been completed. This is the final event that will ever be issued
+      * for a connection.
+      */
+      CONNECTION_FINAL=PN_CONNECTION_FINAL,
+
+      /**
+      * The session has been created. This is the first event that will
+      * ever be issued for a session.
+      */
+      SESSION_INIT=PN_SESSION_INIT,
+
+      /**
+      * The local session endpoint has been opened. Events of this type
+      * point to the relevant session.
+      */
+      SESSION_LOCAL_OPEN=PN_SESSION_LOCAL_OPEN,
+
+      /**
+      * The remote endpoint has opened the session. Events of this type
+      * point to the relevant session.
+      */
+      SESSION_REMOTE_OPEN=PN_SESSION_REMOTE_OPEN,
+
+      /**
+      * The local session endpoint has been closed. Events of this type
+      * point ot the relevant session.
+      */
+      SESSION_LOCAL_CLOSE=PN_SESSION_LOCAL_CLOSE,
+
+      /**
+      * The remote endpoint has closed the session. Events of this type
+      * point to the relevant session.
+      */
+      SESSION_REMOTE_CLOSE=PN_SESSION_REMOTE_CLOSE,
+
+      /**
+      * The session has been freed and any outstanding processing has
+      * been completed. This is the final event that will ever be issued
+      * for a session.
+      */
+      SESSION_FINAL=PN_SESSION_FINAL,
+
+      /**
+      * The link has been created. This is the first event that will ever
+      * be issued for a link.
+      */
+      LINK_INIT=PN_LINK_INIT,
+
+      /**
+      * The local link endpoint has been opened. Events of this type
+      * point ot the relevant link.
+      */
+      LINK_LOCAL_OPEN=PN_LINK_LOCAL_OPEN,
+
+      /**
+      * The remote endpoint has opened the link. Events of this type
+      * point to the relevant link.
+      */
+      LINK_REMOTE_OPEN=PN_LINK_REMOTE_OPEN,
+
+      /**
+      * The local link endpoint has been closed. Events of this type
+      * point ot the relevant link.
+      */
+      LINK_LOCAL_CLOSE=PN_LINK_LOCAL_CLOSE,
+
+      /**
+      * The remote endpoint has closed the link. Events of this type
+      * point to the relevant link.
+      */
+      LINK_REMOTE_CLOSE=PN_LINK_REMOTE_CLOSE,
+
+      /**
+      * The local link endpoint has been detached. Events of this type
+      * point to the relevant link.
+      */
+      LINK_LOCAL_DETACH=PN_LINK_LOCAL_DETACH,
+
+      /**
+      * The remote endpoint has detached the link. Events of this type
+      * point to the relevant link.
+      */
+      LINK_REMOTE_DETACH=PN_LINK_REMOTE_DETACH,
+
+      /**
+      * The flow control state for a link has changed. Events of this
+      * type point to the relevant link.
+      */
+      LINK_FLOW=PN_LINK_FLOW,
+
+      /**
+      * The link has been freed and any outstanding processing has been
+      * completed. This is the final event that will ever be issued for a
+      * link. Events of this type point to the relevant link.
+      */
+      LINK_FINAL=PN_LINK_FINAL,
+
+      /**
+      * A delivery has been created or updated. Events of this type point
+      * to the relevant delivery.
+      */
+      DELIVERY=PN_DELIVERY,
+
+      /**
+      * The transport has new data to read and/or write. Events of this
+      * type point to the relevant transport.
+      */
+      TRANSPORT=PN_TRANSPORT,
+
+      /**
+      * The transport has authenticated, if this is received by a server
+      * the associated transport has authenticated an incoming connection
+      * and transport::user() can be used to obtain the authenticated
+      * user.
+      */
+      TRANSPORT_AUTHENTICATED=PN_TRANSPORT_AUTHENTICATED,
+
+      /**
+      * Indicates that a transport error has occurred. Use
+      * transport::condition() to access the details of the error
+      * from the associated transport.
+      */
+      TRANSPORT_ERROR=PN_TRANSPORT_ERROR,
+
+      /**
+      * Indicates that the head of the transport has been closed. This
+      * means the transport will never produce more bytes for output to
+      * the network. Events of this type point to the relevant transport.
+      */
+      TRANSPORT_HEAD_CLOSED=PN_TRANSPORT_HEAD_CLOSED,
+
+      /**
+      * Indicates that the tail of the transport has been closed. This
+      * means the transport will never be able to process more bytes from
+      * the network. Events of this type point to the relevant transport.
+      */
+      TRANSPORT_TAIL_CLOSED=PN_TRANSPORT_TAIL_CLOSED,
+
+      /**
+      * Indicates that the both the head and tail of the transport are
+      * closed. Events of this type point to the relevant transport.
+      */
+      TRANSPORT_CLOSED=PN_TRANSPORT_CLOSED,
+
+      SELECTABLE_INIT=PN_SELECTABLE_INIT,
+      SELECTABLE_UPDATED=PN_SELECTABLE_UPDATED,
+      SELECTABLE_READABLE=PN_SELECTABLE_READABLE,
+      SELECTABLE_WRITABLE=PN_SELECTABLE_WRITABLE,
+      SELECTABLE_ERROR=PN_SELECTABLE_ERROR,
+      SELECTABLE_EXPIRED=PN_SELECTABLE_EXPIRED,
+      SELECTABLE_FINAL=PN_SELECTABLE_FINAL
+    };
     ///@}
 
-    virtual void dispatch(handler &h);
-    virtual class container& container() const;
-    virtual class connection connection() const;
-    virtual class sender sender() const;
-    virtual class receiver receiver() const;
-    virtual class link link() const;
-    virtual class delivery delivery() const;
+    proton_event(pn_event_t *, pn_event_type_t, class container*);
+
+    std::string name() const;
+
+    void dispatch(proton_handler& h);
+
+    class container& container() const;
+    class connection connection() const;
+    class sender sender() const;
+    class receiver receiver() const;
+    class link link() const;
+    class delivery delivery() const;
 
     /** Get type of event */
     event_type type() const;
 
     pn_event_t* pn_event() const;
 
-  protected:
-    proton_event(pn_event_t *, proton_event::event_type, class container*);
-
   private:
     mutable pn_event_t *pn_event_;
     event_type type_;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/proton_handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_handler.cpp b/proton-c/bindings/cpp/src/proton_handler.cpp
index 37030c9..b361863 100644
--- a/proton-c/bindings/cpp/src/proton_handler.cpp
+++ b/proton-c/bindings/cpp/src/proton_handler.cpp
@@ -18,56 +18,62 @@
  * under the License.
  *
  */
-#include "proton/proton_handler.hpp"
+#include "proton_handler.hpp"
 #include "proton_event.hpp"
 
 namespace proton {
 
-proton_handler::proton_handler(){}
+proton_handler::proton_handler() {}
+proton_handler::~proton_handler() {}
 
 // Everything goes to on_unhandled() unless overriden by subclass
 
-void proton_handler::on_reactor_init(event &e) { on_unhandled(e); }
-void proton_handler::on_reactor_quiesced(event &e) { on_unhandled(e); }
-void proton_handler::on_reactor_final(event &e) { on_unhandled(e); }
-void proton_handler::on_timer_task(event &e) { on_unhandled(e); }
-void proton_handler::on_connection_init(event &e) { on_unhandled(e); }
-void proton_handler::on_connection_bound(event &e) { on_unhandled(e); }
-void proton_handler::on_connection_unbound(event &e) { on_unhandled(e); }
-void proton_handler::on_connection_local_open(event &e) { on_unhandled(e); }
-void proton_handler::on_connection_local_close(event &e) { on_unhandled(e); }
-void proton_handler::on_connection_remote_open(event &e) { on_unhandled(e); }
-void proton_handler::on_connection_remote_close(event &e) { on_unhandled(e); }
-void proton_handler::on_connection_final(event &e) { on_unhandled(e); }
-void proton_handler::on_session_init(event &e) { on_unhandled(e); }
-void proton_handler::on_session_local_open(event &e) { on_unhandled(e); }
-void proton_handler::on_session_local_close(event &e) { on_unhandled(e); }
-void proton_handler::on_session_remote_open(event &e) { on_unhandled(e); }
-void proton_handler::on_session_remote_close(event &e) { on_unhandled(e); }
-void proton_handler::on_session_final(event &e) { on_unhandled(e); }
-void proton_handler::on_link_init(event &e) { on_unhandled(e); }
-void proton_handler::on_link_local_open(event &e) { on_unhandled(e); }
-void proton_handler::on_link_local_close(event &e) { on_unhandled(e); }
-void proton_handler::on_link_local_detach(event &e) { on_unhandled(e); }
-void proton_handler::on_link_remote_open(event &e) { on_unhandled(e); }
-void proton_handler::on_link_remote_close(event &e) { on_unhandled(e); }
-void proton_handler::on_link_remote_detach(event &e) { on_unhandled(e); }
-void proton_handler::on_link_flow(event &e) { on_unhandled(e); }
-void proton_handler::on_link_final(event &e) { on_unhandled(e); }
-void proton_handler::on_delivery(event &e) { on_unhandled(e); }
-void proton_handler::on_transport(event &e) { on_unhandled(e); }
-void proton_handler::on_transport_error(event &e) { on_unhandled(e); }
-void proton_handler::on_transport_head_closed(event &e) { on_unhandled(e); }
-void proton_handler::on_transport_tail_closed(event &e) { on_unhandled(e); }
-void proton_handler::on_transport_closed(event &e) { on_unhandled(e); }
-void proton_handler::on_selectable_init(event &e) { on_unhandled(e); }
-void proton_handler::on_selectable_updated(event &e) { on_unhandled(e); }
-void proton_handler::on_selectable_readable(event &e) { on_unhandled(e); }
-void proton_handler::on_selectable_writable(event &e) { on_unhandled(e); }
-void proton_handler::on_selectable_expired(event &e) { on_unhandled(e); }
-void proton_handler::on_selectable_error(event &e) { on_unhandled(e); }
-void proton_handler::on_selectable_final(event &e) { on_unhandled(e); }
+void proton_handler::on_reactor_init(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_reactor_quiesced(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_reactor_final(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_timer_task(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_connection_init(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_connection_bound(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_connection_unbound(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_connection_local_open(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_connection_local_close(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_connection_remote_open(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_connection_remote_close(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_connection_final(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_session_init(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_session_local_open(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_session_local_close(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_session_remote_open(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_session_remote_close(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_session_final(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_link_init(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_link_local_open(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_link_local_close(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_link_local_detach(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_link_remote_open(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_link_remote_close(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_link_remote_detach(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_link_flow(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_link_final(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_delivery(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_transport(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_transport_error(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_transport_head_closed(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_transport_tail_closed(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_transport_closed(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_init(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_updated(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_readable(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_writable(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_expired(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_error(proton_event &e) { on_unhandled(e); }
+void proton_handler::on_selectable_final(proton_event &e) { on_unhandled(e); }
+
+void proton_handler::on_unhandled(proton_event &) {}
+
+void proton_handler::add_child_handler(proton_handler &e) {
+  children_.push_back(&e);
+}
 
-void proton_handler::on_unhandled(event &) {}
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/proton_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_handler.hpp b/proton-c/bindings/cpp/src/proton_handler.hpp
new file mode 100644
index 0000000..09b170d
--- /dev/null
+++ b/proton-c/bindings/cpp/src/proton_handler.hpp
@@ -0,0 +1,104 @@
+#ifndef PROTON_CPP_PROTONHANDLER_H
+#define PROTON_CPP_PROTONHANDLER_H
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "proton/export.hpp"
+#include "proton/object.hpp"
+
+#include <vector>
+
+struct pn_handler_t;
+
+namespace proton {
+
+class event;
+class proton_event;
+
+/// Handler base class, subclass and over-ride event handling member functions.
+/// @see proton::proton_event for meaning of events.
+class proton_handler
+{
+  public:
+    PN_CPP_EXTERN proton_handler();
+    PN_CPP_EXTERN virtual ~proton_handler();
+
+    ///@name Over-ride these member functions to handle events
+    ///@{
+    PN_CPP_EXTERN virtual void on_reactor_init(proton_event &e);
+    PN_CPP_EXTERN virtual void on_reactor_quiesced(proton_event &e);
+    PN_CPP_EXTERN virtual void on_reactor_final(proton_event &e);
+    PN_CPP_EXTERN virtual void on_timer_task(proton_event &e);
+    PN_CPP_EXTERN virtual void on_connection_init(proton_event &e);
+    PN_CPP_EXTERN virtual void on_connection_bound(proton_event &e);
+    PN_CPP_EXTERN virtual void on_connection_unbound(proton_event &e);
+    PN_CPP_EXTERN virtual void on_connection_local_open(proton_event &e);
+    PN_CPP_EXTERN virtual void on_connection_local_close(proton_event &e);
+    PN_CPP_EXTERN virtual void on_connection_remote_open(proton_event &e);
+    PN_CPP_EXTERN virtual void on_connection_remote_close(proton_event &e);
+    PN_CPP_EXTERN virtual void on_connection_final(proton_event &e);
+    PN_CPP_EXTERN virtual void on_session_init(proton_event &e);
+    PN_CPP_EXTERN virtual void on_session_local_open(proton_event &e);
+    PN_CPP_EXTERN virtual void on_session_local_close(proton_event &e);
+    PN_CPP_EXTERN virtual void on_session_remote_open(proton_event &e);
+    PN_CPP_EXTERN virtual void on_session_remote_close(proton_event &e);
+    PN_CPP_EXTERN virtual void on_session_final(proton_event &e);
+    PN_CPP_EXTERN virtual void on_link_init(proton_event &e);
+    PN_CPP_EXTERN virtual void on_link_local_open(proton_event &e);
+    PN_CPP_EXTERN virtual void on_link_local_close(proton_event &e);
+    PN_CPP_EXTERN virtual void on_link_local_detach(proton_event &e);
+    PN_CPP_EXTERN virtual void on_link_remote_open(proton_event &e);
+    PN_CPP_EXTERN virtual void on_link_remote_close(proton_event &e);
+    PN_CPP_EXTERN virtual void on_link_remote_detach(proton_event &e);
+    PN_CPP_EXTERN virtual void on_link_flow(proton_event &e);
+    PN_CPP_EXTERN virtual void on_link_final(proton_event &e);
+    PN_CPP_EXTERN virtual void on_delivery(proton_event &e);
+    PN_CPP_EXTERN virtual void on_transport(proton_event &e);
+    PN_CPP_EXTERN virtual void on_transport_error(proton_event &e);
+    PN_CPP_EXTERN virtual void on_transport_head_closed(proton_event &e);
+    PN_CPP_EXTERN virtual void on_transport_tail_closed(proton_event &e);
+    PN_CPP_EXTERN virtual void on_transport_closed(proton_event &e);
+    PN_CPP_EXTERN virtual void on_selectable_init(proton_event &e);
+    PN_CPP_EXTERN virtual void on_selectable_updated(proton_event &e);
+    PN_CPP_EXTERN virtual void on_selectable_readable(proton_event &e);
+    PN_CPP_EXTERN virtual void on_selectable_writable(proton_event &e);
+    PN_CPP_EXTERN virtual void on_selectable_expired(proton_event &e);
+    PN_CPP_EXTERN virtual void on_selectable_error(proton_event &e);
+    PN_CPP_EXTERN virtual void on_selectable_final(proton_event &e);
+    PN_CPP_EXTERN virtual void on_unhandled(proton_event &e);
+    ///@}
+
+    /// Add a child handler, equivalent to this->push_back(&h)
+    /// h must not be deleted before this handler.
+    void add_child_handler(proton_handler &h);
+
+  private:
+    std::vector<proton_handler*> children_;
+    typedef std::vector<proton_handler*>::iterator iterator;
+    friend class proton_event;
+    pn_ptr<pn_handler_t> pn_handler_;
+    friend class container_impl;
+};
+
+}
+
+#endif  /*!PROTON_CPP_PROTONHANDLER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/tests/tools/apps/cpp/reactor_send.cpp
----------------------------------------------------------------------
diff --git a/tests/tools/apps/cpp/reactor_send.cpp b/tests/tools/apps/cpp/reactor_send.cpp
index 9170442..29c78a0 100644
--- a/tests/tools/apps/cpp/reactor_send.cpp
+++ b/tests/tools/apps/cpp/reactor_send.cpp
@@ -25,6 +25,7 @@
 #include "proton/messaging_handler.hpp"
 #include "proton/connection.hpp"
 #include "proton/decoder.hpp"
+#include "proton/event.hpp"
 #include "proton/reactor.h"
 #include "proton/value.hpp"
 


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


Mime
View raw message