You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2014/10/10 14:47:29 UTC

svn commit: r1630810 - in /qpid/proton/branches/examples/proton-c: CMakeLists.txt include/proton/event.h src/engine/engine.c src/engine/event.c src/engine/event.h src/events/ src/events/event.c src/transport/transport.c

Author: gsim
Date: Fri Oct 10 12:47:29 2014
New Revision: 1630810

URL: http://svn.apache.org/r1630810
Log:
moved event code into its own directory; made pn_collector_put public

Added:
    qpid/proton/branches/examples/proton-c/src/events/
    qpid/proton/branches/examples/proton-c/src/events/event.c
      - copied, changed from r1630809, qpid/proton/branches/examples/proton-c/src/engine/event.c
Removed:
    qpid/proton/branches/examples/proton-c/src/engine/event.c
    qpid/proton/branches/examples/proton-c/src/engine/event.h
Modified:
    qpid/proton/branches/examples/proton-c/CMakeLists.txt
    qpid/proton/branches/examples/proton-c/include/proton/event.h
    qpid/proton/branches/examples/proton-c/src/engine/engine.c
    qpid/proton/branches/examples/proton-c/src/transport/transport.c

Modified: qpid/proton/branches/examples/proton-c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-c/CMakeLists.txt?rev=1630810&r1=1630809&r2=1630810&view=diff
==============================================================================
--- qpid/proton/branches/examples/proton-c/CMakeLists.txt (original)
+++ qpid/proton/branches/examples/proton-c/CMakeLists.txt Fri Oct 10 12:47:29 2014
@@ -280,7 +280,7 @@ set (qpid-proton-core
 
   src/dispatcher/dispatcher.c
   src/engine/engine.c
-  src/engine/event.c
+  src/events/event.c
   src/transport/transport.c
   src/message/message.c
   src/sasl/sasl.c

Modified: qpid/proton/branches/examples/proton-c/include/proton/event.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-c/include/proton/event.h?rev=1630810&r1=1630809&r2=1630810&view=diff
==============================================================================
--- qpid/proton/branches/examples/proton-c/include/proton/event.h (original)
+++ qpid/proton/branches/examples/proton-c/include/proton/event.h Fri Oct 10 12:47:29 2014
@@ -257,6 +257,25 @@ PN_EXTERN pn_collector_t *pn_collector(v
 PN_EXTERN void pn_collector_free(pn_collector_t *collector);
 
 /**
+ * Place a new event on a collector.
+ *
+ * This operation will create a new event of the given type and
+ * context and return a pointer to the newly created event. In some
+ * cases an event of the given type and context can be elided. When
+ * this happens, this operation will return a NULL pointer.
+ *
+ * @param[in] collector a collector object
+ * @param[in] type the event type
+ * @param[in] context the event context
+ *
+ * @return a pointer to the newly created event or NULL if the event
+ *         was elided
+ */
+
+pn_event_t *pn_collector_put(pn_collector_t *collector, pn_event_type_t type,
+                             void *context);
+
+/**
  * Access the head event contained by a collector.
  *
  * This operation will continue to return the same event until it is

Modified: qpid/proton/branches/examples/proton-c/src/engine/engine.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-c/src/engine/engine.c?rev=1630810&r1=1630809&r2=1630810&view=diff
==============================================================================
--- qpid/proton/branches/examples/proton-c/src/engine/engine.c (original)
+++ qpid/proton/branches/examples/proton-c/src/engine/engine.c Fri Oct 10 12:47:29 2014
@@ -33,7 +33,6 @@
 #include "../platform.h"
 #include "../platform_fmt.h"
 #include "../transport/transport.h"
-#include "../engine/event.h"
 
 // endpoints
 
@@ -332,8 +331,6 @@ void pn_endpoint_tini(pn_endpoint_t *end
   pn_condition_tini(&endpoint->condition);
 }
 
-#include "event.h"
-
 static bool pni_post_final(pn_endpoint_t *endpoint, pn_event_type_t type)
 {
   pn_connection_t *conn = pn_ep_get_connection(endpoint);
@@ -1754,3 +1751,77 @@ int pn_condition_redirect_port(pn_condit
   pn_data_rewind(data);
   return port;
 }
+
+pn_connection_t *pn_event_connection(pn_event_t *event)
+{
+  pn_session_t *ssn;
+  pn_transport_t *transport;
+
+  switch (pn_event_category(event)) {
+  case PN_EVENT_CATEGORY_CONNECTION:
+    return (pn_connection_t *) pn_event_context(event);
+  case PN_EVENT_CATEGORY_TRANSPORT:
+    transport = pn_event_transport(event);
+    if (transport)
+      return transport->connection;
+    return NULL;
+  default:
+    ssn = pn_event_session(event);
+    if (ssn)
+     return pn_session_connection(ssn);
+  }
+  return NULL;
+}
+
+pn_session_t *pn_event_session(pn_event_t *event)
+{
+  pn_link_t *link;
+  switch (pn_event_category(event)) {
+  case PN_EVENT_CATEGORY_SESSION:
+    return (pn_session_t *) pn_event_context(event);
+  default:
+    link = pn_event_link(event);
+    if (link)
+      return pn_link_session(link);
+  }
+  return NULL;
+}
+
+pn_link_t *pn_event_link(pn_event_t *event)
+{
+  pn_delivery_t *dlv;
+  switch (pn_event_category(event)) {
+  case PN_EVENT_CATEGORY_LINK:
+    return (pn_link_t *) pn_event_context(event);
+  default:
+    dlv = pn_event_delivery(event);
+    if (dlv)
+      return pn_delivery_link(dlv);
+  }
+  return NULL;
+}
+
+pn_delivery_t *pn_event_delivery(pn_event_t *event)
+{
+  switch (pn_event_category(event)) {
+  case PN_EVENT_CATEGORY_DELIVERY:
+    return (pn_delivery_t *) pn_event_context(event);
+  default:
+    return NULL;
+  }
+}
+
+pn_transport_t *pn_event_transport(pn_event_t *event)
+{
+  switch (pn_event_category(event)) {
+  case PN_EVENT_CATEGORY_TRANSPORT:
+    return (pn_transport_t *) pn_event_context(event);
+  default:
+    {
+      pn_connection_t *conn = pn_event_connection(event);
+      if (conn)
+        return pn_connection_transport(conn);
+      return NULL;
+    }
+  }
+}

Copied: qpid/proton/branches/examples/proton-c/src/events/event.c (from r1630809, qpid/proton/branches/examples/proton-c/src/engine/event.c)
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-c/src/events/event.c?p2=qpid/proton/branches/examples/proton-c/src/events/event.c&p1=qpid/proton/branches/examples/proton-c/src/engine/event.c&r1=1630809&r2=1630810&rev=1630810&view=diff
==============================================================================
--- qpid/proton/branches/examples/proton-c/src/engine/event.c (original)
+++ qpid/proton/branches/examples/proton-c/src/events/event.c Fri Oct 10 12:47:29 2014
@@ -1,6 +1,6 @@
-#include <proton/engine.h>
+#include <proton/object.h>
+#include <proton/event.h>
 #include <assert.h>
-#include "engine-internal.h"
 
 struct pn_collector_t {
   pn_event_t *head;
@@ -221,80 +221,6 @@ void *pn_event_context(pn_event_t *event
   return event->context;
 }
 
-pn_connection_t *pn_event_connection(pn_event_t *event)
-{
-  pn_session_t *ssn;
-  pn_transport_t *transport;
-
-  switch (pn_event_category(event)) {
-  case PN_EVENT_CATEGORY_CONNECTION:
-    return (pn_connection_t *)event->context;
-  case PN_EVENT_CATEGORY_TRANSPORT:
-    transport = pn_event_transport(event);
-    if (transport)
-      return transport->connection;
-    return NULL;
-  default:
-    ssn = pn_event_session(event);
-    if (ssn)
-     return pn_session_connection(ssn);
-  }
-  return NULL;
-}
-
-pn_session_t *pn_event_session(pn_event_t *event)
-{
-  pn_link_t *link;
-  switch (pn_event_category(event)) {
-  case PN_EVENT_CATEGORY_SESSION:
-    return (pn_session_t *)event->context;
-  default:
-    link = pn_event_link(event);
-    if (link)
-      return pn_link_session(link);
-  }
-  return NULL;
-}
-
-pn_link_t *pn_event_link(pn_event_t *event)
-{
-  pn_delivery_t *dlv;
-  switch (pn_event_category(event)) {
-  case PN_EVENT_CATEGORY_LINK:
-    return (pn_link_t *)event->context;
-  default:
-    dlv = pn_event_delivery(event);
-    if (dlv)
-      return pn_delivery_link(dlv);
-  }
-  return NULL;
-}
-
-pn_delivery_t *pn_event_delivery(pn_event_t *event)
-{
-  switch (pn_event_category(event)) {
-  case PN_EVENT_CATEGORY_DELIVERY:
-    return (pn_delivery_t *)event->context;
-  default:
-    return NULL;
-  }
-}
-
-pn_transport_t *pn_event_transport(pn_event_t *event)
-{
-  switch (pn_event_category(event)) {
-  case PN_EVENT_CATEGORY_TRANSPORT:
-    return (pn_transport_t *)event->context;
-  default:
-    {
-      pn_connection_t *conn = pn_event_connection(event);
-      if (conn)
-        return pn_connection_transport(conn);
-      return NULL;
-    }
-  }
-}
-
 const char *pn_event_type_name(pn_event_type_t type)
 {
   switch (type) {

Modified: qpid/proton/branches/examples/proton-c/src/transport/transport.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-c/src/transport/transport.c?rev=1630810&r1=1630809&r2=1630810&view=diff
==============================================================================
--- qpid/proton/branches/examples/proton-c/src/transport/transport.c (original)
+++ qpid/proton/branches/examples/proton-c/src/transport/transport.c Fri Oct 10 12:47:29 2014
@@ -30,8 +30,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#include "../engine/event.h"
-
 #include "../sasl/sasl-internal.h"
 #include "../ssl/ssl-internal.h"
 #include "../platform.h"



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