qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject [5/6] qpid-proton git commit: PROTON-1153: [C++ binding] Use some template magic to get rid of friend declaraions - Get rid of all friend declarations in the public API casued by implementation code needing to create wrapper types for proton-c
Date Thu, 28 Apr 2016 00:48:13 GMT
PROTON-1153: [C++ binding] Use some template magic to get rid of friend declaraions
- Get rid of all friend declarations in the public API casued by implementation
  code needing to create wrapper types for proton-c


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

Branch: refs/heads/master
Commit: 8c1194c092ae8dca166fa75e7e7c5af194c248d6
Parents: b7d22d7
Author: Andrew Stitcher <astitcher@apache.org>
Authored: Wed Apr 20 18:19:05 2016 -0400
Committer: Andrew Stitcher <astitcher@apache.org>
Committed: Wed Apr 27 17:58:40 2016 -0400

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/acceptor.hpp    |  3 +-
 .../bindings/cpp/include/proton/connection.hpp  | 12 +--
 .../bindings/cpp/include/proton/delivery.hpp    |  5 +-
 .../cpp/include/proton/error_condition.hpp      |  9 +--
 .../bindings/cpp/include/proton/handler.hpp     |  1 -
 proton-c/bindings/cpp/include/proton/link.hpp   | 30 +++-----
 proton-c/bindings/cpp/include/proton/object.hpp |  3 +
 .../bindings/cpp/include/proton/receiver.hpp    | 14 ++--
 .../cpp/include/proton/reconnect_timer.hpp      |  2 -
 proton-c/bindings/cpp/include/proton/sasl.hpp   |  4 +-
 proton-c/bindings/cpp/include/proton/sender.hpp |  9 +--
 proton-c/bindings/cpp/include/proton/ssl.hpp    |  3 +-
 .../bindings/cpp/include/proton/terminus.hpp    |  8 +-
 .../bindings/cpp/include/proton/tracker.hpp     | 11 ++-
 .../bindings/cpp/include/proton/transfer.hpp    |  2 +-
 .../bindings/cpp/include/proton/transport.hpp   |  2 +-
 proton-c/bindings/cpp/src/connection.cpp        |  7 +-
 proton-c/bindings/cpp/src/container_impl.cpp    |  5 +-
 proton-c/bindings/cpp/src/delivery.cpp          |  5 +-
 proton-c/bindings/cpp/src/endpoint.cpp          |  2 -
 proton-c/bindings/cpp/src/link.cpp              | 13 ++--
 proton-c/bindings/cpp/src/messaging_adapter.cpp | 59 ++++++++-------
 proton-c/bindings/cpp/src/proton_bits.cpp       |  2 +
 proton-c/bindings/cpp/src/proton_bits.hpp       | 77 +++++++++++++++++++-
 proton-c/bindings/cpp/src/proton_event.cpp      |  1 +
 proton-c/bindings/cpp/src/reactor.cpp           |  5 +-
 proton-c/bindings/cpp/src/receiver.cpp          |  5 +-
 proton-c/bindings/cpp/src/receiver_options.cpp  | 11 +--
 proton-c/bindings/cpp/src/sender.cpp            |  6 +-
 proton-c/bindings/cpp/src/session.cpp           | 13 ++--
 proton-c/bindings/cpp/src/source.cpp            |  8 +-
 proton-c/bindings/cpp/src/target.cpp            |  8 +-
 proton-c/bindings/cpp/src/tracker.cpp           |  5 +-
 proton-c/bindings/cpp/src/transfer.cpp          |  6 +-
 proton-c/bindings/cpp/src/transport.cpp         |  9 ++-
 proton-c/bindings/cpp/src/types_internal.hpp    |  7 +-
 36 files changed, 225 insertions(+), 147 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/acceptor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/acceptor.hpp b/proton-c/bindings/cpp/include/proton/acceptor.hpp
index 1b0ea12..b0e11ed 100644
--- a/proton-c/bindings/cpp/include/proton/acceptor.hpp
+++ b/proton-c/bindings/cpp/include/proton/acceptor.hpp
@@ -52,8 +52,7 @@ class acceptor : public internal::object<pn_acceptor_t> {
     PN_CPP_EXTERN class connection_options &connection_options();
 
     /// @cond INTERNAL
-    friend class reactor;
-    friend class container_impl;
+    friend class internal::factory<acceptor>;
     /// @endcond
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/connection.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection.hpp b/proton-c/bindings/cpp/include/proton/connection.hpp
index e562df7..60ffe6e 100644
--- a/proton-c/bindings/cpp/include/proton/connection.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection.hpp
@@ -42,10 +42,6 @@ namespace io {
 class connection_engine;
 }
 
-namespace internal {
-class link;
-}
-
 /// A connection to a remote AMQP peer.
 class
 PN_CPP_CLASS_EXTERN connection : public internal::object<pn_connection_t>, public endpoint {
@@ -123,19 +119,13 @@ PN_CPP_CLASS_EXTERN connection : public internal::object<pn_connection_t>, publi
     void password(const std::string &);
     void host(const std::string& h);
 
+    friend class internal::factory<connection>;
     friend class connection_context;
     friend class io::connection_engine;
     friend class connection_options;
     friend class connector;
     friend class container_impl;
     friend class transport;
-    friend class session;
-    friend class internal::link;
-    friend class transfer;
-    friend class reactor;
-    friend class proton_event;
-    friend class override_handler;
-    friend class messaging_adapter;
     /// @endcond
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/delivery.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/delivery.hpp b/proton-c/bindings/cpp/include/proton/delivery.hpp
index 49f68af..a7e0511 100644
--- a/proton-c/bindings/cpp/include/proton/delivery.hpp
+++ b/proton-c/bindings/cpp/include/proton/delivery.hpp
@@ -38,10 +38,12 @@ class receiver;
 /// particular message may correspond to multiple deliveries.
 class delivery : public transfer {
     /// @cond INTERNAL
-    delivery(pn_delivery_t* d) : transfer(d) {}
+    delivery(pn_delivery_t* d);
     /// @endcond
 
   public:
+    delivery() {}
+
     // Return the receiver for this delivery
     PN_CPP_EXTERN class receiver receiver() const;
 
@@ -71,6 +73,7 @@ class delivery : public transfer {
     /// delivery on a receiver.
     bool readable() const;
 
+  friend class internal::factory<delivery>;
   friend class message;
   friend class messaging_adapter;
     /// @endcond

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/error_condition.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/error_condition.hpp b/proton-c/bindings/cpp/include/proton/error_condition.hpp
index 0b9fa9f..14b8544 100644
--- a/proton-c/bindings/cpp/include/proton/error_condition.hpp
+++ b/proton-c/bindings/cpp/include/proton/error_condition.hpp
@@ -34,10 +34,6 @@ struct pn_condition_t;
 
 namespace proton {
 
-namespace internal {
-class link;
-}
-
 /// Describes an endpoint error state.
 class error_condition {
     /// @cond INTERNAL
@@ -84,10 +80,7 @@ class error_condition {
     std::string description_;
     proton::value properties_;
 
-    friend class transport;
-    friend class connection;
-    friend class session;
-    friend class internal::link;
+    friend class internal::factory<error_condition>;
     /// @endcond
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/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
index f963369..8806c17 100644
--- a/proton-c/bindings/cpp/include/proton/handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/handler.hpp
@@ -34,7 +34,6 @@ class event;
 class transport;
 class connection;
 class session;
-class link;
 class sender;
 class receiver;
 class tracker;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/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 9af4523..ed2c5ca 100644
--- a/proton-c/bindings/cpp/include/proton/link.hpp
+++ b/proton-c/bindings/cpp/include/proton/link.hpp
@@ -57,7 +57,6 @@ namespace internal {
 /// class for sender and receiver.
 class
 PN_CPP_CLASS_EXTERN link : public object<pn_link_t> , public endpoint {
-  private:
     /// @cond INTERNAL
     link(pn_link_t* l) : object<pn_link_t>(l) {}
     /// @endcond
@@ -116,11 +115,13 @@ PN_CPP_CLASS_EXTERN link : public object<pn_link_t> , public endpoint {
     /// Session that owns this link.
     PN_CPP_EXTERN class session session() const;
 
-  private:
+    ///@cond INTERNAL
+  protected:
     /// Initiate the AMQP attach frame.  The operation is not complete till
     /// handler::on_link_open.
     void attach();
 
+  private:
     // Used by sender/receiver options
     void handler(proton_handler &);
     void detach_handler();
@@ -131,25 +132,18 @@ PN_CPP_CLASS_EXTERN link : public object<pn_link_t> , public endpoint {
     bool advance();
     link_context &context();
 
-    ///@cond INTERNAL
     /// XXX local versus remote, mutability
     /// XXX - local_sender_settle_mode and local_receiver_settle_mode
-    PN_CPP_EXTERN sender_options::sender_settle_mode sender_settle_mode();
-    PN_CPP_EXTERN receiver_options::receiver_settle_mode receiver_settle_mode();
-    PN_CPP_EXTERN sender_options::sender_settle_mode remote_sender_settle_mode();
-    PN_CPP_EXTERN receiver_options::receiver_settle_mode remote_receiver_settle_mode();
+    sender_options::sender_settle_mode sender_settle_mode();
+    receiver_options::receiver_settle_mode receiver_settle_mode();
+    sender_options::sender_settle_mode remote_sender_settle_mode();
+    receiver_options::receiver_settle_mode remote_receiver_settle_mode();
+
+    friend class factory<link>;
+    friend class proton::message;
+    friend class proton::receiver_options;
+    friend class proton::sender_options;
     ///@endcond
-
-  friend class proton::delivery;
-  friend class proton::sender;
-  friend class proton::receiver;
-  friend class proton::sender_options;
-  friend class proton::receiver_options;
-  friend class proton::sender_iterator;
-  friend class proton::receiver_iterator;
-  friend class proton::message;
-  friend class proton::proton_event;
-  friend class proton::messaging_adapter;
 };
 
 }}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/object.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp
index a428c28..dcbe086 100644
--- a/proton-c/bindings/cpp/include/proton/object.hpp
+++ b/proton-c/bindings/cpp/include/proton/object.hpp
@@ -85,6 +85,9 @@ template <class T> class object : private comparable<object<T> > {
     friend bool operator<(const object& a, const object& b) { return a.object_ < b.object_; }
 };
 
+/// Factory class used internally to make wrappers
+template <class T> class factory;
+
 }}
 
 /// @endcond

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/receiver.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/receiver.hpp b/proton-c/bindings/cpp/include/proton/receiver.hpp
index d0eb6ec..d56f7fd 100644
--- a/proton-c/bindings/cpp/include/proton/receiver.hpp
+++ b/proton-c/bindings/cpp/include/proton/receiver.hpp
@@ -36,11 +36,11 @@ namespace proton {
 class
 PN_CPP_CLASS_EXTERN receiver : public internal::link {
     /// @cond INTERNAL
-    receiver(pn_link_t* r) : internal::link(r) {}
+    receiver(pn_link_t* r);
     /// @endcond
 
   public:
-    receiver() : internal::link(0) {}
+    receiver() {}
 
     /// Locally open the receiver.  The operation is not complete till
     /// handler::on_receiver_open.
@@ -51,15 +51,13 @@ PN_CPP_CLASS_EXTERN receiver : public internal::link {
 
     /// Get the target node.
     PN_CPP_EXTERN class target target() const;
-  /// @cond INTERNAL
-  friend class internal::link;
-  friend class delivery;
-  friend class session;
-  friend class messaging_adapter;
+
+    /// @cond INTERNAL
+  friend class internal::factory<receiver>;
   friend class receiver_iterator;
   friend class source;
   friend class target;
-  /// @endcond
+    /// @endcond
 };
 
 class receiver_iterator : public internal::iter_base<receiver, receiver_iterator> {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp b/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp
index 0d30d4c..802863c 100644
--- a/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp
+++ b/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp
@@ -58,8 +58,6 @@ class reconnect_timer
     int32_t retries_;
     duration next_delay_;
     timestamp timeout_deadline_;
-
-    friend class connector;
 };
 
 /// @endcond

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/sasl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/sasl.hpp b/proton-c/bindings/cpp/include/proton/sasl.hpp
index 6e93001..e9a7731 100644
--- a/proton-c/bindings/cpp/include/proton/sasl.hpp
+++ b/proton-c/bindings/cpp/include/proton/sasl.hpp
@@ -24,6 +24,8 @@
 
 #include "proton/export.hpp"
 #include "proton/config.hpp"
+#include "proton/object.hpp"
+
 #include "proton/sasl.h"
 #include <string>
 
@@ -73,8 +75,8 @@ class sasl {
 
     pn_sasl_t* const object_;
 
+    friend class internal::factory<sasl>;
     friend class connection_options;
-    friend class transport;
     /// @endcond
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/sender.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/sender.hpp b/proton-c/bindings/cpp/include/proton/sender.hpp
index 43c0747..8beb148 100644
--- a/proton-c/bindings/cpp/include/proton/sender.hpp
+++ b/proton-c/bindings/cpp/include/proton/sender.hpp
@@ -39,11 +39,11 @@ class
 PN_CPP_CLASS_EXTERN sender : public internal::link
 {
     /// @cond INTERNAL
-    sender(pn_link_t* s) : internal::link(s) {}
+    sender(pn_link_t* s);
     /// @endcond
 
   public:
-    sender() : internal::link(0) {}
+    sender() {}
 
     /// Locally open the sender.  The operation is not complete till
     /// handler::on_sender_open.
@@ -59,10 +59,7 @@ PN_CPP_CLASS_EXTERN sender : public internal::link
     PN_CPP_EXTERN class target target() const;
 
   /// @cond INTERNAL
-  friend class internal::link;
-  friend class tracker;
-  friend class session;
-  friend class messaging_adapter;
+  friend class internal::factory<sender>;
   friend class sender_iterator;
   friend class source;
   friend class target;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/ssl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp
index d66d5c4..8b182fb 100644
--- a/proton-c/bindings/cpp/include/proton/ssl.hpp
+++ b/proton-c/bindings/cpp/include/proton/ssl.hpp
@@ -23,6 +23,7 @@
  */
 
 #include "proton/export.hpp"
+#include "proton/object.hpp"
 
 #include "proton/ssl.h"
 #include <string>
@@ -88,7 +89,7 @@ class ssl {
   private:
     pn_ssl_t* object_;
 
-    friend class transport;
+    friend class internal::factory<ssl>;
     /// @endcond
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/terminus.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/terminus.hpp b/proton-c/bindings/cpp/include/proton/terminus.hpp
index e3dd711..17abf5e 100644
--- a/proton-c/bindings/cpp/include/proton/terminus.hpp
+++ b/proton-c/bindings/cpp/include/proton/terminus.hpp
@@ -34,10 +34,7 @@ namespace proton {
 
 class source;
 class target;
-class receiver_options;
 class source_options;
-class target_options;
-
 
 namespace internal {
 
@@ -97,13 +94,12 @@ class terminus {
     value properties_, filter_;
     pn_link_t* parent_;
 
-    friend class link;
+
+    friend class factory<terminus>;
     friend class noderef;
     friend class proton::source;
     friend class proton::target;
-    friend class proton::receiver_options;
     friend class proton::source_options;
-    friend class proton::target_options;
     /// @endcond
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/tracker.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/tracker.hpp b/proton-c/bindings/cpp/include/proton/tracker.hpp
index 9f7b691..e35d1f8 100644
--- a/proton-c/bindings/cpp/include/proton/tracker.hpp
+++ b/proton-c/bindings/cpp/include/proton/tracker.hpp
@@ -23,11 +23,9 @@
  */
 
 #include "proton/export.hpp"
-#include "proton/object.hpp"
 #include "proton/transfer.hpp"
 
-#include "proton/delivery.h"
-#include "proton/disposition.h"
+struct pn_delivery_t;
 
 namespace proton {
 
@@ -36,15 +34,16 @@ namespace proton {
 /// particular message may correspond to multiple deliveries.
 class tracker : public transfer {
     /// @cond INTERNAL
-    tracker(pn_delivery_t* d) : transfer(d) {}
+    tracker(pn_delivery_t* d);
     /// @endcond
 
   public:
+    tracker() {}
+
     // Return the sender for this tracker
     PN_CPP_EXTERN class sender sender() const;
 
-  friend class messaging_adapter;
-  friend class sender;
+  friend class internal::factory<tracker>;
 };
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/transfer.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/transfer.hpp b/proton-c/bindings/cpp/include/proton/transfer.hpp
index d3be57b..67c3a42 100644
--- a/proton-c/bindings/cpp/include/proton/transfer.hpp
+++ b/proton-c/bindings/cpp/include/proton/transfer.hpp
@@ -34,7 +34,6 @@ namespace proton {
 /// proton::link.  A delivery attempt can fail. As a result, a
 /// particular message may correspond to multiple deliveries.
 class transfer : public internal::object<pn_delivery_t> {
-  protected:
     /// @cond INTERNAL
     transfer(pn_delivery_t* d) : internal::object<pn_delivery_t>(d) {}
     /// @endcond
@@ -87,6 +86,7 @@ class transfer : public internal::object<pn_delivery_t> {
     /// called.
     bool updated() const;
 
+  friend class internal::factory<transfer>;
   friend class messaging_adapter;
     /// @endcond
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/include/proton/transport.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/transport.hpp b/proton-c/bindings/cpp/include/proton/transport.hpp
index b29f480..6b94696 100644
--- a/proton-c/bindings/cpp/include/proton/transport.hpp
+++ b/proton-c/bindings/cpp/include/proton/transport.hpp
@@ -71,10 +71,10 @@ class transport : public internal::object<pn_transport_t> {
     /// @endcond
 
     /// @cond INTERNAL
+    friend class internal::factory<transport>;
     friend class connection;
     friend class connection_options;
     friend class connector;
-    friend class proton_event;
     friend class io::connection_engine;
     friend class messaging_adapter;
     /// @endcond

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/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 e705fc6..5fb4268 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -29,9 +29,10 @@
 #include "proton/error.hpp"
 #include "connector.hpp"
 
-#include "msg.hpp"
-#include "contexts.hpp"
 #include "container_impl.hpp"
+#include "contexts.hpp"
+#include "msg.hpp"
+#include "proton_bits.hpp"
 
 #include "proton/connection.h"
 #include "proton/session.h"
@@ -105,7 +106,7 @@ receiver connection::open_receiver(const std::string &addr, const receiver_optio
 }
 
 error_condition connection::error() const {
-    return pn_connection_remote_condition(pn_object());
+    return make_wrapper(pn_connection_remote_condition(pn_object()));
 }
 
 void connection::user(const std::string &name) { pn_connection_set_user(pn_object(), name.c_str()); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/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 89cfd89..ce7b0d5 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -38,6 +38,7 @@
 #include "contexts.hpp"
 #include "messaging_adapter.hpp"
 #include "msg.hpp"
+#include "proton_bits.hpp"
 #include "proton_event.hpp"
 
 #include "proton/connection.h"
@@ -100,7 +101,7 @@ class override_handler : public proton_handler
             }
             else if (!override && type == proton_event::CONNECTION_INIT) {
                 // Newly accepted connection from lister socket
-                connection c(conn);
+                connection c(make_wrapper(conn));
                 container_impl_.configure_server_connection(c);
             }
         }
@@ -193,7 +194,7 @@ acceptor container_impl::listen(const proton::url& url, const connection_options
     listener_context& lc(listener_context::get(acptr));
     lc.connection_options = opts;
     lc.ssl = url.scheme() == url::AMQPS;
-    return acceptor(acptr);
+    return make_wrapper(acptr);
 }
 
 task container_impl::schedule(int delay, proton_handler *h) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/delivery.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/delivery.cpp b/proton-c/bindings/cpp/src/delivery.cpp
index e3c0054..b60a0b3 100644
--- a/proton-c/bindings/cpp/src/delivery.cpp
+++ b/proton-c/bindings/cpp/src/delivery.cpp
@@ -23,9 +23,12 @@
 
 #include "proton/receiver.hpp"
 
+#include "proton_bits.hpp"
+
 namespace proton {
 
-receiver delivery::receiver() const { return pn_delivery_link(pn_object()); }
+delivery::delivery(pn_delivery_t* d): transfer(make_wrapper(d)) {}
+receiver delivery::receiver() const { return make_wrapper<class receiver>(pn_delivery_link(pn_object())); }
 
 bool delivery::partial()  const { return pn_delivery_partial(pn_object()); }
 bool delivery::readable() const { return pn_delivery_readable(pn_object()); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/endpoint.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/endpoint.cpp b/proton-c/bindings/cpp/src/endpoint.cpp
index 1834201..d2dce06 100644
--- a/proton-c/bindings/cpp/src/endpoint.cpp
+++ b/proton-c/bindings/cpp/src/endpoint.cpp
@@ -58,7 +58,6 @@ void session::close(const error_condition& condition) {
 }
 
 namespace internal {
-
 bool link::uninitialized() const { return ::uninitialized(pn_link_state(pn_object())); }
 bool link::active() const { return ::active(pn_link_state(pn_object())); }
 bool link::closed() const { return ::closed(pn_link_state(pn_object())); }
@@ -67,7 +66,6 @@ void link::close(const error_condition& condition) {
     set_error_condition(condition, pn_link_condition(pn_object()));
     close();
 }
-
 }
 
 endpoint::~endpoint() {}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/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 b1e8e60..68afef7 100644
--- a/proton-c/bindings/cpp/src/link.cpp
+++ b/proton-c/bindings/cpp/src/link.cpp
@@ -25,14 +25,15 @@
 #include "proton/error.hpp"
 #include "proton/connection.hpp"
 
-#include "msg.hpp"
-#include "container_impl.hpp"
-#include "contexts.hpp"
-
 #include "proton/connection.h"
 #include "proton/session.h"
 #include "proton/link.h"
 
+#include "container_impl.hpp"
+#include "contexts.hpp"
+#include "msg.hpp"
+#include "proton_bits.hpp"
+
 namespace proton {
 namespace internal {
 
@@ -63,7 +64,7 @@ container& link::container() const {
 }
 
 class connection link::connection() const {
-    return pn_session_connection(pn_link_session(pn_object()));
+    return make_wrapper(pn_session_connection(pn_link_session(pn_object())));
 }
 
 class session link::session() const {
@@ -82,7 +83,7 @@ void link::detach_handler() {
 }
 
 error_condition link::error() const {
-    return pn_link_remote_condition(pn_object());
+    return make_wrapper(pn_link_remote_condition(pn_object()));
 }
 
 ssize_t link::recv(char* buffer, size_t size) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/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 3c494e5..ac362bc 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -27,9 +27,10 @@
 #include "proton/tracker.hpp"
 #include "proton/transport.hpp"
 
-#include "contexts.hpp"
 #include "container_impl.hpp"
+#include "contexts.hpp"
 #include "msg.hpp"
+#include "proton_bits.hpp"
 #include "proton_event.hpp"
 
 #include "proton/connection.h"
@@ -67,7 +68,7 @@ void messaging_adapter::on_reactor_init(proton_event &pe) {
 void messaging_adapter::on_link_flow(proton_event &pe) {
     pn_event_t *pne = pe.pn_event();
     pn_link_t *lnk = pn_event_link(pne);
-    sender s(lnk);
+    sender s(make_wrapper<sender>(lnk));
     int state = pn_link_state(lnk);
     if (lnk && pn_link_is_sender(lnk) && pn_link_credit(lnk) > 0 &&
         (state&PN_LOCAL_ACTIVE) && (state&PN_REMOTE_ACTIVE))
@@ -85,7 +86,7 @@ void messaging_adapter::on_delivery(proton_event &pe) {
     link_context& lctx = link_context::get(lnk);
 
     if (pn_link_is_receiver(lnk)) {
-        delivery d(dlv);
+        delivery d(make_wrapper<delivery>(dlv));
         if (!d.partial() && d.readable()) {
             // generate on_message
             pn_connection_t *pnc = pn_session_connection(pn_link_session(lnk));
@@ -109,7 +110,7 @@ void messaging_adapter::on_delivery(proton_event &pe) {
         }
         credit_topup(lnk);
     } else {
-        tracker t(dlv);
+        tracker t(make_wrapper<tracker>(dlv));
         // sender
         if (t.updated()) {
             uint64_t rstate = t.state();
@@ -148,13 +149,13 @@ 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_link_is_receiver(lnk)) {
-        receiver r(lnk);
+        receiver r(make_wrapper<receiver>(lnk));
         if (pn_condition_is_set(pn_link_remote_condition(lnk))) {
             delegate_.on_receiver_error(r);
         }
         delegate_.on_receiver_close(r);
     } else {
-        sender s(lnk);
+        sender s(make_wrapper<sender>(lnk));
         if (pn_condition_is_set(pn_link_remote_condition(lnk))) {
             delegate_.on_sender_error(s);
         }
@@ -176,21 +177,21 @@ void messaging_adapter::on_session_remote_close(proton_event &pe) {
 
 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);
-    class connection c(connection);
-    if (pn_condition_is_set(pn_connection_remote_condition(connection))) {
+    pn_connection_t *conn = pn_event_connection(cevent);
+    connection c(make_wrapper(conn));
+    if (pn_condition_is_set(pn_connection_remote_condition(conn))) {
         delegate_.on_connection_error(c);
     }
     delegate_.on_connection_close(c);
-    pn_connection_close(connection);
+    pn_connection_close(conn);
 }
 
 void messaging_adapter::on_connection_remote_open(proton_event &pe) {
-    pn_connection_t *connection = pn_event_connection(pe.pn_event());
-    class connection c(connection);
+    pn_connection_t *conn = pn_event_connection(pe.pn_event());
+    class connection c(make_wrapper(conn));
     delegate_.on_connection_open(c);
-    if (!is_local_open(pn_connection_state(connection)) && is_local_unititialised(pn_connection_state(connection))) {
-        pn_connection_open(connection);
+    if (!is_local_open(pn_connection_state(conn)) && is_local_unititialised(pn_connection_state(conn))) {
+        pn_connection_open(conn);
     }
 }
 
@@ -208,24 +209,28 @@ void messaging_adapter::on_link_local_open(proton_event &pe) {
 }
 
 void messaging_adapter::on_link_remote_open(proton_event &pe) {
-    receiver r;
-    sender s;
     pn_link_t *lnk = pn_event_link(pe.pn_event());
+    container *c = pe.container();
     if (pn_link_is_receiver(lnk)) {
-      r = lnk;
+      receiver r(make_wrapper<receiver>(lnk));
       delegate_.on_receiver_open(r);
+      if (is_local_unititialised(pn_link_state(lnk))) {
+        if (c) {
+          r.open(c->impl_->receiver_options_);
+        } else {
+          pn_link_open(lnk);    // No default for engine
+        }
+      }
     } else {
-      s = lnk;
+      sender s(make_wrapper<sender>(lnk));
       delegate_.on_sender_open(s);
-    }
-    if (!is_local_open(pn_link_state(lnk)) && is_local_unititialised(pn_link_state(lnk))) {
-        if (pe.container())
-            if (!!s)
-                s.open(pe.container()->impl_->sender_options_);
-            else
-                r.open(pe.container()->impl_->receiver_options_);
-        else
-            pn_link_open(lnk);    // No default for engine
+      if (is_local_unititialised(pn_link_state(lnk))) {
+        if (c) {
+          s.open(c->impl_->sender_options_);
+        } else {
+          pn_link_open(lnk);    // No default for engine
+        }
+      }
     }
     credit_topup(lnk);
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/proton_bits.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.cpp b/proton-c/bindings/cpp/src/proton_bits.cpp
index af032c9..3b459e2 100644
--- a/proton-c/bindings/cpp/src/proton_bits.cpp
+++ b/proton-c/bindings/cpp/src/proton_bits.cpp
@@ -19,6 +19,8 @@
 
 #include "proton_bits.hpp"
 
+#include "proton/error_condition.hpp"
+
 #include <string>
 #include <ostream>
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/proton_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.hpp b/proton-c/bindings/cpp/src/proton_bits.hpp
index a3f2039..f84c978 100644
--- a/proton-c/bindings/cpp/src/proton_bits.hpp
+++ b/proton-c/bindings/cpp/src/proton_bits.hpp
@@ -21,17 +21,44 @@
 
 #include <string>
 #include <iosfwd>
-#include <proton/error_condition.hpp>
-#include <proton/error.h>
 
 /**@file
  *
  * Assorted internal proton utilities.
  */
 
+struct pn_error_t;
+
+struct pn_transport_t;
+struct pn_sasl_t;
+struct pn_ssl_t;
+struct pn_connection_t;
+struct pn_session_t;
+struct pn_link_t;
+struct pn_delivery_t;
+struct pn_condition_t;
+struct pn_acceptor_t;
+struct pn_terminus_t;
+
 namespace proton {
 
+namespace internal {
+class link;
+class terminus;
+}
+
+class transport;
+class sasl;
+class ssl;
+class connection;
+class session;
+class sender;
+class receiver;
+class transfer;
+class tracker;
+class delivery;
 class error_condition;
+class acceptor;
 
 std::string error_str(long code);
 
@@ -49,6 +76,52 @@ void set_error_condition(const error_condition&, pn_condition_t*);
 /// Convert a const char* to std::string, convert NULL to the empty string.
 inline std::string str(const char* s) { return s ? s : std::string(); }
 
+namespace internal {
+
+// These traits relate the wrapped and wrapper classes for the templated factories below
+template <class T> struct wrapped {};
+template <> struct wrapped<transport> { typedef pn_transport_t type; };
+template <> struct wrapped<sasl> { typedef pn_sasl_t type; };
+template <> struct wrapped<ssl> { typedef pn_ssl_t type; };
+template <> struct wrapped<connection> { typedef pn_connection_t type; };
+template <> struct wrapped<session> { typedef pn_session_t type; };
+template <> struct wrapped<link> { typedef pn_link_t type; };
+template <> struct wrapped<sender> { typedef pn_link_t type; };
+template <> struct wrapped<receiver> { typedef pn_link_t type; };
+template <> struct wrapped<transfer> { typedef pn_delivery_t type; };
+template <> struct wrapped<tracker> { typedef pn_delivery_t type; };
+template <> struct wrapped<delivery> { typedef pn_delivery_t type; };
+template <> struct wrapped<error_condition> { typedef pn_condition_t type; };
+template <> struct wrapped<acceptor> { typedef pn_acceptor_t type; };
+template <> struct wrapped<terminus> { typedef pn_terminus_t type; };
+
+template <class T> struct wrapper {};
+template <> struct wrapper<pn_transport_t> { typedef transport type; };
+template <> struct wrapper<pn_sasl_t> { typedef sasl type; };
+template <> struct wrapper<pn_ssl_t> { typedef ssl type; };
+template <> struct wrapper<pn_connection_t> { typedef connection type; };
+template <> struct wrapper<pn_session_t> { typedef session type; };
+template <> struct wrapper<pn_link_t> { typedef link type; };
+template <> struct wrapper<pn_delivery_t> { typedef transfer type; };
+template <> struct wrapper<pn_condition_t> { typedef error_condition type; };
+template <> struct wrapper<pn_acceptor_t> { typedef acceptor type; };
+template <> struct wrapper<pn_terminus_t> { typedef terminus type; };
+
+  // Factory for wrapper types
+template <class T>
+class factory {
+public:
+    static T make(typename wrapped<T>::type* t) { return t; }
+};
+
+}
+
+template <class T>
+typename internal::wrapper<T>::type make_wrapper(T* t) { return internal::factory<typename internal::wrapper<T>::type>::make(t); }
+
+template <class U>
+U make_wrapper(typename internal::wrapped<U>::type* t) { return internal::factory<U>::make(t); }
+
 }
 
 #endif // PROTON_BITS_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/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 40bd93d..9a1ffea 100644
--- a/proton-c/bindings/cpp/src/proton_event.cpp
+++ b/proton-c/bindings/cpp/src/proton_event.cpp
@@ -25,6 +25,7 @@
 
 #include "msg.hpp"
 #include "proton_handler.hpp"
+#include "types_internal.hpp"
 
 namespace proton {
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/reactor.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reactor.cpp b/proton-c/bindings/cpp/src/reactor.cpp
index 9ac3dcc..9507d2b 100644
--- a/proton-c/bindings/cpp/src/reactor.cpp
+++ b/proton-c/bindings/cpp/src/reactor.cpp
@@ -25,6 +25,7 @@
 #include "proton/url.hpp"
 
 #include "contexts.hpp"
+#include "proton_bits.hpp"
 
 #include <proton/reactor.h>
 
@@ -45,7 +46,7 @@ timestamp reactor::mark() { return timestamp(pn_reactor_mark(pn_object())); }
 timestamp reactor::now() { return timestamp(pn_reactor_now(pn_object())); }
 
 acceptor reactor::listen(const url& url){
-    return pn_reactor_acceptor(pn_object(), url.host().c_str(), url.port().c_str(), 0);
+    return make_wrapper(pn_reactor_acceptor(pn_object(), url.host().c_str(), url.port().c_str(), 0));
 }
 
 task reactor::schedule(int delay, pn_handler_t* handler) {
@@ -53,7 +54,7 @@ task reactor::schedule(int delay, pn_handler_t* handler) {
 }
 
 connection reactor::connection(pn_handler_t* h) const {
-    return pn_reactor_connection(pn_object(), h);
+    return make_wrapper(pn_reactor_connection(pn_object(), h));
 }
 
 pn_io_t* reactor::pn_io() const {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/receiver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/receiver.cpp b/proton-c/bindings/cpp/src/receiver.cpp
index 2e7643c..4760c71 100644
--- a/proton-c/bindings/cpp/src/receiver.cpp
+++ b/proton-c/bindings/cpp/src/receiver.cpp
@@ -21,7 +21,9 @@
 #include "proton/link.hpp"
 #include "proton/receiver.hpp"
 #include "proton/error.hpp"
+
 #include "msg.hpp"
+#include "proton_bits.hpp"
 
 #include "proton/connection.h"
 #include "proton/session.h"
@@ -29,6 +31,8 @@
 
 namespace proton {
 
+receiver::receiver(pn_link_t* r): link(make_wrapper(r)) {}
+
 void receiver::open(const receiver_options &opts) {
     opts.apply(*this);
     attach();
@@ -56,5 +60,4 @@ receiver_iterator receiver_iterator::operator++() {
     return *this;
 }
 
-
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/receiver_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/receiver_options.cpp b/proton-c/bindings/cpp/src/receiver_options.cpp
index 3e737fd..43eb998 100644
--- a/proton-c/bindings/cpp/src/receiver_options.cpp
+++ b/proton-c/bindings/cpp/src/receiver_options.cpp
@@ -27,12 +27,13 @@
 #include "proton/source_options.hpp"
 #include "proton/target_options.hpp"
 
-#include "msg.hpp"
-#include "messaging_adapter.hpp"
-#include "contexts.hpp"
-
 #include "proton/link.h"
 
+#include "contexts.hpp"
+#include "messaging_adapter.hpp"
+#include "msg.hpp"
+#include "proton_bits.hpp"
+
 namespace proton {
 
 template <class T> struct option {
@@ -82,7 +83,7 @@ class receiver_options::impl {
             if (auto_accept.set) r.context().auto_accept = auto_accept.value;
             if (credit_window.set) r.context().credit_window = credit_window.value;
 
-            internal::terminus local_src = pn_link_source(r.pn_object());
+            internal::terminus local_src(make_wrapper(pn_link_source(r.pn_object())));
             if (source.set) {
                 proton::source local_s(pn_link_source(r.pn_object()));
                 source.value.apply(local_s);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/sender.cpp b/proton-c/bindings/cpp/src/sender.cpp
index 7ad88cd..fc33524 100644
--- a/proton-c/bindings/cpp/src/sender.cpp
+++ b/proton-c/bindings/cpp/src/sender.cpp
@@ -27,8 +27,12 @@
 #include "proton/link.h"
 #include "proton/types.h"
 
+#include "proton_bits.hpp"
+
 namespace proton {
 
+sender::sender(pn_link_t *l): link(make_wrapper(l)) {}
+
 void sender::open(const sender_options &opts) {
     opts.apply(*this);
     attach();
@@ -57,7 +61,7 @@ tracker sender::send(const message &message) {
     pn_link_advance(pn_object());
     if (pn_link_snd_settle_mode(pn_object()) == PN_SND_SETTLED)
         pn_delivery_settle(dlv);
-    return dlv;
+    return make_wrapper<tracker>(dlv);
 }
 
 sender_iterator sender_iterator::operator++() {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/session.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/session.cpp b/proton-c/bindings/cpp/src/session.cpp
index 42384dd..87349c9 100644
--- a/proton-c/bindings/cpp/src/session.cpp
+++ b/proton-c/bindings/cpp/src/session.cpp
@@ -27,6 +27,7 @@
 
 #include "contexts.hpp"
 #include "container_impl.hpp"
+#include "proton_bits.hpp"
 
 #include <string>
 
@@ -46,7 +47,7 @@ container& session::container() const {
 }
 
 connection session::connection() const {
-    return pn_session_connection(pn_object());
+    return make_wrapper(pn_session_connection(pn_object()));
 }
 
 namespace {
@@ -58,7 +59,7 @@ std::string next_link_name(const connection& c) {
 sender session::open_sender(const std::string &addr, const sender_options &so) {
     pn_link_t *lnk = pn_sender(pn_object(), next_link_name(connection()).c_str());
     pn_terminus_set_address(pn_link_target(lnk), addr.c_str());
-    sender snd(lnk);
+    sender snd(make_wrapper<sender>(lnk));
     snd.open(so);
     return snd;
 }
@@ -67,13 +68,13 @@ receiver session::open_receiver(const std::string &addr, const receiver_options
 {
     pn_link_t *lnk = pn_receiver(pn_object(), next_link_name(connection()).c_str());
     pn_terminus_set_address(pn_link_source(lnk), addr.c_str());
-    receiver rcv(lnk);
+    receiver rcv(make_wrapper<receiver>(lnk));
     rcv.open(ro);
     return rcv;
 }
 
 error_condition session::error() const {
-    return pn_session_remote_condition(pn_object());
+    return make_wrapper(pn_session_remote_condition(pn_object()));
 }
 
 sender_range session::senders() const {
@@ -83,7 +84,7 @@ sender_range session::senders() const {
             break;
         lnk = pn_link_next(lnk, 0);
     }
-    return sender_range(sender_iterator(lnk, pn_object()));
+    return sender_range(sender_iterator(make_wrapper<sender>(lnk), pn_object()));
 }
 
 receiver_range session::receivers() const {
@@ -93,7 +94,7 @@ receiver_range session::receivers() const {
             break;
         lnk = pn_link_next(lnk, 0);
     }
-    return receiver_range(receiver_iterator(lnk, pn_object()));
+    return receiver_range(receiver_iterator(make_wrapper<receiver>(lnk), pn_object()));
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/source.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/source.cpp b/proton-c/bindings/cpp/src/source.cpp
index 95c76da..c955e14 100644
--- a/proton-c/bindings/cpp/src/source.cpp
+++ b/proton-c/bindings/cpp/src/source.cpp
@@ -25,14 +25,16 @@
 #include "proton/sender.hpp"
 #include "proton/receiver.hpp"
 
+#include "proton_bits.hpp"
+
 namespace proton {
 
 // Set parent_ non-null when the local terminus is authoritative and may need to be looked up.
-source::source(pn_terminus_t *t) : terminus(t) {}
+source::source(pn_terminus_t *t) : terminus(make_wrapper(t)) {}
 
-source::source(const sender& snd) : terminus(pn_link_remote_source(snd.pn_object())) { parent_ = snd.pn_object(); }
+source::source(const sender& snd) : terminus(make_wrapper(pn_link_remote_source(snd.pn_object()))) { parent_ = snd.pn_object(); }
 
-source::source(const receiver& rcv) : terminus(pn_link_remote_source(rcv.pn_object())) {}
+source::source(const receiver& rcv) : terminus(make_wrapper(pn_link_remote_source(rcv.pn_object()))) {}
 
 std::string source::address() const {
     pn_terminus_t *authoritative = object_;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/target.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/target.cpp b/proton-c/bindings/cpp/src/target.cpp
index ee83670..2f48bf9 100644
--- a/proton-c/bindings/cpp/src/target.cpp
+++ b/proton-c/bindings/cpp/src/target.cpp
@@ -25,12 +25,14 @@
 #include "proton/sender.hpp"
 #include "proton/receiver.hpp"
 
+#include "proton_bits.hpp"
+
 namespace proton {
 
 // Set parent_ non-null when the local terminus is authoritative and may need to be looked up.
-target::target(pn_terminus_t *t) : terminus(t) {}
-target::target(const sender& snd) : terminus(pn_link_remote_target(snd.pn_object())) {}
-target::target(const receiver& rcv) : terminus(pn_link_remote_target(rcv.pn_object())) { parent_ = rcv.pn_object(); }
+target::target(pn_terminus_t *t) : terminus(make_wrapper(t)) {}
+target::target(const sender& snd) : terminus(make_wrapper(pn_link_remote_target(snd.pn_object()))) {}
+target::target(const receiver& rcv) : terminus(make_wrapper(pn_link_remote_target(rcv.pn_object()))) { parent_ = rcv.pn_object(); }
 
 std::string target::address() const {
     pn_terminus_t *authoritative = object_;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/tracker.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/tracker.cpp b/proton-c/bindings/cpp/src/tracker.cpp
index fd9b007..1d309a5 100644
--- a/proton-c/bindings/cpp/src/tracker.cpp
+++ b/proton-c/bindings/cpp/src/tracker.cpp
@@ -23,7 +23,10 @@
 
 #include "proton/sender.hpp"
 
+#include "proton_bits.hpp"
+
 namespace proton {
 
-sender tracker::sender() const { return pn_delivery_link(pn_object()); }
+tracker::tracker(pn_delivery_t *d): transfer(make_wrapper(d)) {}
+sender tracker::sender() const { return make_wrapper<class sender>(pn_delivery_link(pn_object())); }
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/transfer.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/transfer.cpp b/proton-c/bindings/cpp/src/transfer.cpp
index 9330ef5..3559558 100644
--- a/proton-c/bindings/cpp/src/transfer.cpp
+++ b/proton-c/bindings/cpp/src/transfer.cpp
@@ -29,10 +29,12 @@
 #include "proton/link.h"
 #include "proton/session.h"
 
+#include "proton_bits.hpp"
+
 namespace proton {
 
-session transfer::session() const { return pn_link_session(pn_delivery_link(pn_object())); }
-connection transfer::connection() const { return pn_session_connection(pn_link_session(pn_delivery_link(pn_object()))); }
+session transfer::session() const { return make_wrapper(pn_link_session(pn_delivery_link(pn_object()))); }
+connection transfer::connection() const { return make_wrapper(pn_session_connection(pn_link_session(pn_delivery_link(pn_object())))); }
 container& transfer::container() const { return connection().container(); }
 
 bool transfer::settled() const { return pn_delivery_settled(pn_object()); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/transport.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/transport.cpp b/proton-c/bindings/cpp/src/transport.cpp
index a788816..5681ce4 100644
--- a/proton-c/bindings/cpp/src/transport.cpp
+++ b/proton-c/bindings/cpp/src/transport.cpp
@@ -29,24 +29,25 @@
 #include "proton/error.h"
 
 #include "msg.hpp"
+#include "proton_bits.hpp"
 
 
 namespace proton {
 
 connection transport::connection() const {
-    return pn_transport_connection(pn_object());
+    return make_wrapper(pn_transport_connection(pn_object()));
 }
 
 class ssl transport::ssl() const {
-    return proton::ssl(pn_ssl(pn_object()));
+    return make_wrapper(pn_ssl(pn_object()));
 }
 
 class sasl transport::sasl() const {
-    return pn_sasl(pn_object());
+    return make_wrapper(pn_sasl(pn_object()));
 }
 
 error_condition transport::error() const {
-    return proton::error_condition(pn_transport_condition(pn_object()));
+    return make_wrapper(pn_transport_condition(pn_object()));
 }
 
 void transport::unbind() {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c1194c0/proton-c/bindings/cpp/src/types_internal.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types_internal.hpp b/proton-c/bindings/cpp/src/types_internal.hpp
index 11d2e39..0391d9b 100644
--- a/proton-c/bindings/cpp/src/types_internal.hpp
+++ b/proton-c/bindings/cpp/src/types_internal.hpp
@@ -1,5 +1,5 @@
-#ifndef CODEC_HPP
-#define CODEC_HPP
+#ifndef TYPES_INTERNAL_HPP
+#define TYPES_INTERNAL_HPP
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -69,5 +69,6 @@ struct ios_guard {
 // Convert a char (signed or unsigned) into an unsigned 1 byte integer that will ostream 
 // as a numeric byte value, not a character and will not get sign-extended.
 inline unsigned int printable_byte(uint8_t byte) { return byte; }
+
 }
-#endif // CODEC_HPP
+#endif // TYPES_INTERNAL_HPP


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


Mime
View raw message