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/01/20 16:05:51 UTC
[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
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
[3/5] qpid-proton git commit: PROTON-1083: [C++ binding] Renamed
messaging_handler as simply handler - Now the API visible objects are
proton::event & proton::handler
Posted by as...@apache.org.
PROTON-1083: [C++ binding] Renamed messaging_handler as simply handler
- Now the API visible objects are proton::event & proton::handler
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3faacc52
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3faacc52
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3faacc52
Branch: refs/heads/master
Commit: 3faacc5258d957fbf1e4c3f0efebffb7a001ef03
Parents: d5c68c4
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Jan 19 15:41:40 2016 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Jan 20 00:55:55 2016 -0500
----------------------------------------------------------------------
examples/cpp/broker.cpp | 2 +-
examples/cpp/broker.hpp | 4 +-
examples/cpp/client.cpp | 4 +-
examples/cpp/connection_options.cpp | 6 +-
examples/cpp/direct_recv.cpp | 4 +-
examples/cpp/direct_send.cpp | 4 +-
examples/cpp/helloworld.cpp | 4 +-
examples/cpp/helloworld_direct.cpp | 4 +-
examples/cpp/queue_browser.cpp | 4 +-
examples/cpp/recurring_timer.cpp | 8 +-
examples/cpp/selected_recv.cpp | 4 +-
examples/cpp/server.cpp | 4 +-
examples/cpp/server_direct.cpp | 4 +-
examples/cpp/simple_recv.cpp | 4 +-
examples/cpp/simple_send.cpp | 4 +-
examples/cpp/ssl.cpp | 6 +-
examples/cpp/ssl_client_cert.cpp | 6 +-
proton-c/bindings/cpp/CMakeLists.txt | 2 +-
.../cpp/include/proton/connection_engine.hpp | 4 +-
.../cpp/include/proton/connection_options.hpp | 2 +-
.../bindings/cpp/include/proton/container.hpp | 6 +-
.../bindings/cpp/include/proton/handler.hpp | 98 ++++++++++++++++++++
.../cpp/include/proton/link_options.hpp | 2 +-
.../cpp/include/proton/messaging_handler.hpp | 98 --------------------
.../cpp/include/proton/request_response.hpp | 2 +-
.../cpp/src/blocking_connection_impl.cpp | 4 +-
.../cpp/src/blocking_connection_impl.hpp | 4 +-
proton-c/bindings/cpp/src/blocking_fetcher.cpp | 2 +-
proton-c/bindings/cpp/src/blocking_fetcher.hpp | 4 +-
proton-c/bindings/cpp/src/connection_engine.cpp | 4 +-
.../bindings/cpp/src/connection_options.cpp | 4 +-
proton-c/bindings/cpp/src/container.cpp | 4 +-
proton-c/bindings/cpp/src/container_impl.hpp | 2 +-
proton-c/bindings/cpp/src/handler.cpp | 62 +++++++++++++
proton-c/bindings/cpp/src/link_options.cpp | 4 +-
proton-c/bindings/cpp/src/messaging_adapter.cpp | 2 +-
proton-c/bindings/cpp/src/messaging_adapter.hpp | 6 +-
proton-c/bindings/cpp/src/messaging_event.cpp | 2 +-
proton-c/bindings/cpp/src/messaging_handler.cpp | 62 -------------
tests/tools/apps/cpp/reactor_send.cpp | 6 +-
40 files changed, 231 insertions(+), 231 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp
index a98d43d..097a612 100644
--- a/examples/cpp/broker.cpp
+++ b/examples/cpp/broker.cpp
@@ -36,7 +36,7 @@ class broker {
public:
broker(const proton::url& url) : handler_(url, queues_) {}
- proton::messaging_handler& handler() { return handler_; }
+ proton::handler& handler() { return handler_; }
private:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/broker.hpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.hpp b/examples/cpp/broker.hpp
index c89eb5d..6b4096e 100644
--- a/examples/cpp/broker.hpp
+++ b/examples/cpp/broker.hpp
@@ -29,7 +29,7 @@
#include "proton/event.hpp"
#include "proton/message.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/sender.hpp"
#include "proton/url.hpp"
@@ -134,7 +134,7 @@ class queues {
/** Common handler logic for brokers. */
-class broker_handler : public proton::messaging_handler {
+class broker_handler : public proton::handler {
public:
broker_handler(queues& qs) : queues_(qs) {}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/client.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/client.cpp b/examples/cpp/client.cpp
index 704315b..60eb13b 100644
--- a/examples/cpp/client.cpp
+++ b/examples/cpp/client.cpp
@@ -22,13 +22,13 @@
#include "options.hpp"
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/connection.hpp"
#include <iostream>
#include <vector>
-class client : public proton::messaging_handler {
+class client : public proton::handler {
private:
proton::url url;
std::vector<std::string> requests;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/connection_options.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/connection_options.cpp b/examples/cpp/connection_options.cpp
index e40dac5..10bd320 100644
--- a/examples/cpp/connection_options.cpp
+++ b/examples/cpp/connection_options.cpp
@@ -20,7 +20,7 @@
*/
#include "proton/container.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/event.hpp"
#include "proton/url.hpp"
#include "proton/transport.hpp"
@@ -29,7 +29,7 @@
using proton::connection_options;
-class handler_2 : public proton::messaging_handler {
+class handler_2 : public proton::handler {
void on_connection_open(proton::event &e) {
std::cout << "connection events going to handler_2" << std::endl;
std::cout << "connection max_frame_size: " << e.connection().transport().max_frame_size() <<
@@ -38,7 +38,7 @@ class handler_2 : public proton::messaging_handler {
}
};
-class main_handler : public proton::messaging_handler {
+class main_handler : public proton::handler {
private:
proton::url url;
handler_2 conn_handler;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/direct_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_recv.cpp b/examples/cpp/direct_recv.cpp
index b027ef4..56fa1e2 100644
--- a/examples/cpp/direct_recv.cpp
+++ b/examples/cpp/direct_recv.cpp
@@ -24,7 +24,7 @@
#include "proton/container.hpp"
#include "proton/acceptor.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/link.hpp"
#include "proton/url.hpp"
#include "proton/value.hpp"
@@ -32,7 +32,7 @@
#include <iostream>
#include <map>
-class direct_recv : public proton::messaging_handler {
+class direct_recv : public proton::handler {
private:
proton::url url;
uint64_t expected;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/direct_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_send.cpp b/examples/cpp/direct_send.cpp
index def523f..35b41d5 100644
--- a/examples/cpp/direct_send.cpp
+++ b/examples/cpp/direct_send.cpp
@@ -25,13 +25,13 @@
#include "proton/connection.hpp"
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/value.hpp"
#include <iostream>
#include <map>
-class simple_send : public proton::messaging_handler {
+class simple_send : public proton::handler {
private:
proton::url url;
int sent;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/helloworld.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld.cpp b/examples/cpp/helloworld.cpp
index 15ffe54..b8f8b61 100644
--- a/examples/cpp/helloworld.cpp
+++ b/examples/cpp/helloworld.cpp
@@ -21,12 +21,12 @@
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/url.hpp"
#include <iostream>
-class hello_world : public proton::messaging_handler {
+class hello_world : public proton::handler {
private:
proton::url url;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/helloworld_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp
index 3b53e17..8b4af5b 100644
--- a/examples/cpp/helloworld_direct.cpp
+++ b/examples/cpp/helloworld_direct.cpp
@@ -22,11 +22,11 @@
#include "proton/acceptor.hpp"
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include <iostream>
-class hello_world_direct : public proton::messaging_handler {
+class hello_world_direct : public proton::handler {
private:
proton::url url;
proton::acceptor acceptor;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/queue_browser.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/queue_browser.cpp b/examples/cpp/queue_browser.cpp
index 56b8015..015e6ad 100644
--- a/examples/cpp/queue_browser.cpp
+++ b/examples/cpp/queue_browser.cpp
@@ -21,13 +21,13 @@
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/url.hpp"
#include "proton/link_options.hpp"
#include <iostream>
-class browser : public proton::messaging_handler {
+class browser : public proton::handler {
private:
proton::url url;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/recurring_timer.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/recurring_timer.cpp b/examples/cpp/recurring_timer.cpp
index 1987357..a4fb4bd 100644
--- a/examples/cpp/recurring_timer.cpp
+++ b/examples/cpp/recurring_timer.cpp
@@ -23,26 +23,26 @@
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/task.hpp"
#include <iostream>
#include <map>
-class ticker : public proton::messaging_handler {
+class ticker : public proton::handler {
void on_timer(proton::event &e) {
std::cout << "Tick..." << std::endl;
}
};
-class tocker : public proton::messaging_handler {
+class tocker : public proton::handler {
void on_timer(proton::event &e) {
std::cout << "Tock..." << std::endl;
}
};
-class recurring : public proton::messaging_handler {
+class recurring : public proton::handler {
private:
int remaining_msecs, tick_ms;
ticker tick_handler;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/selected_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/selected_recv.cpp b/examples/cpp/selected_recv.cpp
index 16bab7c..ad010c0 100644
--- a/examples/cpp/selected_recv.cpp
+++ b/examples/cpp/selected_recv.cpp
@@ -21,13 +21,13 @@
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/url.hpp"
#include "proton/link_options.hpp"
#include <iostream>
-class selected_recv : public proton::messaging_handler {
+class selected_recv : public proton::handler {
private:
proton::url url;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/server.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/server.cpp b/examples/cpp/server.cpp
index db186ba..7711f0e 100644
--- a/examples/cpp/server.cpp
+++ b/examples/cpp/server.cpp
@@ -24,7 +24,7 @@
#include "proton/connection.hpp"
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/url.hpp"
#include <iostream>
@@ -32,7 +32,7 @@
#include <string>
#include <cctype>
-class server : public proton::messaging_handler {
+class server : public proton::handler {
private:
typedef std::map<std::string, proton::sender> sender_map;
proton::url url;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/server_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/server_direct.cpp b/examples/cpp/server_direct.cpp
index c29757c..62384b4 100644
--- a/examples/cpp/server_direct.cpp
+++ b/examples/cpp/server_direct.cpp
@@ -24,7 +24,7 @@
#include "proton/acceptor.hpp"
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/url.hpp"
#include <iostream>
@@ -33,7 +33,7 @@
#include <sstream>
#include <cctype>
-class server : public proton::messaging_handler {
+class server : public proton::handler {
private:
typedef std::map<std::string, proton::sender> sender_map;
proton::url url;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/simple_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_recv.cpp b/examples/cpp/simple_recv.cpp
index a28b793..c3df477 100644
--- a/examples/cpp/simple_recv.cpp
+++ b/examples/cpp/simple_recv.cpp
@@ -23,7 +23,7 @@
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/link.hpp"
#include "proton/value.hpp"
#include "proton/message_id.hpp"
@@ -33,7 +33,7 @@
-class simple_recv : public proton::messaging_handler {
+class simple_recv : public proton::handler {
private:
proton::url url;
proton::receiver receiver;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/simple_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp
index 0f627ed..5a2d401 100644
--- a/examples/cpp/simple_send.cpp
+++ b/examples/cpp/simple_send.cpp
@@ -23,14 +23,14 @@
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/connection.hpp"
#include "proton/value.hpp"
#include <iostream>
#include <map>
-class simple_send : public proton::messaging_handler {
+class simple_send : public proton::handler {
private:
proton::url url;
proton::sender sender;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/ssl.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp
index fb775b2..2d68c37 100644
--- a/examples/cpp/ssl.cpp
+++ b/examples/cpp/ssl.cpp
@@ -22,7 +22,7 @@
#include "proton/acceptor.hpp"
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/connection_options.hpp"
#include "proton/transport.hpp"
#include "proton/ssl.hpp"
@@ -42,7 +42,7 @@ std::string cert_directory;
std::string find_CN(const std::string &);
-struct server_handler : public proton::messaging_handler {
+struct server_handler : public proton::handler {
proton::acceptor acceptor;
void on_connection_open(proton::event &e) {
@@ -57,7 +57,7 @@ struct server_handler : public proton::messaging_handler {
};
-class hello_world_direct : public proton::messaging_handler {
+class hello_world_direct : public proton::handler {
private:
proton::url url;
server_handler s_handler;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/examples/cpp/ssl_client_cert.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_client_cert.cpp b/examples/cpp/ssl_client_cert.cpp
index 10218ee..a12873c 100644
--- a/examples/cpp/ssl_client_cert.cpp
+++ b/examples/cpp/ssl_client_cert.cpp
@@ -22,7 +22,7 @@
#include "proton/acceptor.hpp"
#include "proton/container.hpp"
#include "proton/event.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/connection_options.hpp"
#include "proton/transport.hpp"
#include "proton/ssl.hpp"
@@ -44,7 +44,7 @@ std::string cert_directory;
std::string find_CN(const std::string &);
-struct server_handler : public proton::messaging_handler {
+struct server_handler : public proton::handler {
proton::acceptor inbound_listener;
void on_connection_open(proton::event &e) {
@@ -67,7 +67,7 @@ struct server_handler : public proton::messaging_handler {
};
-class hello_world_direct : public proton::messaging_handler {
+class hello_world_direct : public proton::handler {
private:
proton::url url;
server_handler s_handler;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 4c55af4..8ae1c94 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -53,7 +53,7 @@ set(qpid-proton-cpp-source
src/message.cpp
src/messaging_adapter.cpp
src/messaging_event.cpp
- src/messaging_handler.cpp
+ src/handler.cpp
src/object.cpp
src/proton_bits.cpp
src/proton_event.cpp
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/include/proton/connection_engine.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_engine.hpp b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
index 28ecce4..3a39be1 100644
--- a/proton-c/bindings/cpp/include/proton/connection_engine.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
@@ -28,7 +28,7 @@
namespace proton {
-class messaging_handler;
+class handler;
class connection;
/// Pointers to a byte range to use as a buffer.
@@ -84,7 +84,7 @@ class connection_engine {
/**
* Create an engine that will advertise id as the AMQP container-id for its connection.
*/
- PN_CPP_EXTERN connection_engine(messaging_handler&, const std::string& id=std::string());
+ PN_CPP_EXTERN connection_engine(handler&, const std::string& id=std::string());
PN_CPP_EXTERN ~connection_engine();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/include/proton/connection_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_options.hpp b/proton-c/bindings/cpp/include/proton/connection_options.hpp
index 633fd82..bebeef7 100644
--- a/proton-c/bindings/cpp/include/proton/connection_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_options.hpp
@@ -63,7 +63,7 @@ class connection_options {
// TODO: Document options
- PN_CPP_EXTERN connection_options& handler(class messaging_handler *);
+ PN_CPP_EXTERN connection_options& handler(class handler *);
PN_CPP_EXTERN connection_options& max_frame_size(uint32_t max);
PN_CPP_EXTERN connection_options& max_channels(uint16_t max);
PN_CPP_EXTERN connection_options& idle_timeout(uint32_t t);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp
index d4dac36..4251038 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -35,7 +35,7 @@ namespace proton {
class connection;
class acceptor;
-class messaging_handler;
+class handler;
class sender;
class receiver;
class link;
@@ -55,7 +55,7 @@ class container {
PN_CPP_EXTERN container(const std::string& id=std::string());
/// Container ID should be unique within your system. By default a random ID is generated.
- PN_CPP_EXTERN container(messaging_handler& mhandler, const std::string& id=std::string());
+ PN_CPP_EXTERN container(handler& mhandler, const std::string& id=std::string());
PN_CPP_EXTERN ~container();
@@ -87,7 +87,7 @@ class container {
PN_CPP_EXTERN class reactor reactor() const;
// Schedule a timer task event in delay milliseconds.
- PN_CPP_EXTERN task schedule(int delay, messaging_handler *h = 0);
+ PN_CPP_EXTERN task schedule(int delay, handler *h = 0);
/** Copy the connection options to a template which will be
applied to subsequent outgoing connections. These are applied first
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/include/proton/handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/handler.hpp b/proton-c/bindings/cpp/include/proton/handler.hpp
new file mode 100644
index 0000000..971ffab
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/handler.hpp
@@ -0,0 +1,98 @@
+#ifndef PROTON_CPP_MESSAGING_HANDLER_H
+#define PROTON_CPP_MESSAGING_HANDLER_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/event.h"
+#include "proton/pn_unique_ptr.hpp"
+
+#include <stdexcept>
+
+namespace proton {
+
+class event;
+class messaging_adapter;
+
+/** messaging_handler base class. Provides a simpler set of events than
+ * proton::proton_handler and automates some common tasks. Subclass and
+ * over-ride event handling member functions.
+ * @see proton::messaging_event for meaning of events.
+ */
+class handler
+{
+ public:
+ /** Create a messaging_handler
+ *@param prefetch set flow control to automatically pre-fetch this many messages
+ *@param auto_accept automatically accept received messages after on_message()
+ *@param auto_settle automatically settle on receipt of delivery for sent messages.
+ *@param peer_close_is_error treat orderly remote connection close as error.
+ */
+ PN_CPP_EXTERN handler(int prefetch=10, bool auto_accept=true, bool auto_settle=true,
+ bool peer_close_is_error=false);
+
+ PN_CPP_EXTERN virtual ~handler();
+
+ ///@name Over-ride these member functions to handle events
+ ///@{
+ PN_CPP_EXTERN virtual void on_start(event &e);
+ PN_CPP_EXTERN virtual void on_message(event &e);
+ PN_CPP_EXTERN virtual void on_sendable(event &e);
+ PN_CPP_EXTERN virtual void on_disconnect(event &e);
+
+ PN_CPP_EXTERN virtual void on_connection_open(event &e);
+ PN_CPP_EXTERN virtual void on_connection_close(event &e);
+ PN_CPP_EXTERN virtual void on_connection_error(event &e);
+
+ PN_CPP_EXTERN virtual void on_session_open(event &e);
+ PN_CPP_EXTERN virtual void on_session_close(event &e);
+ PN_CPP_EXTERN virtual void on_session_error(event &e);
+
+ PN_CPP_EXTERN virtual void on_link_open(event &e);
+ PN_CPP_EXTERN virtual void on_link_close(event &e);
+ PN_CPP_EXTERN virtual void on_link_error(event &e);
+
+ PN_CPP_EXTERN virtual void on_delivery_accept(event &e);
+ PN_CPP_EXTERN virtual void on_delivery_reject(event &e);
+ PN_CPP_EXTERN virtual void on_delivery_release(event &e);
+ PN_CPP_EXTERN virtual void on_delivery_settle(event &e);
+
+ PN_CPP_EXTERN virtual void on_transaction_declare(event &e);
+ PN_CPP_EXTERN virtual void on_transaction_commit(event &e);
+ PN_CPP_EXTERN virtual void on_transaction_abort(event &e);
+
+ PN_CPP_EXTERN virtual void on_timer(event &e);
+
+ PN_CPP_EXTERN virtual void on_unhandled(event &e);
+ PN_CPP_EXTERN virtual void on_unhandled_error(event &e);
+ ///@}
+
+ private:
+ pn_unique_ptr<messaging_adapter> messaging_adapter_;
+ friend class container;
+ friend class connection_engine;
+ friend class connection_options;
+ friend class link_options;
+};
+
+}
+
+#endif /*!PROTON_CPP_MESSAGING_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/include/proton/link_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/link_options.hpp b/proton-c/bindings/cpp/include/proton/link_options.hpp
index 02613c1..d7f3406 100644
--- a/proton-c/bindings/cpp/include/proton/link_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/link_options.hpp
@@ -88,7 +88,7 @@ class link_options {
PN_CPP_EXTERN void override(const link_options& other);
/** Set a handler for events scoped to the link. If NULL, link-scoped events on the link are discarded. */
- PN_CPP_EXTERN link_options& handler(class messaging_handler *);
+ PN_CPP_EXTERN link_options& handler(class handler *);
/** Receiver-only option to specify whether messages are browsed or
consumed. Setting browsing to true is Equivalent to setting
distribution_mode(COPY). Setting browsing to false is equivalent to
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
deleted file mode 100644
index 5a20b81..0000000
--- a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifndef PROTON_CPP_MESSAGING_HANDLER_H
-#define PROTON_CPP_MESSAGING_HANDLER_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/event.h"
-#include "proton/pn_unique_ptr.hpp"
-
-#include <stdexcept>
-
-namespace proton {
-
-class event;
-class messaging_adapter;
-
-/** messaging_handler base class. Provides a simpler set of events than
- * proton::proton_handler and automates some common tasks. Subclass and
- * over-ride event handling member functions.
- * @see proton::messaging_event for meaning of events.
- */
-class messaging_handler
-{
- public:
- /** Create a messaging_handler
- *@param prefetch set flow control to automatically pre-fetch this many messages
- *@param auto_accept automatically accept received messages after on_message()
- *@param auto_settle automatically settle on receipt of delivery for sent messages.
- *@param peer_close_is_error treat orderly remote connection close as error.
- */
- PN_CPP_EXTERN messaging_handler(int prefetch=10, bool auto_accept=true, bool auto_settle=true,
- bool peer_close_is_error=false);
-
- PN_CPP_EXTERN virtual ~messaging_handler();
-
- ///@name Over-ride these member functions to handle events
- ///@{
- PN_CPP_EXTERN virtual void on_start(event &e);
- PN_CPP_EXTERN virtual void on_message(event &e);
- PN_CPP_EXTERN virtual void on_sendable(event &e);
- PN_CPP_EXTERN virtual void on_disconnect(event &e);
-
- PN_CPP_EXTERN virtual void on_connection_open(event &e);
- PN_CPP_EXTERN virtual void on_connection_close(event &e);
- PN_CPP_EXTERN virtual void on_connection_error(event &e);
-
- PN_CPP_EXTERN virtual void on_session_open(event &e);
- PN_CPP_EXTERN virtual void on_session_close(event &e);
- PN_CPP_EXTERN virtual void on_session_error(event &e);
-
- PN_CPP_EXTERN virtual void on_link_open(event &e);
- PN_CPP_EXTERN virtual void on_link_close(event &e);
- PN_CPP_EXTERN virtual void on_link_error(event &e);
-
- PN_CPP_EXTERN virtual void on_delivery_accept(event &e);
- PN_CPP_EXTERN virtual void on_delivery_reject(event &e);
- PN_CPP_EXTERN virtual void on_delivery_release(event &e);
- PN_CPP_EXTERN virtual void on_delivery_settle(event &e);
-
- PN_CPP_EXTERN virtual void on_transaction_declare(event &e);
- PN_CPP_EXTERN virtual void on_transaction_commit(event &e);
- PN_CPP_EXTERN virtual void on_transaction_abort(event &e);
-
- PN_CPP_EXTERN virtual void on_timer(event &e);
-
- PN_CPP_EXTERN virtual void on_unhandled(event &e);
- PN_CPP_EXTERN virtual void on_unhandled_error(event &e);
- ///@}
-
- private:
- pn_unique_ptr<messaging_adapter> messaging_adapter_;
- friend class container;
- friend class connection_engine;
- friend class connection_options;
- friend class link_options;
-};
-
-}
-
-#endif /*!PROTON_CPP_MESSAGING_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/include/proton/request_response.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/request_response.hpp b/proton-c/bindings/cpp/include/proton/request_response.hpp
index 58b8156..23af836 100644
--- a/proton-c/bindings/cpp/include/proton/request_response.hpp
+++ b/proton-c/bindings/cpp/include/proton/request_response.hpp
@@ -24,7 +24,7 @@
#include "proton/blocking_receiver.hpp"
#include "proton/blocking_sender.hpp"
#include "proton/export.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/pn_unique_ptr.hpp"
#include <string>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection_impl.cpp b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
index db457b0..f05efb6 100644
--- a/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
+++ b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
@@ -19,7 +19,7 @@
*
*/
#include "proton/container.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/duration.hpp"
#include "proton/connection.h"
#include "proton/error.hpp"
@@ -50,7 +50,7 @@ blocking_connection_impl::blocking_connection_impl(const url& url, duration time
{
container_->reactor().start();
container_->reactor().timeout(timeout);
- messaging_handler* h = this; // Set this as handler.
+ handler* h = this; // Set this as handler.
connection_ = container_->connect(url, connection_options().handler(h));
wait(connection_opening(connection_));
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/blocking_connection_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection_impl.hpp b/proton-c/bindings/cpp/src/blocking_connection_impl.hpp
index cd93de8..0c7f02d 100644
--- a/proton-c/bindings/cpp/src/blocking_connection_impl.hpp
+++ b/proton-c/bindings/cpp/src/blocking_connection_impl.hpp
@@ -23,7 +23,7 @@
*/
#include "proton/export.hpp"
#include "proton/container.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/connection.hpp"
#include "proton/types.h"
#include <string>
@@ -35,7 +35,7 @@ namespace proton {
class handler;
class container;
-class blocking_connection_impl : public messaging_handler
+class blocking_connection_impl : public handler
{
public:
blocking_connection_impl(const url &url, duration d);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/blocking_fetcher.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_fetcher.cpp b/proton-c/bindings/cpp/src/blocking_fetcher.cpp
index 0d0b706..fb95aaf 100644
--- a/proton-c/bindings/cpp/src/blocking_fetcher.cpp
+++ b/proton-c/bindings/cpp/src/blocking_fetcher.cpp
@@ -26,7 +26,7 @@
namespace proton {
-blocking_fetcher::blocking_fetcher(int prefetch) : messaging_handler(prefetch, false /*auto_accept*/) {}
+blocking_fetcher::blocking_fetcher(int prefetch) : handler(prefetch, false /*auto_accept*/) {}
void blocking_fetcher::on_message(event &e) {
messages_.push_back(e.message());
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/blocking_fetcher.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_fetcher.hpp b/proton-c/bindings/cpp/src/blocking_fetcher.hpp
index 337df3e..b3e2169 100644
--- a/proton-c/bindings/cpp/src/blocking_fetcher.hpp
+++ b/proton-c/bindings/cpp/src/blocking_fetcher.hpp
@@ -22,14 +22,14 @@
*
*/
#include "proton/delivery.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/message.hpp"
#include <string>
#include <deque>
namespace proton {
-class blocking_fetcher : public messaging_handler {
+class blocking_fetcher : public handler {
public:
blocking_fetcher(int prefetch);
void on_message(event &e);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/connection_engine.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_engine.cpp b/proton-c/bindings/cpp/src/connection_engine.cpp
index 639bd3c..2c54725 100644
--- a/proton-c/bindings/cpp/src/connection_engine.cpp
+++ b/proton-c/bindings/cpp/src/connection_engine.cpp
@@ -19,7 +19,7 @@
#include "proton/connection_engine.hpp"
#include "proton/error.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "messaging_adapter.hpp"
#include "messaging_event.hpp"
@@ -58,7 +58,7 @@ struct connection_engine::impl {
pn_collector_t * collector;
};
-connection_engine::connection_engine(messaging_handler &h, const std::string& id_) :
+connection_engine::connection_engine(handler &h, const std::string& id_) :
impl_(new impl(*h.messaging_adapter_.get(), pn_transport())) {
if (!impl_->transport || !impl_->connection || !impl_->collector)
throw error("connection_engine setup failed");
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp
index 4e5fb44..013daaa 100644
--- a/proton-c/bindings/cpp/src/connection_options.cpp
+++ b/proton-c/bindings/cpp/src/connection_options.cpp
@@ -19,7 +19,7 @@
*
*/
#include "proton/connection_options.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/reconnect_timer.hpp"
#include "proton/transport.hpp"
#include "proton/ssl.hpp"
@@ -158,7 +158,7 @@ connection_options& connection_options::operator=(const connection_options& x) {
void connection_options::override(const connection_options& x) { impl_->override(*x.impl_); }
-connection_options& connection_options::handler(class messaging_handler *h) { impl_->handler = h->messaging_adapter_.get(); return *this; }
+connection_options& connection_options::handler(class handler *h) { impl_->handler = h->messaging_adapter_.get(); return *this; }
connection_options& connection_options::max_frame_size(uint32_t n) { impl_->max_frame_size = n; return *this; }
connection_options& connection_options::max_channels(uint16_t n) { impl_->max_frame_size = n; return *this; }
connection_options& connection_options::idle_timeout(uint32_t t) { impl_->idle_timeout = t; return *this; }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container.cpp b/proton-c/bindings/cpp/src/container.cpp
index 60bfcbd..fc34f39 100644
--- a/proton-c/bindings/cpp/src/container.cpp
+++ b/proton-c/bindings/cpp/src/container.cpp
@@ -47,7 +47,7 @@ container::container(const std::string& id) {
impl_.reset(new container_impl(*this, 0, id));
}
-container::container(messaging_handler &mhandler, const std::string& id) {
+container::container(handler &mhandler, const std::string& id) {
impl_.reset(new container_impl(*this, mhandler.messaging_adapter_.get(), id));
}
@@ -75,7 +75,7 @@ acceptor container::listen(const proton::url &url, const connection_options &opt
return impl_->listen(url, opts);
}
-task container::schedule(int delay, messaging_handler *h) { return impl_->schedule(delay, h ? h->messaging_adapter_.get() : 0); }
+task container::schedule(int delay, handler *h) { return impl_->schedule(delay, h ? h->messaging_adapter_.get() : 0); }
void container::client_connection_options(const connection_options &o) { impl_->client_connection_options(o); }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.hpp b/proton-c/bindings/cpp/src/container_impl.hpp
index 035fb18..d46250e 100644
--- a/proton-c/bindings/cpp/src/container_impl.hpp
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -22,7 +22,7 @@
*
*/
#include "proton/export.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/connection.hpp"
#include "proton/link.hpp"
#include "proton/duration.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/handler.cpp b/proton-c/bindings/cpp/src/handler.cpp
new file mode 100644
index 0000000..4597156
--- /dev/null
+++ b/proton-c/bindings/cpp/src/handler.cpp
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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/handler.hpp"
+
+#include "proton_event.hpp"
+#include "messaging_adapter.hpp"
+
+#include "proton/handlers.h"
+
+#include <algorithm>
+
+namespace proton {
+
+handler::handler(int prefetch0, bool auto_accept0, bool auto_settle0, bool peer_close_is_error0) :
+ messaging_adapter_(new messaging_adapter(*this, prefetch0, auto_accept0, auto_settle0, peer_close_is_error0))
+{}
+
+handler::~handler(){}
+
+void handler::on_delivery_accept(event &e) { on_unhandled(e); }
+void handler::on_connection_close(event &e) { on_unhandled(e); }
+void handler::on_connection_error(event &e) { on_unhandled(e); }
+void handler::on_connection_open(event &e) { on_unhandled(e); }
+void handler::on_disconnect(event &e) { on_unhandled(e); }
+void handler::on_link_close(event &e) { on_unhandled(e); }
+void handler::on_link_error(event &e) { on_unhandled(e); }
+void handler::on_link_open(event &e) { on_unhandled(e); }
+void handler::on_message(event &e) { on_unhandled(e); }
+void handler::on_delivery_reject(event &e) { on_unhandled(e); }
+void handler::on_delivery_release(event &e) { on_unhandled(e); }
+void handler::on_sendable(event &e) { on_unhandled(e); }
+void handler::on_session_close(event &e) { on_unhandled(e); }
+void handler::on_session_error(event &e) { on_unhandled(e); }
+void handler::on_session_open(event &e) { on_unhandled(e); }
+void handler::on_delivery_settle(event &e) { on_unhandled(e); }
+void handler::on_start(event &e) { on_unhandled(e); }
+void handler::on_timer(event &e) { on_unhandled(e); }
+void handler::on_transaction_abort(event &e) { on_unhandled(e); }
+void handler::on_transaction_commit(event &e) { on_unhandled(e); }
+void handler::on_transaction_declare(event &e) { on_unhandled(e); }
+
+void handler::on_unhandled(event &) {}
+void handler::on_unhandled_error(event &) {}
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/link_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/link_options.cpp b/proton-c/bindings/cpp/src/link_options.cpp
index 03c30ea..ef8de3f 100644
--- a/proton-c/bindings/cpp/src/link_options.cpp
+++ b/proton-c/bindings/cpp/src/link_options.cpp
@@ -20,7 +20,7 @@
*/
#include "proton/link.hpp"
#include "proton/link_options.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "msg.hpp"
#include "messaging_adapter.hpp"
@@ -159,7 +159,7 @@ link_options& link_options::operator=(const link_options& x) {
void link_options::override(const link_options& x) { impl_->override(*x.impl_); }
-link_options& link_options::handler(class messaging_handler *h) { impl_->handler = h->messaging_adapter_.get(); return *this; }
+link_options& link_options::handler(class handler *h) { impl_->handler = h->messaging_adapter_.get(); return *this; }
link_options& link_options::browsing(bool b) { distribution_mode(b ? terminus::COPY : terminus::MOVE); return *this; }
link_options& link_options::distribution_mode(terminus::distribution_mode_t m) { impl_->distribution_mode = m; return *this; }
link_options& link_options::durable_subscription(bool b) {impl_->durable_subscription = b; return *this; }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/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 e9ce0ea..cc6f097 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -68,7 +68,7 @@ void messaging_adapter::create_helpers() {
}
}
-messaging_adapter::messaging_adapter(messaging_handler &delegate,
+messaging_adapter::messaging_adapter(handler &delegate,
int prefetch, bool auto_accept, bool auto_settle, bool peer_close_iserror) :
delegate_(delegate),
prefetch_(prefetch),
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.hpp b/proton-c/bindings/cpp/src/messaging_adapter.hpp
index 866644d..32e0423 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.hpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.hpp
@@ -22,7 +22,7 @@
*
*/
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton_handler.hpp"
@@ -38,7 +38,7 @@ namespace proton {
class messaging_adapter : public proton_handler
{
public:
- PN_CPP_EXTERN messaging_adapter(messaging_handler &delegate,
+ PN_CPP_EXTERN messaging_adapter(handler &delegate,
int prefetch, bool auto_accept, bool auto_settle,
bool peer_close_is_error);
PN_CPP_EXTERN virtual ~messaging_adapter();
@@ -56,7 +56,7 @@ class messaging_adapter : public proton_handler
PN_CPP_EXTERN void on_timer_task(proton_event &e);
private:
- messaging_handler &delegate_; // The handler for generated messaging_event's
+ handler &delegate_; // The handler for generated messaging_event's
int prefetch_;
bool auto_accept_;
bool auto_settle_;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/proton-c/bindings/cpp/src/messaging_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp
index 0c6c51d..1434ac7 100644
--- a/proton-c/bindings/cpp/src/messaging_event.cpp
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -21,7 +21,7 @@
#include "messaging_event.hpp"
#include "proton/message.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/sender.hpp"
#include "proton/receiver.hpp"
#include "proton/error.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3faacc52/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
deleted file mode 100644
index 6071ea2..0000000
--- a/proton-c/bindings/cpp/src/messaging_handler.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *
- * 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/messaging_handler.hpp"
-
-#include "proton_event.hpp"
-#include "messaging_adapter.hpp"
-
-#include "proton/handlers.h"
-
-#include <algorithm>
-
-namespace proton {
-
-messaging_handler::messaging_handler(int prefetch0, bool auto_accept0, bool auto_settle0, bool peer_close_is_error0) :
- messaging_adapter_(new messaging_adapter(*this, prefetch0, auto_accept0, auto_settle0, peer_close_is_error0))
-{}
-
-messaging_handler::~messaging_handler(){}
-
-void messaging_handler::on_delivery_accept(event &e) { on_unhandled(e); }
-void messaging_handler::on_connection_close(event &e) { on_unhandled(e); }
-void messaging_handler::on_connection_error(event &e) { on_unhandled(e); }
-void messaging_handler::on_connection_open(event &e) { on_unhandled(e); }
-void messaging_handler::on_disconnect(event &e) { on_unhandled(e); }
-void messaging_handler::on_link_close(event &e) { on_unhandled(e); }
-void messaging_handler::on_link_error(event &e) { on_unhandled(e); }
-void messaging_handler::on_link_open(event &e) { on_unhandled(e); }
-void messaging_handler::on_message(event &e) { on_unhandled(e); }
-void messaging_handler::on_delivery_reject(event &e) { on_unhandled(e); }
-void messaging_handler::on_delivery_release(event &e) { on_unhandled(e); }
-void messaging_handler::on_sendable(event &e) { on_unhandled(e); }
-void messaging_handler::on_session_close(event &e) { on_unhandled(e); }
-void messaging_handler::on_session_error(event &e) { on_unhandled(e); }
-void messaging_handler::on_session_open(event &e) { on_unhandled(e); }
-void messaging_handler::on_delivery_settle(event &e) { on_unhandled(e); }
-void messaging_handler::on_start(event &e) { on_unhandled(e); }
-void messaging_handler::on_timer(event &e) { on_unhandled(e); }
-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/3faacc52/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 29c78a0..aa69658 100644
--- a/tests/tools/apps/cpp/reactor_send.cpp
+++ b/tests/tools/apps/cpp/reactor_send.cpp
@@ -22,7 +22,7 @@
#include "options.hpp"
#include "proton/container.hpp"
-#include "proton/messaging_handler.hpp"
+#include "proton/handler.hpp"
#include "proton/connection.hpp"
#include "proton/decoder.hpp"
#include "proton/event.hpp"
@@ -37,7 +37,7 @@
-class reactor_send : public proton::messaging_handler {
+class reactor_send : public proton::handler {
private:
proton::url url_;
proton::message message_;
@@ -54,7 +54,7 @@ class reactor_send : public proton::messaging_handler {
public:
reactor_send(const std::string &url, int c, int size, bool replying)
- : messaging_handler(1024), // prefetch=1024
+ : handler(1024), // prefetch=1024
url_(url), sent_(0), confirmed_(0), total_(c),
received_(0), received_bytes_(0), replying_(replying) {
if (replying_)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[4/5] qpid-proton git commit: NO-JIRA: removed unnecessary
declarations
Posted by as...@apache.org.
NO-JIRA: removed unnecessary declarations
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f6aca307
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f6aca307
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f6aca307
Branch: refs/heads/master
Commit: f6aca307033e97c72cc395f8140ee124ab96a294
Parents: 3faacc5
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Jan 19 15:58:21 2016 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Jan 20 00:55:55 2016 -0500
----------------------------------------------------------------------
proton-c/bindings/cpp/include/proton/endpoint.hpp | 1 -
proton-c/bindings/cpp/include/proton/session.hpp | 1 -
proton-c/bindings/cpp/src/connector.hpp | 3 ---
3 files changed, 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f6aca307/proton-c/bindings/cpp/include/proton/endpoint.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/endpoint.hpp b/proton-c/bindings/cpp/include/proton/endpoint.hpp
index 9e6fa8d..529a60b 100644
--- a/proton-c/bindings/cpp/include/proton/endpoint.hpp
+++ b/proton-c/bindings/cpp/include/proton/endpoint.hpp
@@ -28,7 +28,6 @@ namespace proton {
class handler;
class connection;
-class transport;
class session;
class link;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f6aca307/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 0f7c946..5b5c67a 100644
--- a/proton-c/bindings/cpp/include/proton/session.hpp
+++ b/proton-c/bindings/cpp/include/proton/session.hpp
@@ -36,7 +36,6 @@ namespace proton {
class container;
class handler;
-class transport;
/** A session is a collection of links */
class session : public object<pn_session_t>, public endpoint
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f6aca307/proton-c/bindings/cpp/src/connector.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connector.hpp b/proton-c/bindings/cpp/src/connector.hpp
index 65a1db4..0f98235 100644
--- a/proton-c/bindings/cpp/src/connector.hpp
+++ b/proton-c/bindings/cpp/src/connector.hpp
@@ -35,9 +35,6 @@
namespace proton {
-class event;
-class connection;
-class transport;
class reconnect_timer;
class connector : public proton_handler
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[5/5] qpid-proton git commit: Merge branch 'event_tidying' This
closes #63
Posted by as...@apache.org.
Merge branch 'event_tidying'
This closes #63
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3a034abb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3a034abb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3a034abb
Branch: refs/heads/master
Commit: 3a034abbdcc167e7744f5fd45696a76657ff75dc
Parents: 701e8d0 f6aca30
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed Jan 20 09:53:22 2016 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Jan 20 09:53:22 2016 -0500
----------------------------------------------------------------------
examples/cpp/broker.cpp | 2 +-
examples/cpp/broker.hpp | 7 +-
examples/cpp/client.cpp | 5 +-
examples/cpp/connection_options.cpp | 7 +-
examples/cpp/direct_recv.cpp | 5 +-
examples/cpp/direct_send.cpp | 5 +-
examples/cpp/helloworld.cpp | 5 +-
examples/cpp/helloworld_direct.cpp | 5 +-
examples/cpp/queue_browser.cpp | 5 +-
examples/cpp/recurring_timer.cpp | 9 +-
examples/cpp/selected_recv.cpp | 5 +-
examples/cpp/server.cpp | 6 +-
examples/cpp/server_direct.cpp | 5 +-
examples/cpp/simple_recv.cpp | 5 +-
examples/cpp/simple_send.cpp | 5 +-
examples/cpp/ssl.cpp | 7 +-
examples/cpp/ssl_client_cert.cpp | 7 +-
proton-c/bindings/cpp/CMakeLists.txt | 3 +-
.../cpp/include/proton/connection_options.hpp | 4 +-
.../bindings/cpp/include/proton/container.hpp | 5 +-
.../bindings/cpp/include/proton/endpoint.hpp | 1 -
proton-c/bindings/cpp/include/proton/event.hpp | 3 -
.../bindings/cpp/include/proton/handler.hpp | 93 ++--
proton-c/bindings/cpp/include/proton/link.hpp | 2 +-
.../cpp/include/proton/link_options.hpp | 4 +-
.../cpp/include/proton/messaging_adapter.hpp | 70 ---
.../cpp/include/proton/messaging_handler.hpp | 107 ----
.../cpp/include/proton/proton_handler.hpp | 86 ----
.../cpp/include/proton/request_response.hpp | 2 +-
.../bindings/cpp/include/proton/session.hpp | 1 -
.../cpp/src/blocking_connection_impl.cpp | 4 +-
.../cpp/src/blocking_connection_impl.hpp | 4 +-
proton-c/bindings/cpp/src/blocking_fetcher.cpp | 2 +-
proton-c/bindings/cpp/src/blocking_fetcher.hpp | 5 +-
proton-c/bindings/cpp/src/connection.cpp | 1 -
proton-c/bindings/cpp/src/connection_engine.cpp | 17 +-
.../bindings/cpp/src/connection_options.cpp | 9 +-
proton-c/bindings/cpp/src/connector.cpp | 18 +-
proton-c/bindings/cpp/src/connector.hpp | 20 +-
proton-c/bindings/cpp/src/container.cpp | 12 +-
proton-c/bindings/cpp/src/container_impl.cpp | 45 +-
proton-c/bindings/cpp/src/container_impl.hpp | 17 +-
proton-c/bindings/cpp/src/contexts.cpp | 4 +-
proton-c/bindings/cpp/src/contexts.hpp | 8 +-
proton-c/bindings/cpp/src/event.cpp | 1 -
proton-c/bindings/cpp/src/handler.cpp | 43 +-
proton-c/bindings/cpp/src/link.cpp | 2 +-
proton-c/bindings/cpp/src/link_options.cpp | 11 +-
proton-c/bindings/cpp/src/messaging_adapter.cpp | 377 +++++++--------
proton-c/bindings/cpp/src/messaging_adapter.hpp | 70 +++
proton-c/bindings/cpp/src/messaging_event.cpp | 94 +---
proton-c/bindings/cpp/src/messaging_event.hpp | 18 +-
proton-c/bindings/cpp/src/messaging_handler.cpp | 106 ----
proton-c/bindings/cpp/src/proton_event.cpp | 170 +++----
proton-c/bindings/cpp/src/proton_event.hpp | 484 +++++++++----------
proton-c/bindings/cpp/src/proton_handler.cpp | 92 ++--
proton-c/bindings/cpp/src/proton_handler.hpp | 104 ++++
tests/tools/apps/cpp/reactor_send.cpp | 7 +-
58 files changed, 986 insertions(+), 1235 deletions(-)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/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
Posted by as...@apache.org.
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 proton_handler
- API User has no access to lower level proton_handler
x Order of handler processing is subtly different now
-- flow controller gets called after user's event handler not before
- No inheritance relationship between proton_event and messaging_event/event
- Removed the old handler completely
- Removed a load of dynamic_casts that are now unnecessary
- A bunch of header include tidies up.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d5c68c48
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d5c68c48
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d5c68c48
Branch: refs/heads/master
Commit: d5c68c48eb6be1c8afd96e5443341c5887ce964a
Parents: babdc00
Author: Andrew Stitcher <as...@apache.org>
Authored: Mon Jan 18 18:42:58 2016 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Jan 20 00:51:32 2016 -0500
----------------------------------------------------------------------
examples/cpp/broker.hpp | 3 +
examples/cpp/client.cpp | 1 +
examples/cpp/connection_options.cpp | 1 +
examples/cpp/direct_recv.cpp | 1 +
examples/cpp/direct_send.cpp | 1 +
examples/cpp/helloworld.cpp | 1 +
examples/cpp/helloworld_direct.cpp | 1 +
examples/cpp/queue_browser.cpp | 1 +
examples/cpp/recurring_timer.cpp | 1 +
examples/cpp/selected_recv.cpp | 1 +
examples/cpp/server.cpp | 2 +
examples/cpp/server_direct.cpp | 1 +
examples/cpp/simple_recv.cpp | 1 +
examples/cpp/simple_send.cpp | 1 +
examples/cpp/ssl.cpp | 1 +
examples/cpp/ssl_client_cert.cpp | 1 +
proton-c/bindings/cpp/CMakeLists.txt | 1 -
.../cpp/include/proton/connection_engine.hpp | 4 +-
.../cpp/include/proton/connection_options.hpp | 6 +-
.../bindings/cpp/include/proton/container.hpp | 3 +-
proton-c/bindings/cpp/include/proton/event.hpp | 3 -
.../bindings/cpp/include/proton/handler.hpp | 69 ---
proton-c/bindings/cpp/include/proton/link.hpp | 2 +-
.../cpp/include/proton/link_options.hpp | 6 +-
.../cpp/include/proton/messaging_adapter.hpp | 70 ---
.../cpp/include/proton/messaging_handler.hpp | 29 +-
.../cpp/include/proton/proton_handler.hpp | 86 ----
.../cpp/src/blocking_connection_impl.cpp | 2 +-
proton-c/bindings/cpp/src/blocking_fetcher.hpp | 1 +
proton-c/bindings/cpp/src/connection.cpp | 1 -
proton-c/bindings/cpp/src/connection_engine.cpp | 17 +-
.../bindings/cpp/src/connection_options.cpp | 9 +-
proton-c/bindings/cpp/src/connector.cpp | 18 +-
proton-c/bindings/cpp/src/connector.hpp | 17 +-
proton-c/bindings/cpp/src/container.cpp | 10 +-
proton-c/bindings/cpp/src/container_impl.cpp | 45 +-
proton-c/bindings/cpp/src/container_impl.hpp | 15 +-
proton-c/bindings/cpp/src/contexts.cpp | 4 +-
proton-c/bindings/cpp/src/contexts.hpp | 8 +-
proton-c/bindings/cpp/src/event.cpp | 1 -
proton-c/bindings/cpp/src/handler.cpp | 37 --
proton-c/bindings/cpp/src/link.cpp | 2 +-
proton-c/bindings/cpp/src/link_options.cpp | 11 +-
proton-c/bindings/cpp/src/messaging_adapter.cpp | 377 +++++++--------
proton-c/bindings/cpp/src/messaging_adapter.hpp | 70 +++
proton-c/bindings/cpp/src/messaging_event.cpp | 92 +---
proton-c/bindings/cpp/src/messaging_event.hpp | 18 +-
proton-c/bindings/cpp/src/messaging_handler.cpp | 60 +--
proton-c/bindings/cpp/src/proton_event.cpp | 170 +++----
proton-c/bindings/cpp/src/proton_event.hpp | 484 +++++++++----------
proton-c/bindings/cpp/src/proton_handler.cpp | 92 ++--
proton-c/bindings/cpp/src/proton_handler.hpp | 104 ++++
tests/tools/apps/cpp/reactor_send.cpp | 1 +
53 files changed, 860 insertions(+), 1104 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/broker.hpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.hpp b/examples/cpp/broker.hpp
index 4cd4f4b..c89eb5d 100644
--- a/examples/cpp/broker.hpp
+++ b/examples/cpp/broker.hpp
@@ -27,7 +27,10 @@
* the important differences between the examples.
*/
+#include "proton/event.hpp"
+#include "proton/message.hpp"
#include "proton/messaging_handler.hpp"
+#include "proton/sender.hpp"
#include "proton/url.hpp"
#include <iostream>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/client.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/client.cpp b/examples/cpp/client.cpp
index f8186e0..704315b 100644
--- a/examples/cpp/client.cpp
+++ b/examples/cpp/client.cpp
@@ -21,6 +21,7 @@
#include "options.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/connection.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/connection_options.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/connection_options.cpp b/examples/cpp/connection_options.cpp
index 6a79224..e40dac5 100644
--- a/examples/cpp/connection_options.cpp
+++ b/examples/cpp/connection_options.cpp
@@ -21,6 +21,7 @@
#include "proton/container.hpp"
#include "proton/messaging_handler.hpp"
+#include "proton/event.hpp"
#include "proton/url.hpp"
#include "proton/transport.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/direct_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_recv.cpp b/examples/cpp/direct_recv.cpp
index ad16d26..b027ef4 100644
--- a/examples/cpp/direct_recv.cpp
+++ b/examples/cpp/direct_recv.cpp
@@ -23,6 +23,7 @@
#include "proton/container.hpp"
#include "proton/acceptor.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/link.hpp"
#include "proton/url.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/direct_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_send.cpp b/examples/cpp/direct_send.cpp
index 0b7095e..def523f 100644
--- a/examples/cpp/direct_send.cpp
+++ b/examples/cpp/direct_send.cpp
@@ -24,6 +24,7 @@
#include "proton/acceptor.hpp"
#include "proton/connection.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/value.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/helloworld.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld.cpp b/examples/cpp/helloworld.cpp
index b18c151..15ffe54 100644
--- a/examples/cpp/helloworld.cpp
+++ b/examples/cpp/helloworld.cpp
@@ -20,6 +20,7 @@
*/
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/url.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/helloworld_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp
index 5e4c316..3b53e17 100644
--- a/examples/cpp/helloworld_direct.cpp
+++ b/examples/cpp/helloworld_direct.cpp
@@ -21,6 +21,7 @@
#include "proton/acceptor.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include <iostream>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/queue_browser.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/queue_browser.cpp b/examples/cpp/queue_browser.cpp
index 1206c71..56b8015 100644
--- a/examples/cpp/queue_browser.cpp
+++ b/examples/cpp/queue_browser.cpp
@@ -20,6 +20,7 @@
*/
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/url.hpp"
#include "proton/link_options.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/recurring_timer.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/recurring_timer.cpp b/examples/cpp/recurring_timer.cpp
index d234b4c..1987357 100644
--- a/examples/cpp/recurring_timer.cpp
+++ b/examples/cpp/recurring_timer.cpp
@@ -22,6 +22,7 @@
#include "options.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/task.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/selected_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/selected_recv.cpp b/examples/cpp/selected_recv.cpp
index d591fd6..16bab7c 100644
--- a/examples/cpp/selected_recv.cpp
+++ b/examples/cpp/selected_recv.cpp
@@ -20,6 +20,7 @@
*/
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/url.hpp"
#include "proton/link_options.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/server.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/server.cpp b/examples/cpp/server.cpp
index fc2b462..db186ba 100644
--- a/examples/cpp/server.cpp
+++ b/examples/cpp/server.cpp
@@ -21,7 +21,9 @@
#include "options.hpp"
+#include "proton/connection.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/url.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/server_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/server_direct.cpp b/examples/cpp/server_direct.cpp
index 7ad5889..c29757c 100644
--- a/examples/cpp/server_direct.cpp
+++ b/examples/cpp/server_direct.cpp
@@ -23,6 +23,7 @@
#include "proton/acceptor.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/url.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/simple_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_recv.cpp b/examples/cpp/simple_recv.cpp
index 1e0d071..a28b793 100644
--- a/examples/cpp/simple_recv.cpp
+++ b/examples/cpp/simple_recv.cpp
@@ -22,6 +22,7 @@
#include "options.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/link.hpp"
#include "proton/value.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/simple_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp
index 64c34bf..0f627ed 100644
--- a/examples/cpp/simple_send.cpp
+++ b/examples/cpp/simple_send.cpp
@@ -22,6 +22,7 @@
#include "options.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/connection.hpp"
#include "proton/value.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/ssl.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp
index 568e223..fb775b2 100644
--- a/examples/cpp/ssl.cpp
+++ b/examples/cpp/ssl.cpp
@@ -21,6 +21,7 @@
#include "proton/acceptor.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/connection_options.hpp"
#include "proton/transport.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/examples/cpp/ssl_client_cert.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_client_cert.cpp b/examples/cpp/ssl_client_cert.cpp
index 7a9f411..10218ee 100644
--- a/examples/cpp/ssl_client_cert.cpp
+++ b/examples/cpp/ssl_client_cert.cpp
@@ -21,6 +21,7 @@
#include "proton/acceptor.hpp"
#include "proton/container.hpp"
+#include "proton/event.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/connection_options.hpp"
#include "proton/transport.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index be8cc1c..4c55af4 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -48,7 +48,6 @@ set(qpid-proton-cpp-source
src/connection_engine.cpp
src/error.cpp
src/event.cpp
- src/handler.cpp
src/link.cpp
src/link_options.cpp
src/message.cpp
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/include/proton/connection_engine.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_engine.hpp b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
index 3a39be1..28ecce4 100644
--- a/proton-c/bindings/cpp/include/proton/connection_engine.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
@@ -28,7 +28,7 @@
namespace proton {
-class handler;
+class messaging_handler;
class connection;
/// Pointers to a byte range to use as a buffer.
@@ -84,7 +84,7 @@ class connection_engine {
/**
* Create an engine that will advertise id as the AMQP container-id for its connection.
*/
- PN_CPP_EXTERN connection_engine(handler&, const std::string& id=std::string());
+ PN_CPP_EXTERN connection_engine(messaging_handler&, const std::string& id=std::string());
PN_CPP_EXTERN ~connection_engine();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/include/proton/connection_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_options.hpp b/proton-c/bindings/cpp/include/proton/connection_options.hpp
index e221e5b..633fd82 100644
--- a/proton-c/bindings/cpp/include/proton/connection_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_options.hpp
@@ -32,7 +32,7 @@
namespace proton {
-class handler;
+class proton_handler;
class connection;
/** Options for creating a connection.
@@ -63,7 +63,7 @@ class connection_options {
// TODO: Document options
- PN_CPP_EXTERN connection_options& handler(class handler *);
+ PN_CPP_EXTERN connection_options& handler(class messaging_handler *);
PN_CPP_EXTERN connection_options& max_frame_size(uint32_t max);
PN_CPP_EXTERN connection_options& max_channels(uint16_t max);
PN_CPP_EXTERN connection_options& idle_timeout(uint32_t t);
@@ -82,7 +82,7 @@ class connection_options {
private:
void apply(connection&) const;
- class handler* handler() const;
+ proton_handler* handler() const;
static pn_connection_t *pn_connection(connection &);
class client_domain &client_domain();
class server_domain &server_domain();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp
index 7c417de..d4dac36 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -87,7 +87,7 @@ class container {
PN_CPP_EXTERN class reactor reactor() const;
// Schedule a timer task event in delay milliseconds.
- PN_CPP_EXTERN task schedule(int delay, handler *h = 0);
+ PN_CPP_EXTERN task schedule(int delay, messaging_handler *h = 0);
/** Copy the connection options to a template which will be
applied to subsequent outgoing connections. These are applied first
@@ -108,6 +108,7 @@ class container {
private:
pn_unique_ptr<container_impl> impl_;
+ friend class connector;
};
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/include/proton/event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/event.hpp b/proton-c/bindings/cpp/include/proton/event.hpp
index ea8ded2..62dd9b0 100644
--- a/proton-c/bindings/cpp/include/proton/event.hpp
+++ b/proton-c/bindings/cpp/include/proton/event.hpp
@@ -39,9 +39,6 @@ class event {
public:
virtual PN_CPP_EXTERN ~event();
- /// Dispatch this event to a handler.
- virtual PN_CPP_EXTERN void dispatch(handler &h) = 0;
-
/// Return the name of the event type
virtual PN_CPP_EXTERN std::string name() const = 0;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/include/proton/handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/handler.hpp b/proton-c/bindings/cpp/include/proton/handler.hpp
deleted file mode 100644
index 9b8f5e9..0000000
--- a/proton-c/bindings/cpp/include/proton/handler.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef PROTON_CPP_HANDLER_H
-#define PROTON_CPP_HANDLER_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/event.hpp"
-#include "proton/event.h"
-#include "proton/reactor.h"
-#include <vector>
-
-namespace proton {
-
-/** Base class for event handlers.
- *
- * A handler can have child handlers which are called in order, after the parent handler.
- *
- * Note: handlers are not deleted automatically. They must not be deleted while
- * they are still in use.
- *
- * There are two simple strategies you can use:
- *
- * 1. Destroy handlers only after the container that uses them is closed.
- *
- * 2. Allocate handlers with `new` and call `delete this` in the appropriate
- * `on_*_closed` or `on_*_final` event that indicates the handler is no longer needed.
- *
- */
-class handler {
- public:
- PN_CPP_EXTERN handler();
- PN_CPP_EXTERN virtual ~handler();
-
- /// Called if a handler function is not over-ridden to handle an event.
- PN_CPP_EXTERN virtual void on_unhandled(event &e);
-
- /// Add a child handler, equivalent to this->push_back(&h)
- /// h must not be deleted before this handler.
- PN_CPP_EXTERN virtual void add_child_handler(handler &h);
-
- public:
- std::vector<handler*> children_;
- typedef std::vector<handler*>::iterator iterator;
- private:
- pn_ptr<pn_handler_t> pn_handler_;
- friend class container_impl;
-};
-
-}
-
-#endif /*!PROTON_CPP_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/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 aafaf77..c876fa0 100644
--- a/proton-c/bindings/cpp/include/proton/link.hpp
+++ b/proton-c/bindings/cpp/include/proton/link.hpp
@@ -104,7 +104,7 @@ class link : public object<pn_link_t> , public endpoint
PN_CPP_EXTERN class session session() const;
/** Set a custom handler for this link. */
- PN_CPP_EXTERN void handler(class handler &);
+ PN_CPP_EXTERN void handler(proton_handler &);
/** Unset any custom handler */
PN_CPP_EXTERN void detach_handler();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/include/proton/link_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/link_options.hpp b/proton-c/bindings/cpp/include/proton/link_options.hpp
index f3c5da6..02613c1 100644
--- a/proton-c/bindings/cpp/include/proton/link_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/link_options.hpp
@@ -58,7 +58,7 @@ enum lifetime_policy_t {
DELETE_ON_NO_LINKS_OR_MESSAGES = 0x2E
};
-class handler;
+class proton_handler;
class link;
/** Options for creating a link.
@@ -88,7 +88,7 @@ class link_options {
PN_CPP_EXTERN void override(const link_options& other);
/** Set a handler for events scoped to the link. If NULL, link-scoped events on the link are discarded. */
- PN_CPP_EXTERN link_options& handler(class handler *);
+ PN_CPP_EXTERN link_options& handler(class messaging_handler *);
/** Receiver-only option to specify whether messages are browsed or
consumed. Setting browsing to true is Equivalent to setting
distribution_mode(COPY). Setting browsing to false is equivalent to
@@ -115,7 +115,7 @@ class link_options {
private:
friend class link;
void apply(link&) const;
- class handler* handler() const;
+ proton_handler* handler() const;
class impl;
pn_unique_ptr<impl> impl_;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp b/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
deleted file mode 100644
index 5a52658..0000000
--- a/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#ifndef PROTON_CPP_MESSAGING_ADAPTER_H
-#define PROTON_CPP_MESSAGING_ADAPTER_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/messaging_handler.hpp"
-
-#include "proton/event.h"
-#include "proton/reactor.h"
-
-///@cond INTERNAL
-
-namespace proton {
-
-// Combine's Python's: endpoint_state_handler, incoming_message_handler, outgoing_message_handler
-
-class messaging_adapter : public proton_handler, public messaging_handler
-{
- public:
- PN_CPP_EXTERN messaging_adapter(messaging_handler &delegate);
- PN_CPP_EXTERN virtual ~messaging_adapter();
- PN_CPP_EXTERN virtual void on_reactor_init(event &e);
- PN_CPP_EXTERN virtual void on_link_flow(event &e);
- PN_CPP_EXTERN virtual void on_delivery(event &e);
- PN_CPP_EXTERN virtual void on_unhandled(event &e);
- PN_CPP_EXTERN virtual void on_connection_remote_open(event &e);
- PN_CPP_EXTERN virtual void on_connection_remote_close(event &e);
- PN_CPP_EXTERN virtual void on_session_remote_open(event &e);
- PN_CPP_EXTERN virtual void on_session_remote_close(event &e);
- PN_CPP_EXTERN virtual void on_link_remote_open(event &e);
- PN_CPP_EXTERN virtual void on_link_remote_close(event &e);
- PN_CPP_EXTERN virtual void on_transport_tail_closed(event &e);
-
- PN_CPP_EXTERN virtual void on_connection_close(event &e);
- PN_CPP_EXTERN virtual void on_connection_error(event &e);
- PN_CPP_EXTERN virtual void on_connection_open(event &e);
- PN_CPP_EXTERN virtual void on_session_close(event &e);
- PN_CPP_EXTERN virtual void on_session_error(event &e);
- PN_CPP_EXTERN virtual void on_session_open(event &e);
- PN_CPP_EXTERN virtual void on_link_close(event &e);
- PN_CPP_EXTERN virtual void on_link_error(event &e);
- PN_CPP_EXTERN virtual void on_link_open(event &e);
-
- PN_CPP_EXTERN virtual void on_timer_task(event &e);
- private:
- messaging_handler &delegate_; // The handler for generated messaging_event's
-};
-
-}
-///@endcond INTERNAL
-#endif /*!PROTON_CPP_MESSAGING_ADAPTER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
index 39dc3e0..5a20b81 100644
--- a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp
@@ -21,9 +21,9 @@
* under the License.
*
*/
-
-#include "proton/proton_handler.hpp"
+#include "proton/export.hpp"
#include "proton/event.h"
+#include "proton/pn_unique_ptr.hpp"
#include <stdexcept>
@@ -32,17 +32,12 @@ namespace proton {
class event;
class messaging_adapter;
-class messaging_exception : public std::runtime_error {
- public:
- messaging_exception(event& e);
-};
-
/** messaging_handler base class. Provides a simpler set of events than
* proton::proton_handler and automates some common tasks. Subclass and
* over-ride event handling member functions.
* @see proton::messaging_event for meaning of events.
*/
-class messaging_handler : virtual public handler
+class messaging_handler
{
public:
/** Create a messaging_handler
@@ -85,21 +80,17 @@ class messaging_handler : virtual public handler
PN_CPP_EXTERN virtual void on_transaction_abort(event &e);
PN_CPP_EXTERN virtual void on_timer(event &e);
+
+ PN_CPP_EXTERN virtual void on_unhandled(event &e);
+ PN_CPP_EXTERN virtual void on_unhandled_error(event &e);
///@}
private:
- int prefetch_;
- bool auto_accept_;
- bool auto_settle_;
- bool peer_close_iserror_;
pn_unique_ptr<messaging_adapter> messaging_adapter_;
- pn_unique_ptr<handler> flow_controller_;
- PN_CPP_EXTERN messaging_handler(
- bool raw_handler, int prefetch=10, bool auto_accept=true,
- bool auto_settle=true, bool peer_close_is_error=false);
- friend class container_impl;
- friend class messaging_adapter;
- PN_CPP_EXTERN void create_helpers();
+ friend class container;
+ friend class connection_engine;
+ friend class connection_options;
+ friend class link_options;
};
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/include/proton/proton_handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/proton_handler.hpp b/proton-c/bindings/cpp/include/proton/proton_handler.hpp
deleted file mode 100644
index 4d22770..0000000
--- a/proton-c/bindings/cpp/include/proton/proton_handler.hpp
+++ /dev/null
@@ -1,86 +0,0 @@
-#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/handler.hpp"
-
-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 : virtual public handler
-{
- public:
- PN_CPP_EXTERN proton_handler();
-
- ///@name Over-ride these member functions to handle events
- ///@{
- PN_CPP_EXTERN virtual void on_reactor_init(event &e);
- PN_CPP_EXTERN virtual void on_reactor_quiesced(event &e);
- PN_CPP_EXTERN virtual void on_reactor_final(event &e);
- PN_CPP_EXTERN virtual void on_timer_task(event &e);
- PN_CPP_EXTERN virtual void on_connection_init(event &e);
- PN_CPP_EXTERN virtual void on_connection_bound(event &e);
- PN_CPP_EXTERN virtual void on_connection_unbound(event &e);
- PN_CPP_EXTERN virtual void on_connection_local_open(event &e);
- PN_CPP_EXTERN virtual void on_connection_local_close(event &e);
- PN_CPP_EXTERN virtual void on_connection_remote_open(event &e);
- PN_CPP_EXTERN virtual void on_connection_remote_close(event &e);
- PN_CPP_EXTERN virtual void on_connection_final(event &e);
- PN_CPP_EXTERN virtual void on_session_init(event &e);
- PN_CPP_EXTERN virtual void on_session_local_open(event &e);
- PN_CPP_EXTERN virtual void on_session_local_close(event &e);
- PN_CPP_EXTERN virtual void on_session_remote_open(event &e);
- PN_CPP_EXTERN virtual void on_session_remote_close(event &e);
- PN_CPP_EXTERN virtual void on_session_final(event &e);
- PN_CPP_EXTERN virtual void on_link_init(event &e);
- PN_CPP_EXTERN virtual void on_link_local_open(event &e);
- PN_CPP_EXTERN virtual void on_link_local_close(event &e);
- PN_CPP_EXTERN virtual void on_link_local_detach(event &e);
- PN_CPP_EXTERN virtual void on_link_remote_open(event &e);
- PN_CPP_EXTERN virtual void on_link_remote_close(event &e);
- PN_CPP_EXTERN virtual void on_link_remote_detach(event &e);
- PN_CPP_EXTERN virtual void on_link_flow(event &e);
- PN_CPP_EXTERN virtual void on_link_final(event &e);
- PN_CPP_EXTERN virtual void on_delivery(event &e);
- PN_CPP_EXTERN virtual void on_transport(event &e);
- PN_CPP_EXTERN virtual void on_transport_error(event &e);
- PN_CPP_EXTERN virtual void on_transport_head_closed(event &e);
- PN_CPP_EXTERN virtual void on_transport_tail_closed(event &e);
- PN_CPP_EXTERN virtual void on_transport_closed(event &e);
- PN_CPP_EXTERN virtual void on_selectable_init(event &e);
- PN_CPP_EXTERN virtual void on_selectable_updated(event &e);
- PN_CPP_EXTERN virtual void on_selectable_readable(event &e);
- PN_CPP_EXTERN virtual void on_selectable_writable(event &e);
- PN_CPP_EXTERN virtual void on_selectable_expired(event &e);
- PN_CPP_EXTERN virtual void on_selectable_error(event &e);
- PN_CPP_EXTERN virtual void on_selectable_final(event &e);
- PN_CPP_EXTERN virtual void on_unhandled(event &e);
- ///@}
-};
-
-}
-
-#endif /*!PROTON_CPP_PROTONHANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_connection_impl.cpp b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
index e0b7c93..db457b0 100644
--- a/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
+++ b/proton-c/bindings/cpp/src/blocking_connection_impl.cpp
@@ -50,7 +50,7 @@ blocking_connection_impl::blocking_connection_impl(const url& url, duration time
{
container_->reactor().start();
container_->reactor().timeout(timeout);
- handler *h = static_cast<handler*>(this); // Set this as handler.
+ messaging_handler* h = this; // Set this as handler.
connection_ = container_->connect(url, connection_options().handler(h));
wait(connection_opening(connection_));
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/blocking_fetcher.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_fetcher.hpp b/proton-c/bindings/cpp/src/blocking_fetcher.hpp
index d766bfc..337df3e 100644
--- a/proton-c/bindings/cpp/src/blocking_fetcher.hpp
+++ b/proton-c/bindings/cpp/src/blocking_fetcher.hpp
@@ -21,6 +21,7 @@
* under the License.
*
*/
+#include "proton/delivery.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/message.hpp"
#include <string>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection.cpp b/proton-c/bindings/cpp/src/connection.cpp
index 7469954..75465af 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -21,7 +21,6 @@
#include "proton/container.hpp"
#include "proton/connection.hpp"
#include "proton/transport.hpp"
-#include "proton/handler.hpp"
#include "proton/session.hpp"
#include "proton/error.hpp"
#include "connector.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/connection_engine.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_engine.cpp b/proton-c/bindings/cpp/src/connection_engine.cpp
index 2fadd00..639bd3c 100644
--- a/proton-c/bindings/cpp/src/connection_engine.cpp
+++ b/proton-c/bindings/cpp/src/connection_engine.cpp
@@ -19,10 +19,12 @@
#include "proton/connection_engine.hpp"
#include "proton/error.hpp"
+#include "proton/messaging_handler.hpp"
-#include "uuid.hpp"
-#include "proton_bits.hpp"
+#include "messaging_adapter.hpp"
#include "messaging_event.hpp"
+#include "proton_bits.hpp"
+#include "uuid.hpp"
#include <proton/connection.h>
#include <proton/transport.h>
@@ -32,7 +34,7 @@ namespace proton {
struct connection_engine::impl {
- impl(class handler& h, pn_transport_t *t) :
+ impl(class proton_handler& h, pn_transport_t *t) :
handler(h), transport(t), connection(pn_connection()), collector(pn_collector())
{}
@@ -50,13 +52,14 @@ struct connection_engine::impl {
pn_event_t *peek() { return pn_collector_peek(collector); }
void pop() { pn_collector_pop(collector); }
- class handler& handler;
+ class proton_handler& handler;
pn_transport_t *transport;
pn_connection_t *connection;
pn_collector_t * collector;
};
-connection_engine::connection_engine(handler &h, const std::string& id_) : impl_(new impl(h, pn_transport())) {
+connection_engine::connection_engine(messaging_handler &h, const std::string& id_) :
+ impl_(new impl(*h.messaging_adapter_.get(), pn_transport())) {
if (!impl_->transport || !impl_->connection || !impl_->collector)
throw error("connection_engine setup failed");
std::string id = id_.empty() ? uuid().str() : id_;
@@ -96,8 +99,8 @@ void connection_engine::run() {
default:
break;
}
- messaging_event mevent(e, pn_event_type(e), 0);
- mevent.dispatch(impl_->handler);
+ proton_event pevent(e, pn_event_type(e), 0);
+ pevent.dispatch(impl_->handler);
impl_->pop();
}
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp
index 3a3e0e1..4e5fb44 100644
--- a/proton-c/bindings/cpp/src/connection_options.cpp
+++ b/proton-c/bindings/cpp/src/connection_options.cpp
@@ -19,12 +19,15 @@
*
*/
#include "proton/connection_options.hpp"
+#include "proton/messaging_handler.hpp"
#include "proton/reconnect_timer.hpp"
#include "proton/transport.hpp"
#include "proton/ssl.hpp"
#include "proton/sasl.hpp"
+
#include "contexts.hpp"
#include "connector.hpp"
+#include "messaging_adapter.hpp"
#include "msg.hpp"
#include "proton/transport.h"
@@ -42,7 +45,7 @@ template <class T> struct option {
class connection_options::impl {
public:
- option<class handler*> handler;
+ option<proton_handler*> handler;
option<uint32_t> max_frame_size;
option<uint16_t> max_channels;
option<uint32_t> idle_timeout;
@@ -155,7 +158,7 @@ connection_options& connection_options::operator=(const connection_options& x) {
void connection_options::override(const connection_options& x) { impl_->override(*x.impl_); }
-connection_options& connection_options::handler(class handler *h) { impl_->handler = h; return *this; }
+connection_options& connection_options::handler(class messaging_handler *h) { impl_->handler = h->messaging_adapter_.get(); return *this; }
connection_options& connection_options::max_frame_size(uint32_t n) { impl_->max_frame_size = n; return *this; }
connection_options& connection_options::max_channels(uint16_t n) { impl_->max_frame_size = n; return *this; }
connection_options& connection_options::idle_timeout(uint32_t t) { impl_->idle_timeout = t; return *this; }
@@ -175,6 +178,6 @@ connection_options& connection_options::sasl_config_path(const std::string &p) {
void connection_options::apply(connection& c) const { impl_->apply(c); }
class client_domain &connection_options::client_domain() { return impl_->client_domain.value; }
class server_domain &connection_options::server_domain() { return impl_->server_domain.value; }
-handler* connection_options::handler() const { return impl_->handler.value; }
+proton_handler* connection_options::handler() const { return impl_->handler.value; }
pn_connection_t* connection_options::pn_connection(connection &c) { return c.pn_object(); }
} // namespace proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/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 9469496..4e5139c 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -20,15 +20,17 @@
*/
#include "connector.hpp"
+
#include "proton/connection.hpp"
#include "proton/transport.hpp"
#include "proton/container.hpp"
-#include "proton/event.hpp"
#include "proton/url.hpp"
#include "proton/reconnect_timer.hpp"
#include "proton/task.hpp"
#include "proton/sasl.hpp"
+
#include "container_impl.hpp"
+#include "proton_event.hpp"
#include "proton/connection.h"
#include "proton/transport.h"
@@ -74,24 +76,24 @@ void connector::connect() {
transport_configured_ = true;
}
-void connector::on_connection_local_open(event &) {
+void connector::on_connection_local_open(proton_event &) {
connect();
}
-void connector::on_connection_remote_open(event &) {
+void connector::on_connection_remote_open(proton_event &) {
if (reconnect_timer_) {
reconnect_timer_->reset();
}
}
-void connector::on_connection_init(event &) {
+void connector::on_connection_init(proton_event &) {
}
-void connector::on_transport_tail_closed(event &e) {
+void connector::on_transport_tail_closed(proton_event &e) {
on_transport_closed(e);
}
-void connector::on_transport_closed(event &e) {
+void connector::on_transport_closed(proton_event &e) {
if (!connection_) return;
if (connection_.state() & endpoint::LOCAL_ACTIVE) {
if (reconnect_timer_) {
@@ -106,7 +108,7 @@ void connector::on_transport_closed(event &e) {
}
else {
// log "Disconnected, reconnecting in " << delay << " milliseconds"
- connection_.container().schedule(delay, this);
+ connection_.container().impl_.get()->schedule(delay, this);
return;
}
}
@@ -116,7 +118,7 @@ void connector::on_transport_closed(event &e) {
connection_ = 0;
}
-void connector::on_timer_task(event &) {
+void connector::on_timer_task(proton_event &) {
connect();
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/connector.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connector.hpp b/proton-c/bindings/cpp/src/connector.hpp
index 458e2ba..65a1db4 100644
--- a/proton-c/bindings/cpp/src/connector.hpp
+++ b/proton-c/bindings/cpp/src/connector.hpp
@@ -22,11 +22,14 @@
*
*/
-#include "proton/proton_handler.hpp"
+#include "proton/connection.hpp"
#include "proton/connection_options.hpp"
#include "proton/url.hpp"
#include "proton/event.h"
#include "proton/reactor.h"
+
+#include "proton_handler.hpp"
+
#include <string>
@@ -48,12 +51,12 @@ class connector : public proton_handler
void apply_options();
void reconnect_timer(const class reconnect_timer &);
bool transport_configured();
- virtual void on_connection_local_open(event &e);
- virtual void on_connection_remote_open(event &e);
- virtual void on_connection_init(event &e);
- virtual void on_transport_closed(event &e);
- virtual void on_transport_tail_closed(event &e);
- virtual void on_timer_task(event &e);
+ virtual void on_connection_local_open(proton_event &e);
+ virtual void on_connection_remote_open(proton_event &e);
+ virtual void on_connection_init(proton_event &e);
+ virtual void on_transport_closed(proton_event &e);
+ virtual void on_transport_tail_closed(proton_event &e);
+ virtual void on_timer_task(proton_event &e);
private:
connection connection_;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container.cpp b/proton-c/bindings/cpp/src/container.cpp
index 01dcf2a..60bfcbd 100644
--- a/proton-c/bindings/cpp/src/container.cpp
+++ b/proton-c/bindings/cpp/src/container.cpp
@@ -19,11 +19,10 @@
*
*/
#include "proton/container.hpp"
-#include "messaging_event.hpp"
+
#include "proton/connection.hpp"
#include "proton/link_options.hpp"
#include "proton/session.hpp"
-#include "proton/messaging_adapter.hpp"
#include "proton/acceptor.hpp"
#include "proton/error.hpp"
#include "proton/url.hpp"
@@ -34,6 +33,9 @@
#include "container_impl.hpp"
#include "connector.hpp"
#include "contexts.hpp"
+#include "messaging_adapter.hpp"
+#include "messaging_event.hpp"
+
#include "proton/connection.h"
#include "proton/session.h"
@@ -46,7 +48,7 @@ container::container(const std::string& id) {
}
container::container(messaging_handler &mhandler, const std::string& id) {
- impl_.reset(new container_impl(*this, &mhandler, id));
+ impl_.reset(new container_impl(*this, mhandler.messaging_adapter_.get(), id));
}
container::~container() {}
@@ -73,7 +75,7 @@ acceptor container::listen(const proton::url &url, const connection_options &opt
return impl_->listen(url, opts);
}
-task container::schedule(int delay, handler *h) { return impl_->schedule(delay, h); }
+task container::schedule(int delay, messaging_handler *h) { return impl_->schedule(delay, h ? h->messaging_adapter_.get() : 0); }
void container::client_connection_options(const connection_options &o) { impl_->client_connection_options(o); }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/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 5a50cdd..dcc48a9 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -21,10 +21,8 @@
#include "proton/container.hpp"
#include "proton/connection_options.hpp"
#include "proton/event.hpp"
-#include "messaging_event.hpp"
#include "proton/connection.hpp"
#include "proton/session.hpp"
-#include "proton/messaging_adapter.hpp"
#include "proton/acceptor.hpp"
#include "proton/error.hpp"
#include "proton/url.hpp"
@@ -35,10 +33,12 @@
#include "proton/sasl.hpp"
#include "proton/transport.hpp"
-#include "msg.hpp"
-#include "container_impl.hpp"
#include "connector.hpp"
+#include "container_impl.hpp"
#include "contexts.hpp"
+#include "messaging_adapter.hpp"
+#include "messaging_event.hpp"
+#include "msg.hpp"
#include "uuid.hpp"
#include "proton/connection.h"
@@ -67,18 +67,18 @@ struct handler_context {
static void dispatch(pn_handler_t *c_handler, pn_event_t *c_event, pn_event_type_t type)
{
handler_context& hc(handler_context::get(c_handler));
- messaging_event mevent(c_event, type, hc.container_);
- mevent.dispatch(*hc.handler_);
+ proton_event pevent(c_event, type, hc.container_);
+ pevent.dispatch(*hc.handler_);
return;
}
container *container_;
- handler *handler_;
+ proton_handler *handler_;
};
// Used to sniff for connector events before the reactor's global handler sees them.
-class override_handler : public handler
+class override_handler : public proton_handler
{
public:
pn_ptr<pn_handler_t> base_handler;
@@ -86,22 +86,19 @@ class override_handler : public handler
override_handler(pn_handler_t *h, container_impl &c) : base_handler(h), container_impl_(c) {}
- virtual void on_unhandled(event &e) {
- proton_event *pne = dynamic_cast<proton_event *>(&e);
- // If not a Proton reactor event, nothing to override, nothing to pass along.
- if (!pne) return;
- int type = pne->type();
- if (!type) return; // Also not from the reactor
+ virtual void on_unhandled(proton_event &pe) {
+ proton_event::event_type type = pe.type();
+ if (type==proton_event::EVENT_NONE) return; // Also not from the reactor
- pn_event_t *cevent = pne->pn_event();
+ pn_event_t *cevent = pe.pn_event();
pn_connection_t *conn = pn_event_connection(cevent);
if (conn) {
- handler *override = connection_context::get(conn).handler.get();
- if (override && type != PN_CONNECTION_INIT) {
+ proton_handler *override = connection_context::get(conn).handler.get();
+ if (override && type != proton_event::CONNECTION_INIT) {
// Send event to connector
- e.dispatch(*override);
+ pe.dispatch(*override);
}
- else if (!override && type == PN_CONNECTION_INIT) {
+ else if (!override && type == proton_event::CONNECTION_INIT) {
// Newly accepted connection from lister socket
connection c(conn);
container_impl_.configure_server_connection(c);
@@ -113,7 +110,7 @@ class override_handler : public handler
} // namespace
-pn_ptr<pn_handler_t> container_impl::cpp_handler(handler *h) {
+pn_ptr<pn_handler_t> container_impl::cpp_handler(proton_handler *h) {
if (!h->pn_handler_) {
h->pn_handler_ = take_ownership(
pn_handler_new(&handler_context::dispatch,
@@ -126,7 +123,7 @@ pn_ptr<pn_handler_t> container_impl::cpp_handler(handler *h) {
return h->pn_handler_;
}
-container_impl::container_impl(container& c, handler *h, const std::string& id) :
+container_impl::container_impl(container& c, messaging_adapter *h, const std::string& id) :
container_(c), reactor_(reactor::create()), handler_(h), id_(id),
link_id_(0)
{
@@ -154,7 +151,7 @@ container_impl::~container_impl() {}
connection container_impl::connect(const proton::url &url, const connection_options &user_opts) {
connection_options opts = client_connection_options(); // Defaults
opts.override(user_opts);
- handler *h = opts.handler();
+ proton_handler *h = opts.handler();
pn_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : pn_ptr<pn_handler_t>();
connection conn(reactor_.connection(chandler.get()));
@@ -196,7 +193,7 @@ receiver container_impl::open_receiver(const proton::url &url, const proton::lin
acceptor container_impl::listen(const proton::url& url, const connection_options &user_opts) {
connection_options opts = server_connection_options(); // Defaults
opts.override(user_opts);
- handler *h = opts.handler();
+ proton_handler *h = opts.handler();
pn_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : pn_ptr<pn_handler_t>();
pn_acceptor_t *acptr = pn_reactor_acceptor(reactor_.pn_object(), url.host().c_str(), url.port().c_str(), chandler.get());
if (!acptr)
@@ -218,7 +215,7 @@ std::string container_impl::next_link_name() {
return s.str();
}
-task container_impl::schedule(int delay, handler *h) {
+task container_impl::schedule(int delay, proton_handler *h) {
pn_ptr<pn_handler_t> task_handler;
if (h)
task_handler = cpp_handler(h);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.hpp b/proton-c/bindings/cpp/src/container_impl.hpp
index 66c3aa6..035fb18 100644
--- a/proton-c/bindings/cpp/src/container_impl.hpp
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -28,6 +28,8 @@
#include "proton/duration.hpp"
#include "proton/reactor.hpp"
+#include "proton_handler.hpp"
+
#include "proton/reactor.h"
#include <string>
@@ -45,7 +47,7 @@ class task;
class container_impl
{
public:
- PN_CPP_EXTERN container_impl(container&, handler *, const std::string& id);
+ PN_CPP_EXTERN container_impl(container&, messaging_adapter*, const std::string& id);
PN_CPP_EXTERN ~container_impl();
PN_CPP_EXTERN connection connect(const url&, const connection_options&);
PN_CPP_EXTERN sender open_sender(const url&, const proton::link_options &, const connection_options &);
@@ -61,8 +63,8 @@ class container_impl
const proton::link_options& link_options() { return link_options_; }
void configure_server_connection(connection &c);
- task schedule(int delay, handler *h);
- pn_ptr<pn_handler_t> cpp_handler(handler *h);
+ task schedule(int delay, proton_handler *h);
+ pn_ptr<pn_handler_t> cpp_handler(proton_handler *h);
std::string next_link_name();
@@ -70,10 +72,9 @@ class container_impl
container& container_;
reactor reactor_;
- handler *handler_;
- pn_unique_ptr<messaging_adapter> messaging_adapter_;
- pn_unique_ptr<handler> override_handler_;
- pn_unique_ptr<handler> flow_controller_;
+ proton_handler *handler_;
+ pn_unique_ptr<proton_handler> override_handler_;
+ pn_unique_ptr<proton_handler> flow_controller_;
std::string id_;
uint64_t link_id_;
connection_options client_connection_options_;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/contexts.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.cpp b/proton-c/bindings/cpp/src/contexts.cpp
index 9b77d89..fba68c6 100644
--- a/proton-c/bindings/cpp/src/contexts.cpp
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -23,12 +23,12 @@
#include "msg.hpp"
#include "proton/error.hpp"
-#include "proton/handler.hpp"
#include "proton/object.h"
+#include "proton/link.h"
#include "proton/message.h"
+#include "proton/reactor.h"
#include "proton/session.h"
-#include "proton/link.h"
#include <typeinfo>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/contexts.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.hpp b/proton-c/bindings/cpp/src/contexts.hpp
index bb35bdf..98dd328 100644
--- a/proton-c/bindings/cpp/src/contexts.hpp
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -26,15 +26,17 @@
#include "proton/message.hpp"
#include "proton/connection.hpp"
#include "proton/container.hpp"
-#include "proton/handler.hpp"
+
+#include "proton_handler.hpp"
struct pn_session_t;
struct pn_event_t;
struct pn_record_t;
+struct pn_acceptor_t;
namespace proton {
-class handler;
+class proton_handler;
class container_impl;
// Base class for C++ classes that are used as proton contexts.
@@ -62,7 +64,7 @@ class connection_context : public context {
connection_context() : default_session(0), container_impl(0) {}
- pn_unique_ptr<class handler> handler;
+ pn_unique_ptr<proton_handler> handler;
pn_session_t *default_session; // Owned by connection
class container_impl* container_impl;
message event_message; // re-used by messaging_adapter for performance
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/event.cpp b/proton-c/bindings/cpp/src/event.cpp
index fd0e995..6490584 100644
--- a/proton-c/bindings/cpp/src/event.cpp
+++ b/proton-c/bindings/cpp/src/event.cpp
@@ -25,7 +25,6 @@
#include "proton/delivery.hpp"
#include "proton/error.hpp"
#include "proton/event.hpp"
-#include "proton/handler.hpp"
#include "proton/receiver.hpp"
#include "proton/sender.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/handler.cpp b/proton-c/bindings/cpp/src/handler.cpp
deleted file mode 100644
index f40ee1f..0000000
--- a/proton-c/bindings/cpp/src/handler.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * 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/handler.hpp"
-#include "proton/event.hpp"
-
-namespace proton {
-
-// container_impl.cpp sets pn_handler_ as needed.
-
-handler::handler() {}
-handler::~handler() {}
-
-void handler::on_unhandled(event &) {}
-
-void handler::add_child_handler(handler &e) {
- children_.push_back(&e);
-}
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/link.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/link.cpp b/proton-c/bindings/cpp/src/link.cpp
index 37337c0..075bc9f 100644
--- a/proton-c/bindings/cpp/src/link.cpp
+++ b/proton-c/bindings/cpp/src/link.cpp
@@ -79,7 +79,7 @@ class session link::session() const {
return pn_link_session(pn_object());
}
-void link::handler(class handler &h) {
+void link::handler(proton_handler &h) {
pn_record_t *record = pn_link_attachments(pn_object());
connection_context& cc(connection_context::get(connection()));
pn_ptr<pn_handler_t> chandler = cc.container_impl->cpp_handler(&h);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/link_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/link_options.cpp b/proton-c/bindings/cpp/src/link_options.cpp
index d5f8fb4..03c30ea 100644
--- a/proton-c/bindings/cpp/src/link_options.cpp
+++ b/proton-c/bindings/cpp/src/link_options.cpp
@@ -18,9 +18,12 @@
* under the License.
*
*/
-#include "proton/link_options.hpp"
#include "proton/link.hpp"
+#include "proton/link_options.hpp"
+#include "proton/messaging_handler.hpp"
+
#include "msg.hpp"
+#include "messaging_adapter.hpp"
namespace proton {
@@ -58,7 +61,7 @@ template <class T> struct option {
class link_options::impl {
public:
- option<class handler*> handler;
+ option<proton_handler*> handler;
option<terminus::distribution_mode_t> distribution_mode;
option<bool> durable_subscription;
option<link_delivery_mode_t> delivery_mode;
@@ -156,7 +159,7 @@ link_options& link_options::operator=(const link_options& x) {
void link_options::override(const link_options& x) { impl_->override(*x.impl_); }
-link_options& link_options::handler(class handler *h) { impl_->handler = h; return *this; }
+link_options& link_options::handler(class messaging_handler *h) { impl_->handler = h->messaging_adapter_.get(); return *this; }
link_options& link_options::browsing(bool b) { distribution_mode(b ? terminus::COPY : terminus::MOVE); return *this; }
link_options& link_options::distribution_mode(terminus::distribution_mode_t m) { impl_->distribution_mode = m; return *this; }
link_options& link_options::durable_subscription(bool b) {impl_->durable_subscription = b; return *this; }
@@ -167,6 +170,6 @@ link_options& link_options::lifetime_policy(lifetime_policy_t lp) {impl_->lifeti
link_options& link_options::selector(const std::string &str) {impl_->selector = str; return *this; }
void link_options::apply(link& l) const { impl_->apply(l); }
-handler* link_options::handler() const { return impl_->handler.value; }
+proton_handler* link_options::handler() const { return impl_->handler.value; }
} // namespace proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/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 ad8e850..e9ce0ea 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -18,12 +18,15 @@
* under the License.
*
*/
-#include "proton/messaging_adapter.hpp"
-#include "messaging_event.hpp"
+
+#include "messaging_adapter.hpp"
+
#include "proton/sender.hpp"
#include "proton/error.hpp"
-#include "msg.hpp"
+
#include "contexts.hpp"
+#include "messaging_event.hpp"
+#include "msg.hpp"
#include "proton/link.h"
#include "proton/handlers.h"
@@ -33,92 +36,122 @@
#include "proton/message.h"
namespace proton {
-messaging_adapter::messaging_adapter(messaging_handler &delegate) :
- messaging_handler(true, delegate.prefetch_, delegate.auto_settle_, delegate.auto_accept_, delegate.peer_close_iserror_),
- delegate_(delegate)
-{}
+
+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(proton_event &pne) {
+ pn_handler_dispatch(flowcontroller, pne.pn_event(), pn_event_type_t(pne.type()));
+ }
+
+ virtual void on_link_local_open(proton_event &e) { redirect(e); }
+ virtual void on_link_remote_open(proton_event &e) { redirect(e); }
+ virtual void on_link_flow(proton_event &e) { redirect(e); }
+ virtual void on_delivery(proton_event &e) { redirect(e); }
+};
+
+} // namespace
+
+void messaging_adapter::create_helpers() {
+ if (prefetch_ > 0) {
+ flow_controller_.reset(new c_flow_controller(prefetch_));
+ add_child_handler(*flow_controller_);
+ }
+}
+
+messaging_adapter::messaging_adapter(messaging_handler &delegate,
+ int prefetch, bool auto_accept, bool auto_settle, bool peer_close_iserror) :
+ delegate_(delegate),
+ prefetch_(prefetch),
+ auto_accept_(auto_accept),
+ auto_settle_(auto_settle),
+ peer_close_iserror_(peer_close_iserror)
+{
+ create_helpers();
+ //add_child_handler(*this);
+}
messaging_adapter::~messaging_adapter(){}
-void messaging_adapter::on_reactor_init(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- messaging_event mevent(messaging_event::START, *pe);
- delegate_.on_start(mevent);
- }
+void messaging_adapter::on_reactor_init(proton_event &pe) {
+ messaging_event mevent(messaging_event::START, pe);
+ delegate_.on_start(mevent);
}
-void messaging_adapter::on_link_flow(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- pn_event_t *pne = pe->pn_event();
- pn_link_t *lnk = pn_event_link(pne);
- if (lnk && pn_link_is_sender(lnk) && pn_link_credit(lnk) > 0) {
- // create on_message extended event
- messaging_event mevent(messaging_event::SENDABLE, *pe);
- delegate_.on_sendable(mevent);;
- }
- }
+void messaging_adapter::on_link_flow(proton_event &pe) {
+ pn_event_t *pne = pe.pn_event();
+ pn_link_t *lnk = pn_event_link(pne);
+ if (lnk && pn_link_is_sender(lnk) && pn_link_credit(lnk) > 0) {
+ // create on_message extended event
+ messaging_event mevent(messaging_event::SENDABLE, pe);
+ delegate_.on_sendable(mevent);;
+ }
}
-void messaging_adapter::on_delivery(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- pn_event_t *cevent = pe->pn_event();
- pn_link_t *lnk = pn_event_link(cevent);
- delivery dlv = pe->delivery();
-
- if (pn_link_is_receiver(lnk)) {
- if (!dlv.partial() && dlv.readable()) {
- // generate on_message
- messaging_event mevent(messaging_event::MESSAGE, *pe);
- pn_connection_t *pnc = pn_session_connection(pn_link_session(lnk));
- connection_context& ctx = connection_context::get(pnc);
- // Reusable per-connection message.
- // Avoid expensive heap malloc/free overhead.
- // See PROTON-998
- class message &msg(ctx.event_message);
- mevent.message_ = &msg;
- mevent.message_->decode(lnk, dlv);
- if (pn_link_state(lnk) & PN_LOCAL_CLOSED) {
- if (auto_accept_)
- dlv.release();
- } else {
- delegate_.on_message(mevent);
- if (auto_accept_ && !dlv.settled())
- dlv.accept();
- }
+void messaging_adapter::on_delivery(proton_event &pe) {
+ pn_event_t *cevent = pe.pn_event();
+ pn_link_t *lnk = pn_event_link(cevent);
+ delivery dlv = pe.delivery();
+
+ if (pn_link_is_receiver(lnk)) {
+ if (!dlv.partial() && dlv.readable()) {
+ // generate on_message
+ messaging_event mevent(messaging_event::MESSAGE, pe);
+ pn_connection_t *pnc = pn_session_connection(pn_link_session(lnk));
+ connection_context& ctx = connection_context::get(pnc);
+ // Reusable per-connection message.
+ // Avoid expensive heap malloc/free overhead.
+ // See PROTON-998
+ class message &msg(ctx.event_message);
+ mevent.message_ = &msg;
+ mevent.message_->decode(lnk, dlv);
+ if (pn_link_state(lnk) & PN_LOCAL_CLOSED) {
+ if (auto_accept_)
+ dlv.release();
+ } else {
+ delegate_.on_message(mevent);
+ if (auto_accept_ && !dlv.settled())
+ dlv.accept();
}
- else if (dlv.updated() && dlv.settled()) {
- messaging_event mevent(messaging_event::DELIVERY_SETTLE, *pe);
- delegate_.on_delivery_settle(mevent);
+ }
+ else if (dlv.updated() && dlv.settled()) {
+ messaging_event mevent(messaging_event::DELIVERY_SETTLE, pe);
+ delegate_.on_delivery_settle(mevent);
+ }
+ } else {
+ // sender
+ if (dlv.updated()) {
+ amqp_ulong rstate = dlv.remote_state();
+ if (rstate == PN_ACCEPTED) {
+ messaging_event mevent(messaging_event::DELIVERY_ACCEPT, pe);
+ delegate_.on_delivery_accept(mevent);
+ }
+ else if (rstate == PN_REJECTED) {
+ messaging_event mevent(messaging_event::DELIVERY_REJECT, pe);
+ delegate_.on_delivery_reject(mevent);
}
- } else {
- // sender
- if (dlv.updated()) {
- amqp_ulong rstate = dlv.remote_state();
- if (rstate == PN_ACCEPTED) {
- messaging_event mevent(messaging_event::DELIVERY_ACCEPT, *pe);
- delegate_.on_delivery_accept(mevent);
- }
- else if (rstate == PN_REJECTED) {
- messaging_event mevent(messaging_event::DELIVERY_REJECT, *pe);
- delegate_.on_delivery_reject(mevent);
- }
- else if (rstate == PN_RELEASED || rstate == PN_MODIFIED) {
- messaging_event mevent(messaging_event::DELIVERY_RELEASE, *pe);
- delegate_.on_delivery_release(mevent);
- }
-
- if (dlv.settled()) {
- messaging_event mevent(messaging_event::DELIVERY_SETTLE, *pe);
- delegate_.on_delivery_settle(mevent);
- }
- if (auto_settle_)
- dlv.settle();
+ else if (rstate == PN_RELEASED || rstate == PN_MODIFIED) {
+ messaging_event mevent(messaging_event::DELIVERY_RELEASE, pe);
+ delegate_.on_delivery_release(mevent);
}
+
+ if (dlv.settled()) {
+ messaging_event mevent(messaging_event::DELIVERY_SETTLE, pe);
+ delegate_.on_delivery_settle(mevent);
+ }
+ if (auto_settle_)
+ dlv.settle();
}
}
}
@@ -135,153 +168,93 @@ bool is_local_unititialised(pn_state_t state) {
} // namespace
-void messaging_adapter::on_link_remote_close(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- pn_event_t *cevent = pe->pn_event();
- pn_link_t *lnk = pn_event_link(cevent);
- if (pn_condition_is_set(pn_link_remote_condition(lnk))) {
- messaging_event mevent(messaging_event::LINK_ERROR, *pe);
- on_link_error(mevent);
- }
- else {
- messaging_event mevent(messaging_event::LINK_CLOSE, *pe);
- on_link_close(mevent);
- }
- pn_link_close(lnk);
+void messaging_adapter::on_link_remote_close(proton_event &pe) {
+ pn_event_t *cevent = pe.pn_event();
+ pn_link_t *lnk = pn_event_link(cevent);
+ if (pn_condition_is_set(pn_link_remote_condition(lnk))) {
+ messaging_event mevent(messaging_event::LINK_ERROR, pe);
+ delegate_.on_link_error(mevent);
}
-}
-
-void messaging_adapter::on_session_remote_close(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- pn_event_t *cevent = pe->pn_event();
- pn_session_t *session = pn_event_session(cevent);
- if (pn_condition_is_set(pn_session_remote_condition(session))) {
- messaging_event mevent(messaging_event::SESSION_ERROR, *pe);
- on_session_error(mevent);
- }
- else {
- messaging_event mevent(messaging_event::SESSION_CLOSE, *pe);
- on_session_close(mevent);
- }
- pn_session_close(session);
+ else {
+ messaging_event mevent(messaging_event::LINK_CLOSE, pe);
+ delegate_.on_link_close(mevent);
+ if (peer_close_iserror_)
+ delegate_.on_link_error(mevent);
}
+ pn_link_close(lnk);
}
-void messaging_adapter::on_connection_remote_close(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- pn_event_t *cevent = pe->pn_event();
- pn_connection_t *connection = pn_event_connection(cevent);
- if (pn_condition_is_set(pn_connection_remote_condition(connection))) {
- messaging_event mevent(messaging_event::CONNECTION_ERROR, *pe);
- on_connection_error(mevent);
- }
- else {
- messaging_event mevent(messaging_event::CONNECTION_CLOSE, *pe);
- on_connection_close(mevent);
- }
- pn_connection_close(connection);
+void messaging_adapter::on_session_remote_close(proton_event &pe) {
+ pn_event_t *cevent = pe.pn_event();
+ pn_session_t *session = pn_event_session(cevent);
+ if (pn_condition_is_set(pn_session_remote_condition(session))) {
+ messaging_event mevent(messaging_event::SESSION_ERROR, pe);
+ delegate_.on_session_error(mevent);
}
-}
-
-void messaging_adapter::on_connection_remote_open(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- messaging_event mevent(messaging_event::CONNECTION_OPEN, *pe);
- on_connection_open(mevent);
- pn_connection_t *connection = pn_event_connection(pe->pn_event());
- if (!is_local_open(pn_connection_state(connection)) && is_local_unititialised(pn_connection_state(connection))) {
- pn_connection_open(connection);
- }
+ else {
+ messaging_event mevent(messaging_event::SESSION_CLOSE, pe);
+ delegate_.on_session_close(mevent);
+ if (peer_close_iserror_)
+ delegate_.on_session_error(mevent);
}
+ pn_session_close(session);
}
-void messaging_adapter::on_session_remote_open(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- messaging_event mevent(messaging_event::SESSION_OPEN, *pe);
- on_session_open(mevent);
- pn_session_t *session = pn_event_session(pe->pn_event());
- if (!is_local_open(pn_session_state(session)) && is_local_unititialised(pn_session_state(session))) {
- pn_session_open(session);
- }
+void messaging_adapter::on_connection_remote_close(proton_event &pe) {
+ pn_event_t *cevent = pe.pn_event();
+ pn_connection_t *connection = pn_event_connection(cevent);
+ if (pn_condition_is_set(pn_connection_remote_condition(connection))) {
+ messaging_event mevent(messaging_event::CONNECTION_ERROR, pe);
+ delegate_.on_connection_error(mevent);
}
-}
-
-void messaging_adapter::on_link_remote_open(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- messaging_event mevent(messaging_event::LINK_OPEN, *pe);
- on_link_open(mevent);
- pn_link_t *link = pn_event_link(pe->pn_event());
- if (!is_local_open(pn_link_state(link)) && is_local_unititialised(pn_link_state(link))) {
- pn_link_open(link);
- }
+ else {
+ messaging_event mevent(messaging_event::CONNECTION_CLOSE, pe);
+ delegate_.on_connection_close(mevent);
+ if (peer_close_iserror_)
+ delegate_.on_connection_error(mevent);
}
+ pn_connection_close(connection);
}
-void messaging_adapter::on_transport_tail_closed(event &e) {
- proton_event *pe = dynamic_cast<proton_event*>(&e);
- if (pe) {
- pn_connection_t *conn = pn_event_connection(pe->pn_event());
- if (conn && is_local_open(pn_connection_state(conn))) {
- messaging_event mevent(messaging_event::DISCONNECT, *pe);
- delegate_.on_disconnect(mevent);
- }
+void messaging_adapter::on_connection_remote_open(proton_event &pe) {
+ messaging_event mevent(messaging_event::CONNECTION_OPEN, pe);
+ delegate_.on_connection_open(mevent);
+ pn_connection_t *connection = pn_event_connection(pe.pn_event());
+ if (!is_local_open(pn_connection_state(connection)) && is_local_unititialised(pn_connection_state(connection))) {
+ pn_connection_open(connection);
}
}
-
-void messaging_adapter::on_connection_open(event &e) {
- delegate_.on_connection_open(e);
-}
-
-void messaging_adapter::on_session_open(event &e) {
- delegate_.on_session_open(e);
-}
-
-void messaging_adapter::on_link_open(event &e) {
- delegate_.on_link_open(e);
-}
-
-void messaging_adapter::on_connection_error(event &e) {
- delegate_.on_connection_error(e);
-}
-
-void messaging_adapter::on_session_error(event &e) {
- delegate_.on_session_error(e);
-}
-
-void messaging_adapter::on_link_error(event &e) {
- delegate_.on_link_error(e);
-}
-
-void messaging_adapter::on_connection_close(event &e) {
- delegate_.on_connection_close(e);
- if (peer_close_iserror_)
- on_connection_error(e);
+void messaging_adapter::on_session_remote_open(proton_event &pe) {
+ messaging_event mevent(messaging_event::SESSION_OPEN, pe);
+ delegate_.on_session_open(mevent);
+ pn_session_t *session = pn_event_session(pe.pn_event());
+ if (!is_local_open(pn_session_state(session)) && is_local_unititialised(pn_session_state(session))) {
+ pn_session_open(session);
+ }
}
-void messaging_adapter::on_session_close(event &e) {
- delegate_.on_session_close(e);
- if (peer_close_iserror_)
- on_session_error(e);
+void messaging_adapter::on_link_remote_open(proton_event &pe) {
+ messaging_event mevent(messaging_event::LINK_OPEN, pe);
+ delegate_.on_link_open(mevent);
+ pn_link_t *link = pn_event_link(pe.pn_event());
+ if (!is_local_open(pn_link_state(link)) && is_local_unititialised(pn_link_state(link))) {
+ pn_link_open(link);
+ }
}
-void messaging_adapter::on_link_close(event &e) {
- delegate_.on_link_close(e);
- if (peer_close_iserror_)
- on_link_error(e);
+void messaging_adapter::on_transport_tail_closed(proton_event &pe) {
+ pn_connection_t *conn = pn_event_connection(pe.pn_event());
+ if (conn && is_local_open(pn_connection_state(conn))) {
+ messaging_event mevent(messaging_event::DISCONNECT, pe);
+ delegate_.on_disconnect(mevent);
+ }
}
-void messaging_adapter::on_timer_task(event& e)
+void messaging_adapter::on_timer_task(proton_event& pe)
{
- delegate_.on_timer(e);
-}
-
-void messaging_adapter::on_unhandled(event &) {
+ messaging_event mevent(messaging_event::TIMER, pe);
+ delegate_.on_timer(mevent);
}
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.hpp b/proton-c/bindings/cpp/src/messaging_adapter.hpp
new file mode 100644
index 0000000..866644d
--- /dev/null
+++ b/proton-c/bindings/cpp/src/messaging_adapter.hpp
@@ -0,0 +1,70 @@
+#ifndef PROTON_CPP_MESSAGING_ADAPTER_H
+#define PROTON_CPP_MESSAGING_ADAPTER_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/messaging_handler.hpp"
+
+#include "proton_handler.hpp"
+
+#include "proton/event.h"
+#include "proton/reactor.h"
+
+///@cond INTERNAL
+
+namespace proton {
+
+// Combine's Python's: endpoint_state_handler, incoming_message_handler, outgoing_message_handler
+
+class messaging_adapter : public proton_handler
+{
+ public:
+ PN_CPP_EXTERN messaging_adapter(messaging_handler &delegate,
+ int prefetch, bool auto_accept, bool auto_settle,
+ bool peer_close_is_error);
+ PN_CPP_EXTERN virtual ~messaging_adapter();
+
+ PN_CPP_EXTERN void on_reactor_init(proton_event &e);
+ PN_CPP_EXTERN void on_link_flow(proton_event &e);
+ PN_CPP_EXTERN void on_delivery(proton_event &e);
+ PN_CPP_EXTERN void on_connection_remote_open(proton_event &e);
+ PN_CPP_EXTERN void on_connection_remote_close(proton_event &e);
+ PN_CPP_EXTERN void on_session_remote_open(proton_event &e);
+ PN_CPP_EXTERN void on_session_remote_close(proton_event &e);
+ PN_CPP_EXTERN void on_link_remote_open(proton_event &e);
+ PN_CPP_EXTERN void on_link_remote_close(proton_event &e);
+ PN_CPP_EXTERN void on_transport_tail_closed(proton_event &e);
+ PN_CPP_EXTERN void on_timer_task(proton_event &e);
+
+ private:
+ messaging_handler &delegate_; // The handler for generated messaging_event's
+ int prefetch_;
+ bool auto_accept_;
+ bool auto_settle_;
+ bool peer_close_iserror_;
+ pn_unique_ptr<proton_handler> flow_controller_;
+ void create_helpers();
+};
+
+}
+///@endcond INTERNAL
+#endif /*!PROTON_CPP_MESSAGING_ADAPTER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/messaging_event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp
index b31e6f9..0c6c51d 100644
--- a/proton-c/bindings/cpp/src/messaging_event.cpp
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -19,19 +19,20 @@
*
*/
-#include "proton/reactor.h"
-#include "proton/event.h"
-#include "proton/link.h"
-
#include "messaging_event.hpp"
#include "proton/message.hpp"
-#include "proton/proton_handler.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/sender.hpp"
#include "proton/receiver.hpp"
#include "proton/error.hpp"
-#include "msg.hpp"
+
#include "contexts.hpp"
+#include "msg.hpp"
+#include "proton_handler.hpp"
+
+#include "proton/reactor.h"
+#include "proton/event.h"
+#include "proton/link.h"
/*
* Performance note:
@@ -40,56 +41,45 @@
namespace proton {
-messaging_event::messaging_event(pn_event_t *ce, proton_event::event_type t, class container *c) :
- proton_event(ce, t, c), type_(messaging_event::PROTON), parent_event_(0), message_(0)
-{}
-
messaging_event::messaging_event(event_type t, proton_event &p) :
- proton_event(NULL, PN_EVENT_NONE, p.container_), type_(t), parent_event_(&p), message_(0)
-{
- if (type_ == messaging_event::PROTON)
- throw error(MSG("invalid messaging event type"));
-}
+ type_(t), parent_event_(&p), message_(0)
+{}
messaging_event::~messaging_event() {}
messaging_event::event_type messaging_event::type() const { return type_; }
+container& messaging_event::container() const {
+ if (parent_event_)
+ return parent_event_->container();
+ throw error(MSG("No container context for event"));
+}
+
connection messaging_event::connection() const {
- if (type_ == messaging_event::PROTON)
- return proton_event::connection();
if (parent_event_)
return parent_event_->connection();
throw error(MSG("No connection context for event"));
}
sender messaging_event::sender() const {
- if (type_ == messaging_event::PROTON)
- return proton_event::sender();
if (parent_event_)
return parent_event_->sender();
throw error(MSG("No sender context for event"));
}
receiver messaging_event::receiver() const {
- if (type_ == messaging_event::PROTON)
- return proton_event::receiver();
if (parent_event_)
return parent_event_->receiver();
throw error(MSG("No receiver context for event"));
}
link messaging_event::link() const {
- if (type_ == messaging_event::PROTON)
- return proton_event::link();
if (parent_event_)
return parent_event_->link();
throw error(MSG("No link context for event"));
}
delivery messaging_event::delivery() const {
- if (type_ == messaging_event::PROTON)
- return proton_event::delivery();
if (parent_event_)
return parent_event_->delivery();
throw error(MSG("No delivery context for event"));
@@ -101,60 +91,8 @@ message &messaging_event::message() const {
return *message_;
}
-void messaging_event::dispatch(handler &h) {
- if (type_ == messaging_event::PROTON) {
- proton_event::dispatch(h);
- return;
- }
-
- messaging_handler *handler = dynamic_cast<messaging_handler*>(&h);
- if (handler) {
- switch(type_) {
-
- case messaging_event::START: handler->on_start(*this); break;
- case messaging_event::SENDABLE: handler->on_sendable(*this); break;
- case messaging_event::MESSAGE: handler->on_message(*this); break;
- case messaging_event::DISCONNECT: handler->on_disconnect(*this); break;
-
- case messaging_event::CONNECTION_CLOSE: handler->on_connection_close(*this); break;
- case messaging_event::CONNECTION_ERROR: handler->on_connection_error(*this); break;
- case messaging_event::CONNECTION_OPEN: handler->on_connection_open(*this); break;
-
- case messaging_event::SESSION_CLOSE: handler->on_session_close(*this); break;
- case messaging_event::SESSION_ERROR: handler->on_session_error(*this); break;
- case messaging_event::SESSION_OPEN: handler->on_session_open(*this); break;
-
- case messaging_event::LINK_CLOSE: handler->on_link_close(*this); break;
- case messaging_event::LINK_ERROR: handler->on_link_error(*this); break;
- case messaging_event::LINK_OPEN: handler->on_link_open(*this); break;
-
- case messaging_event::DELIVERY_ACCEPT: handler->on_delivery_accept(*this); break;
- case messaging_event::DELIVERY_REJECT: handler->on_delivery_reject(*this); break;
- case messaging_event::DELIVERY_RELEASE: handler->on_delivery_release(*this); break;
- case messaging_event::DELIVERY_SETTLE: handler->on_delivery_settle(*this); break;
-
- case messaging_event::TRANSACTION_DECLARE: handler->on_transaction_declare(*this); break;
- case messaging_event::TRANSACTION_COMMIT: handler->on_transaction_commit(*this); break;
- case messaging_event::TRANSACTION_ABORT: handler->on_transaction_abort(*this); break;
-
- case messaging_event::TIMER: handler->on_timer(*this); break;
-
- default:
- throw error(MSG("Unknown messaging event type " << type_));
- }
- } else {
- h.on_unhandled(*this);
- }
-
- // recurse through children
- for (handler::iterator child = h.children_.begin(); child != h.children_.end(); ++child) {
- dispatch(**child);
- }
-}
-
std::string messaging_event::name() const {
switch (type()) {
- case PROTON: return pn_event_type_name(pn_event_type_t(proton_event::type()));
case START: return "START";
case MESSAGE: return "MESSAGE";
case SENDABLE: return "SENDABLE";
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5c68c48/proton-c/bindings/cpp/src/messaging_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_event.hpp b/proton-c/bindings/cpp/src/messaging_event.hpp
index 31ba7d2..64e8975 100644
--- a/proton-c/bindings/cpp/src/messaging_event.hpp
+++ b/proton-c/bindings/cpp/src/messaging_event.hpp
@@ -33,7 +33,7 @@ class connection;
class message;
/** An event for the proton::messaging_handler */
-class messaging_event : public proton_event
+class messaging_event : public event
{
public:
@@ -43,7 +43,6 @@ class messaging_event : public proton_event
/** Event types for a messaging_handler */
enum event_type {
- PROTON = 0, // Wrapped pn_event_t
START,
MESSAGE,
SENDABLE,
@@ -67,17 +66,16 @@ class messaging_event : public proton_event
TIMER
};
- messaging_event(pn_event_t *, proton_event::event_type, class container *);
messaging_event(event_type t, proton_event &parent);
~messaging_event();
- virtual PN_CPP_EXTERN void dispatch(handler &h);
- virtual PN_CPP_EXTERN class connection connection() const;
- virtual PN_CPP_EXTERN class sender sender() const;
- virtual PN_CPP_EXTERN class receiver receiver() const;
- virtual PN_CPP_EXTERN class link link() const;
- virtual PN_CPP_EXTERN class delivery delivery() const;
- virtual PN_CPP_EXTERN class message& message() const;
+ PN_CPP_EXTERN class container& container() const;
+ PN_CPP_EXTERN class connection connection() const;
+ PN_CPP_EXTERN class sender sender() const;
+ PN_CPP_EXTERN class receiver receiver() const;
+ PN_CPP_EXTERN class link link() const;
+ PN_CPP_EXTERN class delivery delivery() const;
+ PN_CPP_EXTERN class message& message() const;
PN_CPP_EXTERN event_type type() const;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org