qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [1/2] qpid-proton git commit: NO-JIRA: C++: Add event::name() to give event type name as string, for debugging/logging.
Date Fri, 09 Oct 2015 20:25:15 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 8112f5f09 -> 617cf6554


NO-JIRA: C++: Add event::name() to give event type name as string, for debugging/logging.


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

Branch: refs/heads/master
Commit: da3ee2c8fe67530ec8421f2b95148190b7aac255
Parents: 8112f5f
Author: Alan Conway <aconway@redhat.com>
Authored: Fri Oct 9 15:26:55 2015 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Fri Oct 9 15:37:43 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/event.hpp  |  5 +++
 .../cpp/include/proton/messaging_event.hpp      |  2 +
 .../cpp/include/proton/proton_event.hpp         |  4 +-
 proton-c/bindings/cpp/src/event.cpp             |  1 -
 proton-c/bindings/cpp/src/messaging_event.cpp   | 44 ++++++++++++++++++++
 proton-c/bindings/cpp/src/proton_event.cpp      |  6 ++-
 6 files changed, 59 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/da3ee2c8/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 486a5c9..82f6cb6 100644
--- a/proton-c/bindings/cpp/include/proton/event.hpp
+++ b/proton-c/bindings/cpp/include/proton/event.hpp
@@ -26,6 +26,7 @@
 #include "proton/connection.hpp"
 #include "proton/message.hpp"
 #include <vector>
+#include <string>
 
 namespace proton {
 
@@ -41,6 +42,9 @@ class 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;
+
     /// Get container.
     virtual PN_CPP_EXTERN class container &container();
     /// Get connection.
@@ -64,6 +68,7 @@ class event {
     event& operator=(const event&);
 };
 
+
 }
 
 #endif  /*!PROTON_CPP_EVENT_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/da3ee2c8/proton-c/bindings/cpp/include/proton/messaging_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/messaging_event.hpp b/proton-c/bindings/cpp/include/proton/messaging_event.hpp
index 5553faf..d130064 100644
--- a/proton-c/bindings/cpp/include/proton/messaging_event.hpp
+++ b/proton-c/bindings/cpp/include/proton/messaging_event.hpp
@@ -37,6 +37,8 @@ class messaging_event : public proton_event
 {
   public:
 
+    std::string name() const;
+
     // TODO aconway 2015-07-16: document meaning of each event type.
 
     /** Event types for a messaging_handler */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/da3ee2c8/proton-c/bindings/cpp/include/proton/proton_event.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/proton_event.hpp b/proton-c/bindings/cpp/include/proton/proton_event.hpp
index c809e55..f71af55 100644
--- a/proton-c/bindings/cpp/include/proton/proton_event.hpp
+++ b/proton-c/bindings/cpp/include/proton/proton_event.hpp
@@ -38,6 +38,8 @@ class proton_event : public event
 {
   public:
 
+    std::string name() const;
+
     ///@name Event types
     ///@{
 
@@ -279,7 +281,7 @@ class proton_event : public event
     virtual PN_CPP_EXTERN class delivery& delivery();
 
     /** Get type of event */
-    PN_CPP_EXTERN event_type type();
+    PN_CPP_EXTERN event_type type() const;
 
     PN_CPP_EXTERN pn_event_t* pn_event();
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/da3ee2c8/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 d7a99dc..84927c4 100644
--- a/proton-c/bindings/cpp/src/event.cpp
+++ b/proton-c/bindings/cpp/src/event.cpp
@@ -38,7 +38,6 @@ event::event() {}
 
 event::~event() {}
 
-
 container &event::container() {
     // Subclasses to override as appropriate
     throw error(MSG("No container context for event"));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/da3ee2c8/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 82f9159..e602dc4 100644
--- a/proton-c/bindings/cpp/src/messaging_event.cpp
+++ b/proton-c/bindings/cpp/src/messaging_event.cpp
@@ -152,4 +152,48 @@ void messaging_event::dispatch(handler &h) {
     }
 }
 
+std::string messaging_event::name() const {
+    switch (type()) {
+      case PROTON: return pn_event_type_name(pn_event_type_t(proton_event::type()));
+      case ABORT: return "ABORT";
+      case ACCEPTED: return "ACCEPTED";
+      case COMMIT: return "COMMIT";
+      case CONNECTION_CLOSED: return "CONNECTION_CLOSED";
+      case CONNECTION_CLOSING: return "CONNECTION_CLOSING";
+      case CONNECTION_ERROR: return "CONNECTION_ERROR";
+      case CONNECTION_OPENED: return "CONNECTION_OPENED";
+      case CONNECTION_OPENING: return "CONNECTION_OPENING";
+      case DISCONNECTED: return "DISCONNECTED";
+      case FETCH: return "FETCH";
+      case ID_LOADED: return "ID_LOADED";
+      case LINK_CLOSED: return "LINK_CLOSED";
+      case LINK_CLOSING: return "LINK_CLOSING";
+      case LINK_OPENED: return "LINK_OPENED";
+      case LINK_OPENING: return "LINK_OPENING";
+      case LINK_ERROR: return "LINK_ERROR";
+      case MESSAGE: return "MESSAGE";
+      case QUIT: return "QUIT";
+      case RECORD_INSERTED: return "RECORD_INSERTED";
+      case RECORDS_LOADED: return "RECORDS_LOADED";
+      case REJECTED: return "REJECTED";
+      case RELEASED: return "RELEASED";
+      case REQUEST: return "REQUEST";
+      case RESPONSE: return "RESPONSE";
+      case SENDABLE: return "SENDABLE";
+      case SESSION_CLOSED: return "SESSION_CLOSED";
+      case SESSION_CLOSING: return "SESSION_CLOSING";
+      case SESSION_OPENED: return "SESSION_OPENED";
+      case SESSION_OPENING: return "SESSION_OPENING";
+      case SESSION_ERROR: return "SESSION_ERROR";
+      case SETTLED: return "SETTLED";
+      case START: return "START";
+      case TIMER: return "TIMER";
+      case TRANSACTION_ABORTED: return "TRANSACTION_ABORTED";
+      case TRANSACTION_COMMITTED: return "TRANSACTION_COMMITTED";
+      case TRANSACTION_DECLARED: return "TRANSACTION_DECLARED";
+      case TRANSPORT_CLOSED: return "TRANSPORT_CLOSED";
+      default: return "UNKNOWN";
+    }
+}
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/da3ee2c8/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 4b2d3ac..9b08826 100644
--- a/proton-c/bindings/cpp/src/proton_event.cpp
+++ b/proton-c/bindings/cpp/src/proton_event.cpp
@@ -42,7 +42,9 @@ proton_event::proton_event(pn_event_t *ce, proton_event::event_type t, class
con
     container_(c)
 {}
 
-int proton_event::type() { return type_; }
+int proton_event::type() const { return type_; }
+
+std::string proton_event::name() const { return pn_event_type_name(pn_event_type_t(type_));
}
 
 pn_event_t *proton_event::pn_event() { return pn_event_; }
 
@@ -181,3 +183,5 @@ const proton_event::event_type proton_event::SELECTABLE_ERROR=PN_SELECTABLE_ERRO
 const proton_event::event_type proton_event::SELECTABLE_EXPIRED=PN_SELECTABLE_EXPIRED;
 const proton_event::event_type proton_event::SELECTABLE_FINAL=PN_SELECTABLE_FINAL;
 }
+
+


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


Mime
View raw message