qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject qpid-proton git commit: PROTON-1232: [C++ binding] change container interface: - Make all member functions in container class pure virtual (except destructor) - Add a new standard_container class that has the standard behaviour of the variant overloads
Date Wed, 15 Jun 2016 18:17:42 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master ab6b74732 -> b005b877a


PROTON-1232: [C++ binding] change container interface:
- Make all member functions in container class pure virtual (except destructor)
- Add a new standard_container class that has the standard behaviour
  of the variant overloads
- Make all container implementations use standard_container class
- Remove unnecessary includes of container_impl


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

Branch: refs/heads/master
Commit: b005b877a62630a6fdcb62f2270827af56737830
Parents: ab6b747
Author: Andrew Stitcher <astitcher@apache.org>
Authored: Tue Jun 14 18:05:13 2016 -0400
Committer: Andrew Stitcher <astitcher@apache.org>
Committed: Wed Jun 15 13:49:17 2016 -0400

----------------------------------------------------------------------
 examples/cpp/mt/epoll_container.cpp             |  5 ++
 .../bindings/cpp/include/proton/container.hpp   | 73 +++++++++++++++-----
 .../include/proton/io/container_impl_base.hpp   |  6 +-
 proton-c/bindings/cpp/src/connection.cpp        |  1 -
 proton-c/bindings/cpp/src/connector.cpp         |  1 -
 proton-c/bindings/cpp/src/container.cpp         | 39 +++--------
 proton-c/bindings/cpp/src/container_impl.hpp    |  9 ++-
 proton-c/bindings/cpp/src/link.cpp              |  1 -
 proton-c/bindings/cpp/src/messaging_adapter.cpp |  1 -
 proton-c/bindings/cpp/src/session.cpp           |  1 -
 .../bindings/cpp/src/test_dummy_container.hpp   | 10 ++-
 11 files changed, 92 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/examples/cpp/mt/epoll_container.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/mt/epoll_container.cpp b/examples/cpp/mt/epoll_container.cpp
index 63b6a5f..4dd1525 100644
--- a/examples/cpp/mt/epoll_container.cpp
+++ b/examples/cpp/mt/epoll_container.cpp
@@ -104,6 +104,11 @@ class epoll_container : public proton::io::container_impl_base {
     epoll_container(const std::string& id);
     ~epoll_container();
 
+    // Pull in base class functions here so that name search finds all the overloads
+    using standard_container::stop;
+    using standard_container::connect;
+    using standard_container::listen;
+
     proton::returned<proton::connection> connect(
         const std::string& addr, const proton::connection_options& opts) OVERRIDE;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/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 16f63fd..cbf6e7d 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -25,6 +25,8 @@
 #include "./connection_options.hpp"
 #include "./function.hpp"
 #include "./listener.hpp"
+#include "./receiver_options.hpp"
+#include "./sender_options.hpp"
 #include "./thread_safe.hpp"
 
 #include "./internal/config.hpp"
@@ -75,7 +77,7 @@ class PN_CPP_CLASS_EXTERN container {
     virtual returned<connection> connect(const std::string& url, const connection_options
&) = 0;
 
     /// Connect to `url` and send an open request to the remote peer.
-    PN_CPP_EXTERN returned<connection> connect(const std::string& url);
+    virtual returned<connection> connect(const std::string& url) = 0;
 
     /// @cond INTERNAL
     /// Stop listening on url, must match the url string given to listen().
@@ -95,11 +97,11 @@ class PN_CPP_CLASS_EXTERN container {
 
     /// Listen with a fixed set of options for all accepted connections.
     /// See listen(const std::string&, listen_handler&)
-    PN_CPP_EXTERN listener listen(const std::string& url, const connection_options&);
+    virtual listener listen(const std::string& url, const connection_options&) =
0;
 
     /// Start listening on URL.
     /// New connections will use the handler from server_connection_options()
-    PN_CPP_EXTERN listener listen(const std::string& url);
+    virtual listener listen(const std::string& url) = 0;
 
     /// Run the container in this thread.
     /// Returns when the container stops.
@@ -124,17 +126,17 @@ class PN_CPP_CLASS_EXTERN container {
 
     /// Stop the container with an empty error condition.
     /// @see stop(const error_condition&)
-    PN_CPP_EXTERN void stop();
+    virtual void stop() = 0;
 
     /// Open a connection and sender for `url`.
-    PN_CPP_EXTERN returned<sender> open_sender(const std::string &url);
+    virtual returned<sender> open_sender(const std::string &url) = 0;
 
     /// Open a connection and sender for `url`.
     ///
     /// Any supplied sender options will override the container's
     /// template options.
-    PN_CPP_EXTERN returned<sender> open_sender(const std::string &url,
-                                               const proton::sender_options &o);
+    virtual returned<sender> open_sender(const std::string &url,
+                                         const proton::sender_options &o) = 0;
 
     /// Open a connection and sender for `url`.
     ///
@@ -145,15 +147,15 @@ class PN_CPP_CLASS_EXTERN container {
                                          const connection_options &c) = 0;
 
     /// Open a connection and receiver for `url`.
-    PN_CPP_EXTERN returned<receiver> open_receiver(const std::string&url);
+    virtual returned<receiver> open_receiver(const std::string&url) = 0;
 
 
     /// Open a connection and receiver for `url`.
     ///
     /// Any supplied receiver options will override the container's
     /// template options.
-    PN_CPP_EXTERN returned<receiver> open_receiver(const std::string&url,
-                                                   const proton::receiver_options &o);
+    virtual returned<receiver> open_receiver(const std::string&url,
+                                             const proton::receiver_options &o) = 0;
 
     /// Open a connection and receiver for `url`.
     ///
@@ -208,6 +210,36 @@ class PN_CPP_CLASS_EXTERN container {
     virtual void schedule(duration, void_function0&) = 0;
 };
 
+/// @cond INTERNAL
+/// This class is intended for container implementers, it simplifies implementing container
+/// by performing all the default actions for shortened method signatures
+///
+/// Note: This class will only be useful if you want all the ususal defaulted behaviours
+/// in your class as it makes them all non virtual, so you can't use just some of them.
+///
+/// It means that in the usual case the container interface is smaller and a little simpler.
+class PN_CPP_CLASS_EXTERN standard_container : public container {
+  public:
+    // Pull in base class functions here so we don't need to define them again
+    using container::stop;
+    using container::connect;
+    using container::listen;
+    using container::open_receiver;
+    using container::open_sender;
+
+    PN_CPP_EXTERN returned<connection> connect(const std::string& url);
+    PN_CPP_EXTERN listener listen(const std::string& url, const connection_options&);
+    PN_CPP_EXTERN listener listen(const std::string& url);
+    PN_CPP_EXTERN void stop();
+    PN_CPP_EXTERN returned<sender> open_sender(const std::string &url);
+    PN_CPP_EXTERN returned<sender> open_sender(const std::string &url,
+                                               const proton::sender_options &o);
+    PN_CPP_EXTERN returned<receiver> open_receiver(const std::string&url);
+    PN_CPP_EXTERN returned<receiver> open_receiver(const std::string&url,
+                                                           const proton::receiver_options
&o);
+};
+/// @endcond
+
 /// This is an header only class that can be used to help using containers more natural
 /// by allowing them to be treated as value types.
 template <class Ptr>
@@ -221,31 +253,38 @@ class container_ref : public container {
     container_ref(Ptr p) : impl_(p) {}
 #endif
 
-    // Pull in base class functions here so we don't need to define them again
-    using container::stop;
-    using container::connect;
-    using container::listen;
-    using container::open_receiver;
-    using container::open_sender;
-
     returned<connection> connect(const std::string& url, const connection_options&
opts) { return impl_->connect(url, opts); }
+    returned<connection> connect(const std::string& url) { return impl_->connect(url);
}
     listener listen(const std::string& url, listen_handler& l) { return impl_->listen(url,
l); }
+    listener listen(const std::string& url, const connection_options& opts) { return
impl_->listen(url, opts); }
+    listener listen(const std::string& url) { return impl_->listen(url); }
 
     void stop_listening(const std::string& url) { impl_->stop_listening(url); }
     void run() { impl_->run(); }
     void auto_stop(bool set) { impl_->auto_stop(set); }
 
     void stop(const error_condition& err) { impl_->stop(err); }
+    void stop() { impl_->stop(); }
 
     returned<sender> open_sender(
         const std::string &url,
         const class sender_options &o,
         const connection_options &c) { return impl_->open_sender(url, o, c); }
+    returned<sender> open_sender(
+        const std::string &url,
+        const class sender_options &o) { return impl_->open_sender(url, o); }
+    returned<sender> open_sender(
+        const std::string &url) { return impl_->open_sender(url); }
 
     returned<receiver> open_receiver(
         const std::string&url,
         const class receiver_options &o,
         const connection_options &c) { return impl_->open_receiver(url, o, c); }
+    returned<receiver> open_receiver(
+        const std::string&url,
+        const class receiver_options &o) { return impl_->open_receiver(url, o); }
+    returned<receiver> open_receiver(
+        const std::string&url) { return impl_->open_receiver(url); }
 
     std::string id() const { return impl_->id(); }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp b/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp
index 313e675..695125d 100644
--- a/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp
+++ b/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp
@@ -39,8 +39,12 @@ namespace io {
 ///
 /// You can ignore this class if you want to implement the functions
 /// in a different way.
-class container_impl_base : public container {
+class container_impl_base : public standard_container {
   public:
+    // Pull in base class functions here so that name search finds all the overloads
+    using standard_container::open_receiver;
+    using standard_container::open_sender;
+
     /// @copydoc container::client_connection_options
     void client_connection_options(const connection_options & opts) {
         store(client_copts_, opts);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/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 9219517..45164fe 100644
--- a/proton-c/bindings/cpp/src/connection.cpp
+++ b/proton-c/bindings/cpp/src/connection.cpp
@@ -29,7 +29,6 @@
 #include "proton/transport.hpp"
 
 #include "connector.hpp"
-#include "container_impl.hpp"
 #include "contexts.hpp"
 #include "msg.hpp"
 #include "proton_bits.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/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 c03826c..d1b6936 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "connector.hpp"
-#include "container_impl.hpp"
 
 #include "proton/connection.hpp"
 #include "proton/transport.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/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 d8a6061..4ba6a6a 100644
--- a/proton-c/bindings/cpp/src/container.cpp
+++ b/proton-c/bindings/cpp/src/container.cpp
@@ -19,54 +19,35 @@
  *
  */
 
-#include "container_impl.hpp"
-
 #include "proton/container.hpp"
-#include "proton/connection.hpp"
-#include "proton/sender_options.hpp"
-#include "proton/receiver_options.hpp"
-#include "proton/session.hpp"
-#include "proton/error.hpp"
-#include "proton/receiver.hpp"
-#include "proton/receiver_options.hpp"
-#include "proton/sender.hpp"
-#include "proton/sender_options.hpp"
-#include "proton/task.hpp"
-#include "proton/url.hpp"
-
-#include "container_impl.hpp"
-#include "connector.hpp"
-#include "contexts.hpp"
-#include "messaging_adapter.hpp"
 
-#include <proton/connection.h>
-#include <proton/session.h>
+#include "proton/listen_handler.hpp"
 
 namespace proton {
 
 container::~container() {}
 
-/// Functions defined here are convenience overrides that can be triviall
+/// Functions defined here are convenience overrides that can be trivially
 /// defined in terms of other pure virtual functions on container. Don't make
 /// container implementers wade thru all this boiler-plate.
 
-returned<connection> container::connect(const std::string &url) {
+returned<connection> standard_container::connect(const std::string &url) {
     return connect(url, connection_options());
 }
 
-returned<sender> container::open_sender(const std::string &url) {
+returned<sender> standard_container::open_sender(const std::string &url) {
     return open_sender(url, proton::sender_options(), connection_options());
 }
 
-returned<sender> container::open_sender(const std::string &url, const proton::sender_options
&lo) {
+returned<sender> standard_container::open_sender(const std::string &url, const
proton::sender_options &lo) {
     return open_sender(url, lo, connection_options());
 }
 
-returned<receiver> container::open_receiver(const std::string &url) {
+returned<receiver> standard_container::open_receiver(const std::string &url) {
     return open_receiver(url, proton::receiver_options(), connection_options());
 }
 
-returned<receiver> container::open_receiver(const std::string &url, const proton::receiver_options
&lo) {
+returned<receiver> standard_container::open_receiver(const std::string &url, const
proton::receiver_options &lo) {
     return open_receiver(url, lo, connection_options());
 }
 
@@ -79,17 +60,17 @@ namespace{
     };
 }
 
-listener container::listen(const std::string& url, const connection_options& opts)
{
+listener standard_container::listen(const std::string& url, const connection_options&
opts) {
     // Note: listen_opts::on_close() calls delete(this) so this is not a leak.
     // The container will always call on_closed() even if there are errors or exceptions.

     listen_opts* lh = new listen_opts(opts);
     return listen(url, *lh);
 }
 
-listener container::listen(const std::string &url) {
+listener standard_container::listen(const std::string &url) {
     return listen(url, connection_options());
 }
 
-void container::stop() { stop(error_condition()); }
+void standard_container::stop() { stop(error_condition()); }
 
 } // namespace proton

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/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 07f2563..9ffb7bb 100644
--- a/proton-c/bindings/cpp/src/container_impl.hpp
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -49,8 +49,15 @@ class url;
 class task;
 class listen_handler;
 
-class container_impl : public container {
+class container_impl : public standard_container {
   public:
+    // Pull in base class functions here so that name search finds all the overloads
+    using standard_container::stop;
+    using standard_container::connect;
+    using standard_container::listen;
+    using standard_container::open_receiver;
+    using standard_container::open_sender;
+
     container_impl(const std::string& id, messaging_handler* = 0);
     ~container_impl();
     std::string id() const PN_CPP_OVERRIDE { return id_; }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/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 6a00101..eb4ccb1 100644
--- a/proton-c/bindings/cpp/src/link.cpp
+++ b/proton-c/bindings/cpp/src/link.cpp
@@ -29,7 +29,6 @@
 #include <proton/session.h>
 #include <proton/link.h>
 
-#include "container_impl.hpp"
 #include "contexts.hpp"
 #include "msg.hpp"
 #include "proton_bits.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/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 eba6c06..e74fa4e 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -27,7 +27,6 @@
 #include "proton/tracker.hpp"
 #include "proton/transport.hpp"
 
-#include "container_impl.hpp"
 #include "contexts.hpp"
 #include "msg.hpp"
 #include "proton_bits.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/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 abb7399..03d8cd1 100644
--- a/proton-c/bindings/cpp/src/session.cpp
+++ b/proton-c/bindings/cpp/src/session.cpp
@@ -27,7 +27,6 @@
 #include "proton/session_options.hpp"
 
 #include "contexts.hpp"
-#include "container_impl.hpp"
 #include "proton_bits.hpp"
 
 #include <string>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b005b877/proton-c/bindings/cpp/src/test_dummy_container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/test_dummy_container.hpp b/proton-c/bindings/cpp/src/test_dummy_container.hpp
index 24bb415..4af432a 100644
--- a/proton-c/bindings/cpp/src/test_dummy_container.hpp
+++ b/proton-c/bindings/cpp/src/test_dummy_container.hpp
@@ -29,14 +29,20 @@ namespace test {
 using namespace proton;
 
 
-class dummy_container : public container {
+class dummy_container : public standard_container {
   public:
     dummy_container(const std::string cid="") :
         id_(cid), fail("not implemented for dummy_container") {}
 
+    // Pull in base class functions here so that name search finds all the overloads
+    using standard_container::stop;
+    using standard_container::connect;
+    using standard_container::listen;
+    using standard_container::open_receiver;
+    using standard_container::open_sender;
+
     returned<connection> connect(const std::string&, const connection_options&)
{ throw fail; }
     listener listen(const std::string& , listen_handler& ) { throw fail; }
-    listener listen(const std::string&, const connection_options&) { throw fail;
}
     void stop_listening(const std::string&) { throw fail; }
     void run() { throw fail; }
     void auto_stop(bool) { throw fail; }


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


Mime
View raw message