qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [34/50] [abbrv] qpid-proton git commit: NO-JIRA: c++: Minor renaming for consistency and conciseness.
Date Fri, 23 Oct 2015 14:36:36 GMT
NO-JIRA: c++: Minor renaming for consistency and conciseness.

- Replace redundant container::container_id() with container::id()
- Replace bool is_sender()/sender& sender() with sender* sender()
  Consistent with casting, since these functions are cast-like.
- Drop "is_" from is_dynamic, is_described for consistency with other accessors.
- Rename create_(sender|receiver|sessin) to open_... for functions that open the endpoint.
- Renamed create_(sender|receiver)_link to create_... for functions that create but do not
open.


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

Branch: refs/heads/go1
Commit: 4e9afbb088be900b1ad08ce1ef8974e833f5aa2f
Parents: 9106cb0
Author: Alan Conway <aconway@redhat.com>
Authored: Mon Oct 19 15:50:16 2015 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Mon Oct 19 17:18:31 2015 -0400

----------------------------------------------------------------------
 examples/cpp/broker.cpp                         | 20 +++++++++-----------
 examples/cpp/client.cpp                         |  4 ++--
 examples/cpp/helloworld.cpp                     |  4 ++--
 examples/cpp/helloworld_direct.cpp              |  2 +-
 examples/cpp/server.cpp                         |  4 ++--
 examples/cpp/server_direct.cpp                  |  4 ++--
 examples/cpp/simple_recv.cpp                    |  2 +-
 examples/cpp/simple_send.cpp                    |  2 +-
 .../bindings/cpp/include/proton/connection.hpp  |  6 +++---
 .../bindings/cpp/include/proton/container.hpp   |  6 +++---
 proton-c/bindings/cpp/include/proton/link.hpp   | 12 ++++--------
 .../bindings/cpp/include/proton/reactor.hpp     |  2 +-
 .../bindings/cpp/include/proton/session.hpp     |  8 ++++----
 .../bindings/cpp/include/proton/terminus.hpp    |  2 +-
 proton-c/bindings/cpp/include/proton/types.hpp  |  2 +-
 proton-c/bindings/cpp/src/blocking_receiver.cpp |  4 ++--
 proton-c/bindings/cpp/src/blocking_sender.cpp   |  4 ++--
 proton-c/bindings/cpp/src/connection.cpp        | 12 ++++++------
 proton-c/bindings/cpp/src/connector.cpp         |  2 +-
 proton-c/bindings/cpp/src/container.cpp         | 10 +++++-----
 proton-c/bindings/cpp/src/container_impl.cpp    | 12 ++++++------
 proton-c/bindings/cpp/src/container_impl.hpp    | 10 +++++-----
 proton-c/bindings/cpp/src/link.cpp              | 13 ++++---------
 proton-c/bindings/cpp/src/proton_event.cpp      | 10 ++++++++--
 proton-c/bindings/cpp/src/receiver.cpp          |  2 +-
 proton-c/bindings/cpp/src/sender.cpp            |  2 +-
 proton-c/bindings/cpp/src/session.cpp           | 12 ++++++------
 proton-c/bindings/cpp/src/terminus.cpp          |  2 +-
 tests/tools/apps/cpp/reactor_send.cpp           |  2 +-
 29 files changed, 86 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/examples/cpp/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp
index 991fb88..c37f45c 100644
--- a/examples/cpp/broker.cpp
+++ b/examples/cpp/broker.cpp
@@ -121,22 +121,21 @@ class broker : public proton::messaging_handler {
 
     void on_link_opening(proton::event &e) {
         proton::link& lnk = e.link();
-        if (lnk.is_sender()) {
-            proton::sender &sender(lnk.sender());
+        if (lnk.sender()) {
             proton::terminus &remote_source(lnk.remote_source());
-            if (remote_source.is_dynamic()) {
+            if (remote_source.dynamic()) {
                 std::string address = queue_name();
                 lnk.source().address(address);
                 queue *q = new queue(true);
                 queues[address] = q;
-                q->subscribe(sender);
+                q->subscribe(*lnk.sender());
                 std::cout << "broker dynamic outgoing link from " << address
<< std::endl;
             }
             else {
                 std::string address = remote_source.address();
                 if (!address.empty()) {
                     lnk.source().address(address);
-                    get_queue(address).subscribe(sender);
+                    get_queue(address).subscribe(*lnk.sender());
                     std::cout << "broker outgoing link from " << address <<
std::endl;
                 }
             }
@@ -160,8 +159,8 @@ class broker : public proton::messaging_handler {
 
     void on_link_closing(proton::event &e) {
         proton::link &lnk = e.link();
-        if (lnk.is_sender()) {
-            unsubscribe(lnk.sender());
+        if (lnk.sender()) {
+            unsubscribe(*lnk.sender());
         }
     }
 
@@ -176,8 +175,8 @@ class broker : public proton::messaging_handler {
     void remove_stale_consumers(proton::connection &connection) {
         proton::link *l = connection.link_head(proton::endpoint::REMOTE_ACTIVE);
         while (l) {
-            if (l->is_sender()) {
-                unsubscribe(l->sender());
+            if (l->sender()) {
+                unsubscribe(*l->sender());
             }
             l = l->next(proton::endpoint::REMOTE_ACTIVE);
         }
@@ -186,8 +185,7 @@ class broker : public proton::messaging_handler {
     void on_sendable(proton::event &e) {
         proton::link& lnk = e.link();
         std::string addr = lnk.source().address();
-        proton::sender &s(lnk.sender());
-        get_queue(addr).dispatch(&s);
+        get_queue(addr).dispatch(lnk.sender());
     }
 
     void on_message(proton::event &e) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/examples/cpp/client.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/client.cpp b/examples/cpp/client.cpp
index 502e490..05924f6 100644
--- a/examples/cpp/client.cpp
+++ b/examples/cpp/client.cpp
@@ -38,9 +38,9 @@ class client : public proton::messaging_handler {
     client(const proton::url &u, const std::vector<std::string>& r) : url(u),
requests(r) {}
 
     void on_start(proton::event &e) {
-        sender = e.container().create_sender(url).ptr();
+        sender = e.container().open_sender(url).ptr();
         // Create a receiver with a dynamically chosen unique address.
-        receiver = sender->connection().create_receiver("", true/*dynamic*/).ptr();
+        receiver = sender->connection().open_receiver("", true/*dynamic*/).ptr();
     }
 
     void send_request() {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/examples/cpp/helloworld.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld.cpp b/examples/cpp/helloworld.cpp
index 358162d..b1eed87 100644
--- a/examples/cpp/helloworld.cpp
+++ b/examples/cpp/helloworld.cpp
@@ -35,8 +35,8 @@ class hello_world : public proton::messaging_handler {
 
     void on_start(proton::event &e) {
         proton::connection& conn = e.container().connect(url);
-        conn.create_receiver(url.path());
-        conn.create_sender(url.path());
+        conn.open_receiver(url.path());
+        conn.open_sender(url.path());
     }
 
     void on_sendable(proton::event &e) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/examples/cpp/helloworld_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp
index 4d96924..b141f1b 100644
--- a/examples/cpp/helloworld_direct.cpp
+++ b/examples/cpp/helloworld_direct.cpp
@@ -36,7 +36,7 @@ class hello_world_direct : public proton::messaging_handler {
 
     void on_start(proton::event &e) {
         acceptor = e.container().listen(url).ptr();
-        e.container().create_sender(url);
+        e.container().open_sender(url);
     }
 
     void on_sendable(proton::event &e) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/examples/cpp/server.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/server.cpp b/examples/cpp/server.cpp
index 7c94228..e1de85e 100644
--- a/examples/cpp/server.cpp
+++ b/examples/cpp/server.cpp
@@ -43,7 +43,7 @@ class server : public proton::messaging_handler {
 
     void on_start(proton::event &e) {
         connection = e.container().connect(url).ptr();
-        connection->create_receiver(url.path());
+        connection->open_receiver(url.path());
         std::cout << "server connected to " << url << std::endl;
     }
 
@@ -62,7 +62,7 @@ class server : public proton::messaging_handler {
         reply.body(to_upper(e.message().body().get<std::string>()));
         reply.correlation_id(e.message().correlation_id());
         if (!senders[reply_to])
-            senders[reply_to] = connection->create_sender(reply_to).ptr();
+            senders[reply_to] = connection->open_sender(reply_to).ptr();
         senders[reply_to]->send(reply);
     }
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/examples/cpp/server_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/server_direct.cpp b/examples/cpp/server_direct.cpp
index 80e672a..2b6d8e2 100644
--- a/examples/cpp/server_direct.cpp
+++ b/examples/cpp/server_direct.cpp
@@ -63,9 +63,9 @@ class server : public proton::messaging_handler {
 
     void on_link_opening(proton::event& e) {
         proton::link& link = e.link();
-        if (link.is_sender() && link.has_remote_source() && link.remote_source().is_dynamic())
{
+        if (link.sender() && link.has_remote_source() && link.remote_source().dynamic())
{
             link.source().address(generate_address());
-            senders[link.source().address()] = link.sender().ptr();
+            senders[link.source().address()] = link.sender()->ptr();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/examples/cpp/simple_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_recv.cpp b/examples/cpp/simple_recv.cpp
index a3337d9..dfd8b5f 100644
--- a/examples/cpp/simple_recv.cpp
+++ b/examples/cpp/simple_recv.cpp
@@ -42,7 +42,7 @@ class simple_recv : public proton::messaging_handler {
     simple_recv(const std::string &s, int c) : url(s), expected(c), received(0) {}
 
     void on_start(proton::event &e) {
-        receiver = e.container().create_receiver(url).ptr();
+        receiver = e.container().open_receiver(url).ptr();
         std::cout << "simple_recv listening on " << url << std::endl;
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/examples/cpp/simple_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp
index 971fbae..d103359 100644
--- a/examples/cpp/simple_send.cpp
+++ b/examples/cpp/simple_send.cpp
@@ -41,7 +41,7 @@ class simple_send : public proton::messaging_handler {
     simple_send(const std::string &s, int c) : url(s), sent(0), confirmed(0), total(c)
{}
 
     void on_start(proton::event &e) {
-        sender = e.container().create_sender(url).ptr();
+        sender = e.container().open_sender(url).ptr();
     }
 
     void on_sendable(proton::event &e) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 08b6ad9..2732802 100644
--- a/proton-c/bindings/cpp/include/proton/connection.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection.hpp
@@ -55,16 +55,16 @@ class connection : public counted_facade<pn_connection_t, connection,
endpoint>
     PN_CPP_EXTERN void close();
 
     /** Create a new session */
-    PN_CPP_EXTERN class session& create_session();
+    PN_CPP_EXTERN class session& open_session();
 
     /** Default session is created on first call and re-used for the lifeime of the connection
*/
     PN_CPP_EXTERN class session& default_session();
 
     /** Create a sender on default_session() with target=addr and optional handler h */
-    PN_CPP_EXTERN sender& create_sender(const std::string &addr, handler *h=0);
+    PN_CPP_EXTERN sender& open_sender(const std::string &addr, handler *h=0);
 
     /** Create a receiver on default_session() with target=addr and optional handler h */
-    PN_CPP_EXTERN receiver& create_receiver(const std::string &addr, bool dynamic=false,
handler *h=0);
+    PN_CPP_EXTERN receiver& open_receiver(const std::string &addr, bool dynamic=false,
handler *h=0);
 
     /** Get the first link on this connection matching the state mask.
      * Return 0 if none. Don't delete returned pointer.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 98754cf..ddb12e9 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -65,13 +65,13 @@ class container
     PN_CPP_EXTERN void run();
 
     /** Open a connection to url and create a sender with target=url.path() */
-    PN_CPP_EXTERN sender& create_sender(const proton::url &);
+    PN_CPP_EXTERN sender& open_sender(const proton::url &);
 
     /** Create a receiver on connection with source=url.path() */
-    PN_CPP_EXTERN receiver& create_receiver(const url &);
+    PN_CPP_EXTERN receiver& open_receiver(const url &);
 
     /// Identifier for the container
-    PN_CPP_EXTERN std::string container_id();
+    PN_CPP_EXTERN std::string id();
 
     /// Set the prefix to be used when generating link names. @see proton::session
     PN_CPP_EXTERN void link_prefix(const std::string&);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 88b5368..8146f33 100644
--- a/proton-c/bindings/cpp/include/proton/link.hpp
+++ b/proton-c/bindings/cpp/include/proton/link.hpp
@@ -49,14 +49,10 @@ class link : public counted_facade<pn_link_t, link, endpoint>
      */
     PN_CPP_EXTERN void close();
 
-    /** True if link is a sender */
-    PN_CPP_EXTERN bool is_sender();
-    /** True if link is a receiver */
-    PN_CPP_EXTERN bool is_receiver();
-    /** Return sender pointer. @throw if link is not a sender. */
-    PN_CPP_EXTERN class sender& sender();
-    /** Return receiver pointer. @throw if link is not a receiver. */
-    PN_CPP_EXTERN class receiver& receiver();
+    /** Return sender if this link is a sender, 0 if not. */
+    PN_CPP_EXTERN class sender* sender();
+    /** Return receiver if this link is a receiver, 0 if not. */
+    PN_CPP_EXTERN class receiver* receiver();
     /** Credit available on the link */
     PN_CPP_EXTERN int credit();
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/proton-c/bindings/cpp/include/proton/reactor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/reactor.hpp b/proton-c/bindings/cpp/include/proton/reactor.hpp
index 401c7dc..b9e9427 100644
--- a/proton-c/bindings/cpp/include/proton/reactor.hpp
+++ b/proton-c/bindings/cpp/include/proton/reactor.hpp
@@ -56,7 +56,7 @@ class reactor : public facade<pn_reactor_t, reactor> {
     PN_CPP_EXTERN void stop();
 
     /// Identifier for the container
-    PN_CPP_EXTERN std::string container_id();
+    PN_CPP_EXTERN std::string id();
 
     /// Get timeout, process() will return if there is no activity within the timeout.
     PN_CPP_EXTERN duration timeout();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 fdee859..7fe3e8d 100644
--- a/proton-c/bindings/cpp/include/proton/session.hpp
+++ b/proton-c/bindings/cpp/include/proton/session.hpp
@@ -59,20 +59,20 @@ class session : public counted_facade<pn_session_t, session, endpoint>
      *@param name must be unique within a container, if empty a unique name is
      * generated beginning with connection().container().link_prefix()
      */
-    PN_CPP_EXTERN receiver& create_receiver_link(const std::string& name=std::string());
+    PN_CPP_EXTERN receiver& create_receiver(const std::string& name=std::string());
 
     /** An un-opened sender link, you can set link properties before calling open().
      *
      *@param name must be unique within a container, if empty a unique name is
      * generated beginning with connection().container().link_prefix()
      */
-    PN_CPP_EXTERN sender& create_sender_link(const std::string& name=std::string());
+    PN_CPP_EXTERN sender& create_sender(const std::string& name=std::string());
 
     /** Create and open a sender with target=addr and optional handler h */
-    PN_CPP_EXTERN sender& create_sender(const std::string &addr, handler *h=0);
+    PN_CPP_EXTERN sender& open_sender(const std::string &addr, handler *h=0);
 
     /** Create and open a receiver with target=addr and optional handler h */
-    PN_CPP_EXTERN receiver& create_receiver(const std::string &addr, bool dynamic=false,
handler *h=0);
+    PN_CPP_EXTERN receiver& open_receiver(const std::string &addr, bool dynamic=false,
handler *h=0);
 
     /** Get the endpoint state */
     PN_CPP_EXTERN endpoint::state state();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 4bb9651..e058e84 100644
--- a/proton-c/bindings/cpp/include/proton/terminus.hpp
+++ b/proton-c/bindings/cpp/include/proton/terminus.hpp
@@ -67,7 +67,7 @@ class terminus : public counted_facade<pn_terminus_t, terminus>
     PN_CPP_EXTERN void distribution_mode(distribution_mode_t);
     PN_CPP_EXTERN std::string address();
     PN_CPP_EXTERN void address(const std::string &);
-    PN_CPP_EXTERN bool is_dynamic();
+    PN_CPP_EXTERN bool dynamic();
     PN_CPP_EXTERN void dynamic(bool);
 };
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/proton-c/bindings/cpp/include/proton/types.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/types.hpp b/proton-c/bindings/cpp/include/proton/types.hpp
index 2de83d2..972f35d 100644
--- a/proton-c/bindings/cpp/include/proton/types.hpp
+++ b/proton-c/bindings/cpp/include/proton/types.hpp
@@ -228,7 +228,7 @@ struct start {
     type_id type;            ///< The container type: ARRAY, LIST, MAP or DESCRIBED.
     type_id element;         ///< the element type for array only.
     bool is_described;       ///< true if first value is a descriptor.
-    size_t size;            ///< the element count excluding the descriptor (if any)
+    size_t size;             ///< the element count excluding the descriptor (if any)
 
     /** Return a start for an array */
     PN_CPP_EXTERN static start array(type_id element, bool described=false);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/proton-c/bindings/cpp/src/blocking_receiver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_receiver.cpp b/proton-c/bindings/cpp/src/blocking_receiver.cpp
index 9628620..656e770 100644
--- a/proton-c/bindings/cpp/src/blocking_receiver.cpp
+++ b/proton-c/bindings/cpp/src/blocking_receiver.cpp
@@ -46,7 +46,7 @@ blocking_receiver::blocking_receiver(
     class blocking_connection &c, const std::string& addr, int credit, bool dynamic)
:
     blocking_link(c), fetcher_(new blocking_fetcher(credit))
 {
-    open(c.impl_->connection_->create_receiver(addr, dynamic, fetcher_.get()));
+    open(c.impl_->connection_->open_receiver(addr, dynamic, fetcher_.get()));
     std::string sa = link_->source().address();
     std::string rsa = link_->remote_source().address();
     if (!sa.empty() && sa.compare(rsa) != 0) {
@@ -97,6 +97,6 @@ void blocking_receiver::flow(int count) {
     receiver().flow(count);
 }
 
-receiver& blocking_receiver::receiver() { return link_->receiver(); }
+receiver& blocking_receiver::receiver() { return *link_->receiver(); }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/proton-c/bindings/cpp/src/blocking_sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking_sender.cpp b/proton-c/bindings/cpp/src/blocking_sender.cpp
index 323dc5e..1fca30b 100644
--- a/proton-c/bindings/cpp/src/blocking_sender.cpp
+++ b/proton-c/bindings/cpp/src/blocking_sender.cpp
@@ -39,7 +39,7 @@ struct delivery_settled : public blocking_connection_impl::condition {
 blocking_sender::blocking_sender(blocking_connection &c, const std::string &address)
:
     blocking_link(c)
 {
-    open(c.impl_->connection_->create_sender(address));
+    open(c.impl_->connection_->open_sender(address));
     std::string ta = link_->target().address();
     std::string rta = link_->remote_target().address();
     if (ta.empty() || ta.compare(rta) != 0) {
@@ -63,6 +63,6 @@ delivery& blocking_sender::send(const message &msg) {
     return send(msg, connection_.timeout());
 }
 
-sender& blocking_sender::sender() { return link_->sender(); }
+sender& blocking_sender::sender() { return *link_->sender(); }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 84c79a6..8f27a01 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -57,24 +57,24 @@ link* connection::link_head(endpoint::state mask) {
     return link::cast(pn_link_head(pn_cast(this), mask));
 }
 
-session& connection::create_session() { return *session::cast(pn_session(pn_cast(this)));
}
+session& connection::open_session() { return *session::cast(pn_session(pn_cast(this)));
}
 
 session& connection::default_session() {
     struct connection_context& ctx = connection_context::get(pn_cast(this));
     if (!ctx.default_session) {
-        ctx.default_session = &create_session();
+        ctx.default_session = &open_session();
         ctx.default_session->open();
     }
     return *ctx.default_session;
 }
 
-sender& connection::create_sender(const std::string &addr, handler *h) {
-    return default_session().create_sender(addr, h);
+sender& connection::open_sender(const std::string &addr, handler *h) {
+    return default_session().open_sender(addr, h);
 }
 
-receiver& connection::create_receiver(const std::string &addr, bool dynamic, handler
*h)
+receiver& connection::open_receiver(const std::string &addr, bool dynamic, handler
*h)
 {
-    return default_session().create_receiver(addr, dynamic, h);
+    return default_session().open_receiver(addr, dynamic, h);
 }
 
 endpoint::state connection::state() { return pn_connection_state(pn_cast(this)); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 3c7c970..49660ea 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -40,7 +40,7 @@ void connector::address(const url &a) {
 
 void connector::connect() {
     pn_connection_t *conn = pn_cast(connection_);
-    pn_connection_set_container(conn, connection_->container().container_id().c_str());
+    pn_connection_set_container(conn, connection_->container().id().c_str());
     pn_connection_set_hostname(conn, address_.host_port().c_str());
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 da97191..9b681b9 100644
--- a/proton-c/bindings/cpp/src/container.cpp
+++ b/proton-c/bindings/cpp/src/container.cpp
@@ -51,16 +51,16 @@ connection& container::connect(const url &host, handler *h) {
return impl_->conn
 
 reactor &container::reactor() { return *impl_->reactor_; }
 
-std::string container::container_id() { return impl_->container_id_; }
+std::string container::id() { return impl_->id_; }
 
 void container::run() { impl_->reactor_->run(); }
 
-sender& container::create_sender(const proton::url &url) {
-    return impl_->create_sender(url);
+sender& container::open_sender(const proton::url &url) {
+    return impl_->open_sender(url);
 }
 
-receiver& container::create_receiver(const proton::url &url) {
-    return impl_->create_receiver(url);
+receiver& container::open_receiver(const proton::url &url) {
+    return impl_->open_receiver(url);
 }
 
 acceptor& container::listen(const proton::url &url) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 eda3c3b..cb32d75 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -116,10 +116,10 @@ counted_ptr<pn_handler_t> container_impl::cpp_handler(handler
*h)
 }
 
 container_impl::container_impl(container& c, handler *h, const std::string& id) :
-    container_(c), reactor_(reactor::create()), handler_(h), container_id_(id),
+    container_(c), reactor_(reactor::create()), handler_(h), id_(id),
     link_id_(0)
 {
-    if (container_id_.empty()) container_id_ = uuid().str();
+    if (id_.empty()) id_ = uuid().str();
     container_context(pn_cast(reactor_.get()), container_);
 
     // Set our own global handler that "subclasses" the existing one
@@ -154,19 +154,19 @@ connection& container_impl::connect(const proton::url &url,
handler *h) {
     return conn;
 }
 
-sender& container_impl::create_sender(const proton::url &url) {
+sender& container_impl::open_sender(const proton::url &url) {
     connection& conn = connect(url, 0);
     std::string path = url.path();
-    sender& snd = conn.default_session().create_sender(container_id_ + '-' + path);
+    sender& snd = conn.default_session().open_sender(id_ + '-' + path);
     snd.target().address(path);
     snd.open();
     return snd;
 }
 
-receiver& container_impl::create_receiver(const proton::url &url) {
+receiver& container_impl::open_receiver(const proton::url &url) {
     connection& conn = connect(url, 0);
     std::string path = url.path();
-    receiver& rcv = conn.default_session().create_receiver(container_id_ + '-' + path);
+    receiver& rcv = conn.default_session().open_receiver(id_ + '-' + path);
     pn_terminus_set_address(pn_link_source(pn_cast(&rcv)), path.c_str());
     rcv.open();
     return rcv;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 6210b23..76d30fb 100644
--- a/proton-c/bindings/cpp/src/container_impl.hpp
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -45,10 +45,10 @@ class container_impl
     PN_CPP_EXTERN container_impl(container&, handler *, const std::string& id);
     PN_CPP_EXTERN ~container_impl();
     PN_CPP_EXTERN connection& connect(const url&, handler *h);
-    PN_CPP_EXTERN sender& create_sender(connection &connection, const std::string
&addr, handler *h);
-    PN_CPP_EXTERN sender& create_sender(const url&);
-    PN_CPP_EXTERN receiver& create_receiver(connection &connection, const std::string
&addr, bool dynamic, handler *h);
-    PN_CPP_EXTERN receiver& create_receiver(const url&);
+    PN_CPP_EXTERN sender& open_sender(connection &connection, const std::string &addr,
handler *h);
+    PN_CPP_EXTERN sender& open_sender(const url&);
+    PN_CPP_EXTERN receiver& open_receiver(connection &connection, const std::string
&addr, bool dynamic, handler *h);
+    PN_CPP_EXTERN receiver& open_receiver(const url&);
     PN_CPP_EXTERN class acceptor& listen(const url&);
     PN_CPP_EXTERN duration timeout();
     PN_CPP_EXTERN void timeout(duration timeout);
@@ -66,7 +66,7 @@ class container_impl
     pn_unique_ptr<messaging_adapter> messaging_adapter_;
     pn_unique_ptr<handler> override_handler_;
     pn_unique_ptr<handler> flow_controller_;
-    std::string container_id_;
+    std::string id_;
     uint64_t link_id_;
     std::string prefix_;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 12c8790..8afad6d 100644
--- a/proton-c/bindings/cpp/src/link.cpp
+++ b/proton-c/bindings/cpp/src/link.cpp
@@ -39,17 +39,12 @@ void link::close() {
     pn_link_close(pn_cast(this));
 }
 
-bool link::is_sender() { return pn_link_is_sender(pn_cast(this)); }
-bool link::is_receiver() { return pn_link_is_receiver(pn_cast(this)); }
-
-sender& link::sender() {
-    if (!is_sender()) throw error("link is not a sender");
-    return *reinterpret_cast<class sender*>(this);
+sender* link::sender() {
+    return pn_link_is_sender(pn_cast(this)) ? reinterpret_cast<class sender*>(this)
: 0;
 }
 
-receiver& link::receiver() {
-    if (!is_receiver()) throw error("link is not a receiver");
-    return *reinterpret_cast<class receiver*>(this);
+receiver* link::receiver() {
+    return pn_link_is_receiver(pn_cast(this)) ? reinterpret_cast<class receiver*>(this)
: 0;
 }
 
 int link::credit() {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 767c6af..80e678e 100644
--- a/proton-c/bindings/cpp/src/proton_event.cpp
+++ b/proton-c/bindings/cpp/src/proton_event.cpp
@@ -63,9 +63,15 @@ link& proton_event::link() {
     return *lnk;
 }
 
-sender& proton_event::sender() { return link().sender(); }
+sender& proton_event::sender() {
+    if (!link().sender()) throw error(MSG("No sender context for this event"));
+    return *link().sender();
+}
 
-receiver& proton_event::receiver() { return link().receiver(); }
+receiver& proton_event::receiver() {
+    if (!link().receiver()) throw error(MSG("No receiver context for this event"));
+    return *link().receiver();
+}
 
 delivery& proton_event::delivery() {
     class delivery *dlv = delivery::cast(pn_event_delivery(pn_event()));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 96a116d..d997c23 100644
--- a/proton-c/bindings/cpp/src/receiver.cpp
+++ b/proton-c/bindings/cpp/src/receiver.cpp
@@ -33,6 +33,6 @@ void receiver::flow(int count) {
     pn_link_flow(pn_cast(this), count);
 }
 
-receiver* receiver::cast(pn_type* p) { return &link::cast(p)->receiver(); }
+receiver* receiver::cast(pn_type* p) { return link::cast(p)->receiver(); }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 993f27d..cd1b0ae 100644
--- a/proton-c/bindings/cpp/src/sender.cpp
+++ b/proton-c/bindings/cpp/src/sender.cpp
@@ -54,6 +54,6 @@ delivery& sender::send(const message &message) {
     return *delivery::cast(dlv);
 }
 
-sender* sender::cast(pn_type* p) { return &link::cast(p)->sender(); }
+sender* sender::cast(pn_type* p) { return link::cast(p)->sender(); }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 3629f21..fd5df6f 100644
--- a/proton-c/bindings/cpp/src/session.cpp
+++ b/proton-c/bindings/cpp/src/session.cpp
@@ -46,27 +46,27 @@ std::string set_name(const std::string& name, session* s) {
 }
 }
 
-receiver& session::create_receiver_link(const std::string& name) {
+receiver& session::create_receiver(const std::string& name) {
     return *reinterpret_cast<receiver*>(
         pn_receiver(pn_cast(this), set_name(name, this).c_str()));
 }
 
-sender& session::create_sender_link(const std::string& name) {
+sender& session::create_sender(const std::string& name) {
     return *reinterpret_cast<sender*>(
         pn_sender(pn_cast(this), set_name(name, this).c_str()));
 }
 
-sender& session::create_sender(const std::string &addr, handler *h) {
-    sender& snd = create_sender_link();
+sender& session::open_sender(const std::string &addr, handler *h) {
+    sender& snd = create_sender();
     snd.target().address(addr);
     if (h) snd.handler(*h);
     snd.open();
     return snd;
 }
 
-receiver& session::create_receiver(const std::string &addr, bool dynamic, handler
*h)
+receiver& session::open_receiver(const std::string &addr, bool dynamic, handler *h)
 {
-    receiver& rcv = create_receiver_link();
+    receiver& rcv = create_receiver();
     rcv.source().address(addr);
     if (dynamic) rcv.source().dynamic(true);
     if (h) rcv.handler(*h);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/proton-c/bindings/cpp/src/terminus.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/terminus.cpp b/proton-c/bindings/cpp/src/terminus.cpp
index 2c960d6..6d17786 100644
--- a/proton-c/bindings/cpp/src/terminus.cpp
+++ b/proton-c/bindings/cpp/src/terminus.cpp
@@ -57,7 +57,7 @@ void terminus::address(const std::string &addr) {
     pn_terminus_set_address(pn_cast(this), addr.c_str());
 }
 
-bool terminus::is_dynamic() {
+bool terminus::dynamic() {
     return (type_t) pn_terminus_is_dynamic(pn_cast(this));
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4e9afbb0/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 721a7cd..7064876 100644
--- a/tests/tools/apps/cpp/reactor_send.cpp
+++ b/tests/tools/apps/cpp/reactor_send.cpp
@@ -64,7 +64,7 @@ class reactor_send : public proton::messaging_handler {
     }
 
     void on_start(proton::event &e) {
-        e.container().create_sender(url_);
+        e.container().open_sender(url_);
         reactor_ = pn_cast(&e.container().reactor());
     }
 


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


Mime
View raw message