This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/main by this push:
     new a9509ed  PROTON-2308: Change dynamic_node API to be more like existing 
APIs
a9509ed is described below

commit a9509ed3a66370d2f27a6da12b86e3f67c353fe5
Author: Andrew Stitcher <[email protected]>
AuthorDate: Thu Jan 6 17:28:45 2022 -0500

    PROTON-2308: Change dynamic_node API to be more like existing APIs
    
    Also mark new APIs as unsettled
---
 cpp/include/proton/source_options.hpp |  6 +++---
 cpp/include/proton/target_options.hpp |  6 +++---
 cpp/include/proton/terminus.hpp       | 16 ++++++++++------
 cpp/src/link_test.cpp                 | 28 +++++++++++++++++++---------
 cpp/src/node_options.cpp              |  8 ++++----
 cpp/src/terminus.cpp                  |  6 +++---
 6 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/cpp/include/proton/source_options.hpp 
b/cpp/include/proton/source_options.hpp
index 6258a20..8a0f093 100644
--- a/cpp/include/proton/source_options.hpp
+++ b/cpp/include/proton/source_options.hpp
@@ -91,11 +91,11 @@ class source_options {
     /// messages.
     PN_CPP_EXTERN source_options& filters(const source::filter_map&);
 
-    /// Extension capabilities that are supported/requested
+    /// **Unsettled API** Extension capabilities that are supported/requested
     PN_CPP_EXTERN source_options& capabilities(const std::vector<symbol>&);
 
-    /// Set the dynamic node properties.
-    PN_CPP_EXTERN source_options& dynamic_properties(const std::map<symbol, 
value>&);
+    /// **Unsettled API** Set the dynamic node properties.
+    PN_CPP_EXTERN source_options& dynamic_properties(const 
source::dynamic_property_map&);
 
   private:
     void apply(source&) const;
diff --git a/cpp/include/proton/target_options.hpp 
b/cpp/include/proton/target_options.hpp
index 8c0bb7a..02feba8 100644
--- a/cpp/include/proton/target_options.hpp
+++ b/cpp/include/proton/target_options.hpp
@@ -82,11 +82,11 @@ class target_options {
     /// target::LINK_CLOSE.
     PN_CPP_EXTERN target_options& expiry_policy(enum target::expiry_policy);
 
-    /// Extension capabilities that are supported/requested
+    /// **Unsettled API** Extension capabilities that are supported/requested
     PN_CPP_EXTERN target_options& capabilities(const std::vector<symbol>&);
 
-    /// Set the dynamic node properties.
-    PN_CPP_EXTERN target_options& dynamic_properties(const std::map<symbol, 
value>&);
+    /// **Unsettled API** Set the dynamic node properties.
+    PN_CPP_EXTERN target_options& dynamic_properties(const 
target::dynamic_property_map&);
 
   private:
     void apply(target&) const;
diff --git a/cpp/include/proton/terminus.hpp b/cpp/include/proton/terminus.hpp
index ca10d2c..0e44fef 100644
--- a/cpp/include/proton/terminus.hpp
+++ b/cpp/include/proton/terminus.hpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "./map.hpp"
 #include "./types_fwd.hpp"
 #include "./internal/export.hpp"
 
@@ -55,6 +56,8 @@ class terminus {
     /// @endcond
 
   public:
+    typedef map<symbol, value> dynamic_property_map;
+
     terminus() : object_(0), parent_(0) {}
 
     /// The persistence mode of the source or target.
@@ -97,16 +100,17 @@ class terminus {
     /// True if the remote node is an anonymous-relay
     PN_CPP_EXTERN bool anonymous() const;
 
-    /// Obtain a reference to the AMQP dynamic node properties for the
-    /// terminus.  See also lifetime_policy.
+    /// Obtain the AMQP dynamic node properties for the terminus as a single 
value.
+    /// See also lifetime_policy.
+    /// @deprecated in favor of dynamic_properties()
     PN_CPP_EXTERN value node_properties() const;
 
-    /// Extension capabilities that are supported/requested
+    /// **Unsettled API** Extension capabilities that are supported/requested
     PN_CPP_EXTERN std::vector<symbol> capabilities() const;
 
-    /// Obtain the AMQP dynamic node properties for the
-    /// terminus as a standard map.
-    PN_CPP_EXTERN std::map<symbol, value> dynamic_properties() const;
+    /// **Unsettled API** Obtain the AMQP dynamic node properties for the
+    /// terminus as a map.
+    PN_CPP_EXTERN dynamic_property_map dynamic_properties() const;
 
   protected:
     pn_terminus_t *pn_object() const { return object_; }
diff --git a/cpp/src/link_test.cpp b/cpp/src/link_test.cpp
index cd9d931..066381c 100644
--- a/cpp/src/link_test.cpp
+++ b/cpp/src/link_test.cpp
@@ -41,7 +41,7 @@
 #include <mutex>
 #include <thread>
 
-typedef std::map<proton::symbol, proton::value> property_map;
+using property_map=proton::terminus::dynamic_property_map;
 
 namespace {
 std::mutex m;
@@ -78,16 +78,21 @@ class test_server : public proton::messaging_handler {
     void on_sender_open(proton::sender& s) override {
         ASSERT(s.source().dynamic());
         ASSERT(s.source().address().empty());
-        property_map p = {{proton::symbol("supported-dist-modes"), 
proton::symbol("copy")}};
+        property_map p;
+        p = std::map<proton::symbol, proton::value>{
+          {proton::symbol("supported-dist-modes"), proton::symbol("copy")}
+        };
         ASSERT_EQUAL(s.source().dynamic_properties(), p);
 
+        property_map sp;
+        sp = std::map<proton::symbol, proton::value>{
+          {proton::symbol("supported-dist-modes"), proton::symbol("move")}
+        };
         proton::source_options opts;
         opts.address(DYNAMIC_ADDRESS)
             // This fails due to a bug in the C++ bindings - PROTON-2480
             // .dynamic(true)
-            .dynamic_properties(
-          property_map{{proton::symbol("supported-dist-modes"), 
proton::symbol("move")}}
-        );
+            .dynamic_properties(sp);
         s.open(proton::sender_options().source(opts));
         listener.stop();
     }
@@ -101,11 +106,13 @@ class test_client : public proton::messaging_handler {
     test_client (const std::string& s) : url(s) {}
 
     void on_container_start(proton::container& c) override {
+        property_map sp;
+        sp = std::map<proton::symbol, proton::value>{
+          {proton::symbol("supported-dist-modes"), proton::symbol("copy")}
+        };
         proton::source_options opts;
         opts.dynamic(true)
-            .dynamic_properties(
-              property_map{{proton::symbol{"supported-dist-modes"}, 
proton::symbol{"copy"}}}
-        );
+            .dynamic_properties(sp);
         c.open_receiver(url, proton::receiver_options().source(opts));
     }
 
@@ -113,7 +120,10 @@ class test_client : public proton::messaging_handler {
         // This fails due to a bug in the c++ bindings - PROTON-2480
         // ASSERT(r.source().dynamic());
         ASSERT_EQUAL(DYNAMIC_ADDRESS, r.source().address());
-        property_map m({{proton::symbol("supported-dist-modes"), 
proton::symbol("move")}});
+        property_map m;
+        m = std::map<proton::symbol, proton::value>{
+          {proton::symbol("supported-dist-modes"), proton::symbol("move")}
+        };
         ASSERT_EQUAL(m, r.source().dynamic_properties());
 
         r.connection().close();
diff --git a/cpp/src/node_options.cpp b/cpp/src/node_options.cpp
index 1cc07ec..2b506fd 100644
--- a/cpp/src/node_options.cpp
+++ b/cpp/src/node_options.cpp
@@ -100,7 +100,7 @@ class source_options::impl {
     option<enum source::distribution_mode> distribution_mode;
     option<source::filter_map> filters;
     option<std::vector<symbol> > capabilities;
-    option<std::map<symbol, value>> dynamic_properties;
+    option<source::dynamic_property_map> dynamic_properties;
 
     void apply(source& s) {
         node_address(s, address, dynamic, anonymous);
@@ -143,7 +143,7 @@ source_options& source_options::expiry_policy(enum 
source::expiry_policy m) { im
 source_options& source_options::distribution_mode(enum 
source::distribution_mode m) { impl_->distribution_mode = m; return *this; }
 source_options& source_options::filters(const source::filter_map &map) { 
impl_->filters = map; return *this; }
 source_options& source_options::capabilities(const std::vector<symbol>& c) { 
impl_->capabilities = c; return *this; }
-source_options& source_options::dynamic_properties(const std::map<symbol, 
value>& c) {
+source_options& source_options::dynamic_properties(const 
source::dynamic_property_map& c) {
     impl_->dynamic_properties = c;
     return *this;
 }
@@ -161,7 +161,7 @@ class target_options::impl {
     option<duration> timeout;
     option<enum target::expiry_policy> expiry_policy;
     option<std::vector<symbol> > capabilities;
-    option<std::map<symbol, value>> dynamic_properties;
+    option<target::dynamic_property_map> dynamic_properties;
 
     void apply(target& t) {
         node_address(t, address, dynamic, anonymous);
@@ -196,7 +196,7 @@ target_options& target_options::durability_mode(enum 
target::durability_mode m)
 target_options& target_options::timeout(duration d) { impl_->timeout = d; 
return *this; }
 target_options& target_options::expiry_policy(enum target::expiry_policy m) { 
impl_->expiry_policy = m; return *this; }
 target_options& target_options::capabilities(const std::vector<symbol>& c) { 
impl_->capabilities = c; return *this; }
-target_options& target_options::dynamic_properties(const std::map<symbol, 
value>& c) {
+target_options& target_options::dynamic_properties(const 
target::dynamic_property_map& c) {
     impl_->dynamic_properties = c;
     return *this;
 }
diff --git a/cpp/src/terminus.cpp b/cpp/src/terminus.cpp
index 5393bbe..0cdc25c 100644
--- a/cpp/src/terminus.cpp
+++ b/cpp/src/terminus.cpp
@@ -61,11 +61,11 @@ std::vector<symbol> terminus::capabilities() const {
     return caps.empty() ? std::vector<symbol>() : caps.get<std::vector<symbol> 
>();
 }
 
-std::map<symbol, value> terminus::dynamic_properties() const {
+terminus::dynamic_property_map terminus::dynamic_properties() const {
     value props(pn_terminus_properties(object_));
-    std::map<symbol, value> properties;
+    dynamic_property_map properties;
     if (!props.empty()) {
-        get(props, properties);
+        properties.value(props);
     }
     return properties;
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to