You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2018/07/03 22:12:51 UTC
[02/89] [abbrv] [partial] qpid-proton git commit: PROTON-1728:
Reorganize the source tree
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/io/connection_driver.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/io/connection_driver.hpp b/cpp/include/proton/io/connection_driver.hpp
new file mode 100644
index 0000000..33026e0
--- /dev/null
+++ b/cpp/include/proton/io/connection_driver.hpp
@@ -0,0 +1,208 @@
+#ifndef PROTON_IO_CONNECTION_DRIVER_HPP
+#define PROTON_IO_CONNECTION_DRIVER_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "../connection_options.hpp"
+#include "../error_condition.hpp"
+#include "../fwd.hpp"
+#include "../internal/config.hpp"
+#include "../types_fwd.hpp"
+
+#include <proton/connection_driver.h>
+
+#include <string>
+
+/// @file
+/// @copybrief proton::io::connection_driver
+
+namespace proton {
+
+class work_queue;
+class proton_handler;
+
+namespace io {
+
+/// **Unsettled API** - A pointer to a mutable memory region with a
+/// size.
+struct mutable_buffer {
+ char* data; ///< Beginning of the buffered data.
+ size_t size; ///< Number of bytes in the buffer.
+
+ /// Construct a buffer starting at data_ with size_ bytes.
+ mutable_buffer(char* data_=0, size_t size_=0) : data(data_), size(size_) {}
+};
+
+/// **Unsettled API** - A pointer to an immutable memory region with a
+/// size.
+struct const_buffer {
+ const char* data; ///< Beginning of the buffered data.
+ size_t size; ///< Number of bytes in the buffer.
+
+ /// Construct a buffer starting at data_ with size_ bytes.
+ const_buffer(const char* data_=0, size_t size_=0) : data(data_), size(size_) {}
+};
+
+/// **Unsettled API** - An AMQP driver for a single connection.
+///
+/// io::connection_driver manages a single proton::connection and dispatches
+/// events to a proton::messaging_handler. It does no IO of its own, but allows you to
+/// integrate AMQP protocol handling into any IO or concurrency framework.
+///
+/// The application is coded the same way as for the
+/// proton::container. The application implements a
+/// proton::messaging_handler to respond to transport, connection,
+/// session, link, and message events. With a little care, the same
+/// handler classes can be used for both container and
+/// connection_driver. the @ref broker.cpp example illustrates this.
+///
+/// You need to write the IO code to read AMQP data to the
+/// read_buffer(). The engine parses the AMQP frames. dispatch() calls
+/// the appropriate functions on the applications proton::messaging_handler. You
+/// write output data from the engine's write_buffer() to your IO.
+///
+/// The engine is not safe for concurrent use, but you can process
+/// different engines concurrently. A common pattern for
+/// high-performance servers is to serialize read/write activity
+/// per connection and dispatch in a fixed-size thread pool.
+///
+/// The engine is designed to work with a classic reactor (e.g.,
+/// select, poll, epoll) or an async-request driven proactor (e.g.,
+/// windows completion ports, boost.asio, libuv).
+///
+/// The engine never throws exceptions.
+class
+PN_CPP_CLASS_EXTERN connection_driver {
+ public:
+ /// An engine without a container id.
+ PN_CPP_EXTERN connection_driver();
+
+ /// Create a connection driver associated with a container id.
+ PN_CPP_EXTERN connection_driver(const std::string&);
+
+ PN_CPP_EXTERN ~connection_driver();
+
+ /// Configure a connection by applying exactly the options in opts (including proton::messaging_handler)
+ /// Does not apply any default options, to apply container defaults use connect() or accept()
+ /// instead. If server==true, configure a server connection.
+ void configure(const connection_options& opts=connection_options(), bool server=false);
+
+ /// Call configure() with client options and call connection::open()
+ /// Options applied: container::id(), container::client_connection_options(), opts.
+ PN_CPP_EXTERN void connect(const connection_options& opts);
+
+ /// Call configure() with server options.
+ /// Options applied: container::id(), container::server_connection_options(), opts.
+ ///
+ /// Note this does not call connection::open(). If there is a messaging_handler in the
+ /// composed options it will receive messaging_handler::on_connection_open() and can
+ /// respond with connection::open() or connection::close()
+ PN_CPP_EXTERN void accept(const connection_options& opts);
+
+ /// The engine's read buffer. Read data into this buffer then call read_done() when complete.
+ /// Returns mutable_buffer(0, 0) if the engine cannot currently read data.
+ /// Calling dispatch() may open up more buffer space.
+ PN_CPP_EXTERN mutable_buffer read_buffer();
+
+ /// Indicate that the first n bytes of read_buffer() have valid data.
+ /// This changes the buffer, call read_buffer() to get the updated buffer.
+ PN_CPP_EXTERN void read_done(size_t n);
+
+ /// Indicate that the read side of the transport is closed and no more data will be read.
+ /// Note that there may still be events to dispatch() or data to write.
+ PN_CPP_EXTERN void read_close();
+
+ /// The engine's write buffer. Write data from this buffer then call write_done()
+ /// Returns const_buffer(0, 0) if the engine has nothing to write.
+ /// Calling dispatch() may generate more data in the write buffer.
+ PN_CPP_EXTERN const_buffer write_buffer();
+
+ /// Indicate that the first n bytes of write_buffer() have been written successfully.
+ /// This changes the buffer, call write_buffer() to get the updated buffer.
+ PN_CPP_EXTERN void write_done(size_t n);
+
+ /// Indicate that the write side of the transport has closed and no more data can be written.
+ /// Note that there may still be events to dispatch() or data to read.
+ PN_CPP_EXTERN void write_close();
+
+ /// Indicate that time has passed
+ ///
+ /// @return the expiration time of the next unexpired timer. You must arrange to call tick()
+ /// no later than this expiration time. In practice this will mean calling tick() every time
+ /// there is anything read or written, and if nothing is read or written then as soon as possible
+ /// after the returned timestamp (so you will probably need to set a platform specific timeout to
+ /// know when this occurs).
+ PN_CPP_EXTERN timestamp tick(timestamp now);
+
+ /// Inform the engine that the transport been disconnected unexpectedly,
+ /// without completing the AMQP connection close sequence.
+ ///
+ /// This calls read_close(), write_close(), sets the transport().error() and
+ /// queues an `on_transport_error` event. You must call dispatch() one more
+ /// time to dispatch the messaging_handler::on_transport_error() call and other final
+ /// events.
+ ///
+ /// Note this does not close the connection() so that a proton::messaging_handler can
+ /// distinguish between a connection close error sent by the remote peer and
+ /// a transport failure.
+ ///
+ PN_CPP_EXTERN void disconnected(const error_condition& = error_condition());
+
+ /// There are events to be dispatched by dispatch()
+ PN_CPP_EXTERN bool has_events() const;
+
+ /// Dispatch all available events and call the corresponding \ref messaging_handler methods.
+ ///
+ /// Returns true if the engine is still active, false if it is finished and
+ /// can be destroyed. The engine is finished when all events are dispatched
+ /// and one of the following is true:
+ ///
+ /// - both read_close() and write_close() have been called, no more IO is possible.
+ /// - The AMQP connection() is closed AND the write_buffer() is empty.
+ ///
+ /// May modify the read_buffer() and/or the write_buffer().
+ ///
+ PN_CPP_EXTERN bool dispatch();
+
+ /// Get the AMQP connection associated with this connection_driver.
+ PN_CPP_EXTERN proton::connection connection() const;
+
+ /// Get the transport associated with this connection_driver.
+ PN_CPP_EXTERN proton::transport transport() const;
+
+ /// Get the container associated with this connection_driver, if there is one.
+ PN_CPP_EXTERN proton::container* container() const;
+
+ private:
+ void init();
+ connection_driver(const connection_driver&);
+ connection_driver& operator=(const connection_driver&);
+
+ std::string container_id_;
+ messaging_handler* handler_;
+ pn_connection_driver_t driver_;
+};
+
+} // io
+} // proton
+
+#endif // PROTON_IO_CONNECTION_DRIVER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/link.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/link.hpp b/cpp/include/proton/link.hpp
new file mode 100644
index 0000000..5c5280e
--- /dev/null
+++ b/cpp/include/proton/link.hpp
@@ -0,0 +1,106 @@
+#ifndef PROTON_LINK_HPP
+#define PROTON_LINK_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./endpoint.hpp"
+#include "./internal/object.hpp"
+
+#include <string>
+
+/// @file
+/// @copybrief proton::link
+
+struct pn_link_t;
+
+namespace proton {
+
+/// A named channel for sending or receiving messages. It is the base
+/// class for sender and receiver.
+class
+PN_CPP_CLASS_EXTERN link : public internal::object<pn_link_t> , public endpoint {
+ /// @cond INTERNAL
+ link(pn_link_t* l) : internal::object<pn_link_t>(l) {}
+ /// @endcond
+
+ public:
+ /// Create an empty link.
+ link() : internal::object<pn_link_t>(0) {}
+
+ PN_CPP_EXTERN bool uninitialized() const;
+ PN_CPP_EXTERN bool active() const;
+ PN_CPP_EXTERN bool closed() const;
+
+ PN_CPP_EXTERN class error_condition error() const;
+
+ PN_CPP_EXTERN void close();
+ PN_CPP_EXTERN void close(const error_condition&);
+
+ /// Suspend the link without closing it. A suspended link may be
+ /// reopened with the same or different link options if supported
+ /// by the peer. A suspended durable subscription becomes inactive
+ /// without cancelling it.
+ // XXX Should take error condition
+ PN_CPP_EXTERN void detach();
+
+ /// Credit available on the link.
+ PN_CPP_EXTERN int credit() const;
+
+ /// **Unsettled API** - True for a receiver if a drain cycle has
+ /// been started and the corresponding `on_receiver_drain_finish`
+ /// event is still pending. True for a sender if the receiver has
+ /// requested a drain of credit and the sender has unused credit.
+ ///
+ /// @see @ref receiver::drain.
+ PN_CPP_EXTERN bool draining();
+
+ /// Get the link name.
+ PN_CPP_EXTERN std::string name() const;
+
+ /// The container for this link.
+ PN_CPP_EXTERN class container &container() const;
+
+ /// Get the work_queue for the link.
+ PN_CPP_EXTERN class work_queue& work_queue() const;
+
+ /// The connection that owns this link.
+ PN_CPP_EXTERN class connection connection() const;
+
+ /// The session that owns this link.
+ PN_CPP_EXTERN class session session() const;
+
+ protected:
+ /// @cond INTERNAL
+
+ // Initiate the AMQP attach frame.
+ void attach();
+
+ friend class internal::factory<link>;
+
+ /// @endcond
+};
+
+}
+
+#endif // PROTON_LINK_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/listen_handler.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/listen_handler.hpp b/cpp/include/proton/listen_handler.hpp
new file mode 100644
index 0000000..b5e44a7
--- /dev/null
+++ b/cpp/include/proton/listen_handler.hpp
@@ -0,0 +1,64 @@
+#ifndef PROTON_LISTEN_HANDLER_HPP
+#define PROTON_LISTEN_HANDLER_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+#include <string>
+
+/// @file
+/// @copybrief proton::listen_handler
+
+namespace proton {
+
+// XXX Discuss more
+/// **Unsettled API** - A handler for incoming connections.
+///
+/// Implement this interface and pass to proton::container::listen()
+/// to be notified of new connections.
+class PN_CPP_CLASS_EXTERN listen_handler {
+ public:
+ PN_CPP_EXTERN virtual ~listen_handler();
+
+ /// Called when the listener is opened successfully.
+ PN_CPP_EXTERN virtual void on_open(listener&);
+
+ /// Called for each accepted connection.
+ ///
+ /// Returns connection_options to apply, including a proton::messaging_handler for
+ /// the connection. messaging_handler::on_connection_open() will be called with
+ /// the proton::connection, it can call connection::open() to accept or
+ /// connection::close() to reject the connection.
+ PN_CPP_EXTERN virtual connection_options on_accept(listener&);
+
+ /// Called if there is a listening error, with an error message.
+ /// close() will also be called.
+ PN_CPP_EXTERN virtual void on_error(listener&, const std::string&);
+
+ /// Called when this listen_handler is no longer needed, and can be deleted.
+ PN_CPP_EXTERN virtual void on_close(listener&);
+};
+
+} // proton
+
+#endif // PROTON_LISTEN_HANDLER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/listener.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/listener.hpp b/cpp/include/proton/listener.hpp
new file mode 100644
index 0000000..d5d0aba
--- /dev/null
+++ b/cpp/include/proton/listener.hpp
@@ -0,0 +1,75 @@
+#ifndef PROTON_LISTENER_HPP
+#define PROTON_LISTENER_HPP
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "./internal/export.hpp"
+
+/// @file
+/// @copybrief proton::listener
+
+struct pn_listener_t;
+
+namespace proton {
+
+/// A listener for incoming connections.
+class PN_CPP_CLASS_EXTERN listener {
+ /// @cond INTERNAL
+ listener(pn_listener_t*);
+ /// @endcond
+
+ public:
+ /// Create an empty listener.
+ PN_CPP_EXTERN listener();
+
+ /// Copy a listener.
+ PN_CPP_EXTERN listener(const listener&);
+
+ PN_CPP_EXTERN ~listener();
+
+ /// Copy a listener.
+ PN_CPP_EXTERN listener& operator=(const listener&);
+
+ /// Stop listening on the address provided to the call to
+ /// container::listen that returned this listener.
+ PN_CPP_EXTERN void stop();
+
+ /// **Unsettedled API**
+ ///
+ /// Return the port used by the listener.
+ /// If port 0 was passed to container::listen, this will be a dynamically allocated port.
+ /// @throw proton::error if the listener does not have a port
+ PN_CPP_EXTERN int port();
+
+ /// **Unsettedled API**
+ ///
+ /// Get the container.
+ /// @throw proton::error if this listener is not managed by a container.
+ PN_CPP_EXTERN class container& container() const;
+
+ private:
+ pn_listener_t* listener_;
+
+ friend class container;
+};
+
+} // proton
+
+#endif // PROTON_LISTENER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/map.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/map.hpp b/cpp/include/proton/map.hpp
new file mode 100644
index 0000000..f9d524c
--- /dev/null
+++ b/cpp/include/proton/map.hpp
@@ -0,0 +1,152 @@
+#ifndef PROTON_MAP_HPP
+#define PROTON_MAP_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./value.hpp"
+#include "./internal/pn_unique_ptr.hpp"
+
+#include <cstddef>
+
+/// @file
+/// @copybrief proton::map
+
+namespace proton {
+
+namespace codec {
+class decoder;
+class encoder;
+}
+
+template <class K, class T>
+class map_type_impl;
+
+template <class K, class T>
+class map;
+
+/// Decode from a proton::map
+template <class K, class T>
+PN_CPP_EXTERN proton::codec::decoder& operator>>(proton::codec::decoder& d, map<K,T>& m);
+/// Encode to a proton::map
+template <class K, class T>
+PN_CPP_EXTERN proton::codec::encoder& operator<<(proton::codec::encoder& e, const map<K,T>& m);
+/// Swap proton::map instances
+template <class K, class T>
+PN_CPP_EXTERN void swap(map<K,T>&, map<K,T>&);
+
+/// A collection of key-value pairs.
+///
+/// Used to access standard AMQP property, annotation, and filter maps
+/// attached to proton::message and proton::source.
+///
+/// This class provides only basic get() and put() operations for
+/// convenience. For more complicated uses (iteration, preserving
+/// order, and so on), convert the value to a standard C++ map type
+/// such as `std::map`. See @ref message_properties.cpp and @ref
+/// types_page.
+template <class K, class T>
+class PN_CPP_CLASS_EXTERN map {
+ template <class M, class U=void>
+ struct assignable_map :
+ public internal::enable_if<codec::is_encodable_map<M,K,T>::value, U> {};
+
+ public:
+ /// Construct an empty map.
+ PN_CPP_EXTERN map();
+
+ /// Copy a map.
+ PN_CPP_EXTERN map(const map&);
+
+ /// Copy a map.
+ PN_CPP_EXTERN map& operator=(const map&);
+
+#if PN_CPP_HAS_RVALUE_REFERENCES
+ /// Move a map.
+ PN_CPP_EXTERN map(map&&);
+
+ /// Move a map.
+ PN_CPP_EXTERN map& operator=(map&&);
+#endif
+ PN_CPP_EXTERN ~map();
+
+ /// Type-safe assign from a compatible map, for instance
+ /// `std::map<K,T>`. See @ref types_page.
+ template <class M>
+ typename assignable_map<M, map&>::type operator=(const M& x) { value(x); return *this; }
+
+ /// Copy from a proton::value.
+ ///
+ /// @throw proton::conversion_error if `x` does not contain a
+ /// compatible map.
+ PN_CPP_EXTERN void value(const value& x);
+
+ /// Access as a proton::value containing an AMQP map.
+ PN_CPP_EXTERN proton::value& value();
+
+ /// Access as a proton::value containing an AMQP map.
+ PN_CPP_EXTERN const proton::value& value() const;
+
+ /// Get the map entry for key `k`. Return `T()` if there is no
+ /// such entry.
+ PN_CPP_EXTERN T get(const K& k) const;
+
+ /// Put a map entry for key `k`.
+ PN_CPP_EXTERN void put(const K& k, const T& v);
+
+ /// Erase the map entry at `k`.
+ PN_CPP_EXTERN size_t erase(const K& k);
+
+ /// True if the map has an entry for `k`.
+ PN_CPP_EXTERN bool exists(const K& k) const;
+
+ /// Get the number of map entries.
+ PN_CPP_EXTERN size_t size() const;
+
+ /// Remove all map entries.
+ PN_CPP_EXTERN void clear();
+
+ /// True if the map has no entries.
+ PN_CPP_EXTERN bool empty() const;
+
+ /// @cond INTERNAL
+ explicit map(pn_data_t*);
+ void reset(pn_data_t*);
+ /// @endcond
+
+ private:
+ typedef map_type_impl<K,T> map_type;
+ mutable internal::pn_unique_ptr<map_type> map_;
+ mutable proton::value value_;
+
+ map_type& cache() const;
+ proton::value& flush() const;
+
+ /// @cond INTERNAL
+ friend PN_CPP_EXTERN proton::codec::decoder& operator>> <>(proton::codec::decoder&, map&);
+ friend PN_CPP_EXTERN proton::codec::encoder& operator<< <>(proton::codec::encoder&, const map&);
+ friend PN_CPP_EXTERN void swap<>(map&, map&);
+ /// @endcond
+};
+
+} // proton
+
+#endif // PROTON_MAP_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/message.hpp b/cpp/include/proton/message.hpp
new file mode 100644
index 0000000..50e12e4
--- /dev/null
+++ b/cpp/include/proton/message.hpp
@@ -0,0 +1,334 @@
+#ifndef PROTON_MESSAGE_HPP
+#define PROTON_MESSAGE_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./duration.hpp"
+#include "./timestamp.hpp"
+#include "./value.hpp"
+#include "./map.hpp"
+
+#include "./internal/pn_unique_ptr.hpp"
+
+#include <proton/type_compat.h>
+
+#include <string>
+#include <vector>
+
+/// @file
+/// @copybrief proton::message
+
+struct pn_message_t;
+
+namespace proton {
+
+/// An AMQP message.
+///
+/// Value semantics: A message can be copied or assigned to make a new
+/// message.
+class message {
+ public:
+ /// A map of string keys and AMQP scalar values.
+ typedef map<std::string, scalar> property_map;
+
+ /// A map of AMQP annotation keys and AMQP values.
+ typedef map<annotation_key, value> annotation_map;
+
+ /// Create an empty message.
+ PN_CPP_EXTERN message();
+
+ /// Copy a message.
+ PN_CPP_EXTERN message(const message&);
+
+ /// Copy a message.
+ PN_CPP_EXTERN message& operator=(const message&);
+
+#if PN_CPP_HAS_RVALUE_REFERENCES
+ /// Move a message.
+ PN_CPP_EXTERN message(message&&);
+
+ /// Move a message.
+ PN_CPP_EXTERN message& operator=(message&&);
+#endif
+
+ /// Create a message with its body set from any value that can be
+ /// converted to a proton::value.
+ PN_CPP_EXTERN message(const value& x);
+
+ PN_CPP_EXTERN ~message();
+
+ /// @name Basic properties and methods
+ /// @{
+
+ /// Clear the message content and properties.
+ PN_CPP_EXTERN void clear();
+
+ /// Set the message ID.
+ ///
+ /// The message ID uniquely identifies a message within a
+ /// messaging system.
+ PN_CPP_EXTERN void id(const message_id&);
+
+ /// Get the message ID.
+ PN_CPP_EXTERN message_id id() const;
+
+ /// Set the user name or ID.
+ PN_CPP_EXTERN void user(const std::string&);
+
+ /// Get the user name or ID.
+ PN_CPP_EXTERN std::string user() const;
+
+ /// Encode entire message into a byte vector, growing it if
+ /// necessary.
+ PN_CPP_EXTERN void encode(std::vector<char>&) const;
+
+ /// Return encoded message as a byte vector.
+ PN_CPP_EXTERN std::vector<char> encode() const;
+
+ /// Decode from string data into the message.
+ PN_CPP_EXTERN void decode(const std::vector<char>&);
+
+ /// @}
+
+ /// @name Routing
+ /// @{
+
+ /// Set the destination address.
+ PN_CPP_EXTERN void to(const std::string&);
+
+ /// Get the destination address.
+ PN_CPP_EXTERN std::string to() const;
+
+ /// @cond INTERNAL
+ /// These are aliases for to()
+ PN_CPP_EXTERN void address(const std::string&);
+ PN_CPP_EXTERN std::string address() const;
+ /// @endcond
+
+ /// Set the address for replies.
+ PN_CPP_EXTERN void reply_to(const std::string&);
+
+ /// Get the address for replies.
+ PN_CPP_EXTERN std::string reply_to() const;
+
+ /// Set the ID for matching related messages.
+ PN_CPP_EXTERN void correlation_id(const message_id&);
+
+ /// Get the ID for matching related messages.
+ PN_CPP_EXTERN message_id correlation_id() const;
+
+ /// @}
+
+ /// @name Content
+ /// @{
+
+ /// Set the body. Equivalent to `body() = x`.
+ PN_CPP_EXTERN void body(const value& x);
+
+ /// Get the body.
+ PN_CPP_EXTERN const value& body() const;
+
+ /// Get a reference to the body that can be modified in place.
+ PN_CPP_EXTERN value& body();
+
+ /// Set the subject.
+ PN_CPP_EXTERN void subject(const std::string&);
+
+ /// Get the subject.
+ PN_CPP_EXTERN std::string subject() const;
+
+ /// Set the content type of the body.
+ PN_CPP_EXTERN void content_type(const std::string&);
+
+ /// Get the content type of the body.
+ PN_CPP_EXTERN std::string content_type() const;
+
+ /// Set the content encoding of the body.
+ PN_CPP_EXTERN void content_encoding(const std::string&);
+
+ /// Get the content encoding of the body.
+ PN_CPP_EXTERN std::string content_encoding() const;
+
+ /// Set the expiration time.
+ PN_CPP_EXTERN void expiry_time(timestamp);
+
+ /// Get the expiration time.
+ PN_CPP_EXTERN timestamp expiry_time() const;
+
+ /// Set the creation time.
+ PN_CPP_EXTERN void creation_time(timestamp);
+
+ /// Get the creation time.
+ PN_CPP_EXTERN timestamp creation_time() const;
+
+ /// Get the inferred flag.
+ ///
+ /// The inferred flag for a message indicates how the message
+ /// content is encoded into AMQP sections. If the inferred is true
+ /// then binary and list values in the body of the message will be
+ /// encoded as AMQP DATA and AMQP SEQUENCE sections,
+ /// respectively. If inferred is false, then all values in the
+ /// body of the message will be encoded as AMQP VALUE sections
+ /// regardless of their type.
+ PN_CPP_EXTERN bool inferred() const;
+
+ /// Set the inferred flag.
+ PN_CPP_EXTERN void inferred(bool);
+
+ /// @}
+
+ /// @name Transfer headers
+ /// @{
+
+ /// Get the durable flag.
+ ///
+ /// The durable flag indicates that any parties taking
+ /// responsibility for the message must durably store the content.
+ PN_CPP_EXTERN bool durable() const;
+
+ /// Set the durable flag.
+ PN_CPP_EXTERN void durable(bool);
+
+ /// Get the TTL.
+ ///
+ /// The TTL (time to live) for a message determines how long a
+ /// message is considered live. When a message is held for
+ /// retransmit, the TTL is decremented. Once the TTL reaches zero,
+ /// the message is considered dead. Once a message is considered
+ /// dead, it may be dropped.
+ PN_CPP_EXTERN duration ttl() const;
+
+ /// Set the TTL.
+ PN_CPP_EXTERN void ttl(duration);
+
+ /// Get the priority.
+ ///
+ /// The priority of a message impacts ordering guarantees. Within
+ /// a given ordered context, higher priority messages may jump
+ /// ahead of lower priority messages.
+ ///
+ /// The default value set on newly constructed messages is message::default_priority.
+ PN_CPP_EXTERN uint8_t priority() const;
+
+ /// Set the priority.
+ PN_CPP_EXTERN void priority(uint8_t);
+
+ /// Get the first acquirer flag.
+ ///
+ /// When set to true, the first acquirer flag for a message
+ /// indicates that the recipient of the message is the first
+ /// recipient to acquire the message, i.e. there have been no
+ /// failed delivery attempts to other acquirers. Note that this
+ /// does not mean the message has not been delivered to, but not
+ /// acquired, by other recipients.
+
+ // XXX The triple-not in the last sentence above is confusing.
+
+ PN_CPP_EXTERN bool first_acquirer() const;
+
+ /// Set the first acquirer flag.
+ PN_CPP_EXTERN void first_acquirer(bool);
+
+ /// Get the delivery count.
+ ///
+ /// The delivery count field tracks how many attempts have been
+ /// made to deliver a message.
+ PN_CPP_EXTERN uint32_t delivery_count() const;
+
+ /// Get the delivery count.
+ PN_CPP_EXTERN void delivery_count(uint32_t);
+
+ /// @}
+
+ /// @name Message groups
+ /// @{
+
+ /// Set the message group ID.
+ PN_CPP_EXTERN void group_id(const std::string&);
+
+ /// Get the message group ID.
+ PN_CPP_EXTERN std::string group_id() const;
+
+ /// Set the reply-to group ID.
+ PN_CPP_EXTERN void reply_to_group_id(const std::string&);
+
+ /// Get the reply-to group ID.
+ PN_CPP_EXTERN std::string reply_to_group_id() const;
+
+ /// Get the group sequence.
+ ///
+ /// The group sequence of a message identifies the relative
+ /// ordering of messages within a group. The default value for the
+ /// group sequence of a message is zero.
+ PN_CPP_EXTERN int32_t group_sequence() const;
+
+ /// Set the group sequence for a message.
+ PN_CPP_EXTERN void group_sequence(int32_t);
+
+ /// @}
+
+ /// @name Extended attributes
+ /// @{
+
+ /// Get the application properties map. It can
+ /// be modified in place.
+ PN_CPP_EXTERN property_map& properties();
+
+ /// Examine the application properties map.
+ PN_CPP_EXTERN const property_map& properties() const;
+
+ /// Get the message annotations map. It can
+ /// be modified in place.
+ PN_CPP_EXTERN annotation_map& message_annotations();
+
+ /// Examine the message annotations map.
+ PN_CPP_EXTERN const annotation_map& message_annotations() const;
+
+ /// Get the delivery annotations map. It can
+ /// be modified in place.
+ PN_CPP_EXTERN annotation_map& delivery_annotations();
+
+ /// Examine the delivery annotations map.
+ PN_CPP_EXTERN const annotation_map& delivery_annotations() const;
+
+ /// @}
+
+ /// Default priority assigned to new messages.
+ PN_CPP_EXTERN static const uint8_t default_priority;
+
+ /// @cond INTERNAL
+ private:
+ struct impl;
+ pn_message_t* pn_msg() const;
+ struct impl& impl() const;
+
+ mutable pn_message_t* pn_msg_;
+
+ PN_CPP_EXTERN friend void swap(message&, message&);
+ /// @endcond
+};
+
+} // proton
+
+#endif // PROTON_MESSAGE_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/message_id.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/message_id.hpp b/cpp/include/proton/message_id.hpp
new file mode 100644
index 0000000..517a6b0
--- /dev/null
+++ b/cpp/include/proton/message_id.hpp
@@ -0,0 +1,95 @@
+#ifndef PROTON_MESSAGE_ID_HPP
+#define PROTON_MESSAGE_ID_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./binary.hpp"
+#include "./scalar_base.hpp"
+#include "./uuid.hpp"
+
+#include <proton/type_compat.h>
+
+#include <string>
+
+/// @file
+/// @copybrief proton::message_id
+
+namespace proton {
+
+/// An AMQP message ID.
+///
+/// It can contain one of the following types:
+///
+/// - uint64_t
+/// - std::string
+/// - proton::uuid
+/// - proton::binary
+///
+class message_id : public scalar_base {
+ public:
+ /// An empty message_id.
+ message_id() {}
+
+ /// Construct from any type that can be assigned.
+ template <class T> message_id(const T& x) { *this = x; }
+
+ /// @name Assignment operators
+ /// Assign a C++ value, deduce the AMQP type()
+ ///
+ /// @{
+ message_id& operator=(uint64_t x) { put_(x); return *this; }
+ message_id& operator=(const uuid& x) { put_(x); return *this; }
+ message_id& operator=(const binary& x) { put_(x); return *this; }
+ message_id& operator=(const std::string& x) { put_(x); return *this; }
+ message_id& operator=(const char* x) { put_(x); return *this; } ///< Treated as amqp::STRING
+ /// @}
+
+ private:
+ message_id(const pn_atom_t& a): scalar_base(a) {}
+
+ ///@cond INTERNAL
+ friend class message;
+ friend class codec::decoder;
+ ///@endcond
+};
+
+/// @cond INTERNAL
+/// Base template for get(message_id), specialized for legal message_id types.
+template <class T> T get(const message_id& x);
+/// @endcond
+
+/// Get the uint64_t value or throw conversion_error. @relatedalso message_id
+template<> inline uint64_t get<uint64_t>(const message_id& x) { return internal::get<uint64_t>(x); }
+/// Get the @ref uuid value or throw conversion_error. @relatedalso message_id
+template<> inline uuid get<uuid>(const message_id& x) { return internal::get<uuid>(x); }
+/// Get the @ref binary value or throw conversion_error. @relatedalso message_id
+template<> inline binary get<binary>(const message_id& x) { return internal::get<binary>(x); }
+/// Get the std::string value or throw conversion_error. @relatedalso message_id
+template<> inline std::string get<std::string>(const message_id& x) { return internal::get<std::string>(x); }
+
+/// @copydoc scalar::coerce
+/// @relatedalso message_id
+template<class T> T coerce(const message_id& x) { return internal::coerce<T>(x); }
+
+} // proton
+
+#endif // PROTON_MESSAGE_ID_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/messaging_handler.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/messaging_handler.hpp b/cpp/include/proton/messaging_handler.hpp
new file mode 100644
index 0000000..841de7b
--- /dev/null
+++ b/cpp/include/proton/messaging_handler.hpp
@@ -0,0 +1,184 @@
+#ifndef PROTON_MESSAGING_HANDLER_HPP
+#define PROTON_MESSAGING_HANDLER_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+
+/// @file
+/// @copybrief proton::messaging_handler
+
+namespace proton {
+
+/// A handler for Proton messaging events.
+///
+/// Subclass and override the event-handling member functions.
+///
+/// #### Close and error handling
+///
+/// There are several objects that have `on_X_close` and `on_X_error`
+/// functions. They are called as follows:
+///
+/// - If `X` is closed cleanly, with no error status, then `on_X_close`
+/// is called.
+///
+/// - If `X` is closed with an error, then `on_X_error` is called,
+/// followed by `on_X_close`. The error condition is also available
+/// in `on_X_close` from `X::error()`.
+///
+/// By default, if you do not implement `on_X_error`, it will call
+/// `on_error`. If you do not implement `on_error` it will throw a
+/// `proton::error` exception, which may not be what you want but
+/// does help to identify forgotten error handling quickly.
+///
+/// #### Resource cleanup
+///
+/// Every `on_X_open` event is paired with an `on_X_close` event which
+/// can clean up any resources created by the open handler. In
+/// particular this is still true if an error is reported with an
+/// `on_X_error` event. The error-handling logic doesn't have to
+/// manage resource clean up. It can assume that the close event will
+/// be along to handle it.
+class
+PN_CPP_CLASS_EXTERN messaging_handler {
+ public:
+ PN_CPP_EXTERN messaging_handler();
+ PN_CPP_EXTERN virtual ~messaging_handler();
+
+ /// The container event loop is starting.
+ ///
+ /// This is the first event received after calling
+ /// `container::run()`.
+ PN_CPP_EXTERN virtual void on_container_start(container&);
+
+ /// The container event loop is stopping.
+ ///
+ /// This is the last event received before the container event
+ /// loop stops.
+ PN_CPP_EXTERN virtual void on_container_stop(container&);
+
+ /// A message is received.
+ PN_CPP_EXTERN virtual void on_message(delivery&, message&);
+
+ /// A message can be sent.
+ PN_CPP_EXTERN virtual void on_sendable(sender&);
+
+ /// The underlying network transport is open
+ PN_CPP_EXTERN virtual void on_transport_open(transport&);
+
+ /// The underlying network transport has closed.
+ PN_CPP_EXTERN virtual void on_transport_close(transport&);
+
+ /// The underlying network transport has closed with an error
+ /// condition.
+ PN_CPP_EXTERN virtual void on_transport_error(transport&);
+
+ /// The remote peer opened the connection.
+ PN_CPP_EXTERN virtual void on_connection_open(connection&);
+
+ /// The remote peer closed the connection.
+ PN_CPP_EXTERN virtual void on_connection_close(connection&);
+
+ /// The remote peer closed the connection with an error condition.
+ PN_CPP_EXTERN virtual void on_connection_error(connection&);
+
+ /// The remote peer opened the session.
+ PN_CPP_EXTERN virtual void on_session_open(session&);
+
+ /// The remote peer closed the session.
+ PN_CPP_EXTERN virtual void on_session_close(session&);
+
+ /// The remote peer closed the session with an error condition.
+ PN_CPP_EXTERN virtual void on_session_error(session&);
+
+ /// The remote peer opened the link.
+ PN_CPP_EXTERN virtual void on_receiver_open(receiver&);
+
+ /// The remote peer detached the link.
+ PN_CPP_EXTERN virtual void on_receiver_detach(receiver&);
+
+ /// The remote peer closed the link.
+ PN_CPP_EXTERN virtual void on_receiver_close(receiver&);
+
+ /// The remote peer closed the link with an error condition.
+ PN_CPP_EXTERN virtual void on_receiver_error(receiver&);
+
+ /// The remote peer opened the link.
+ PN_CPP_EXTERN virtual void on_sender_open(sender&);
+
+ /// The remote peer detached the link.
+ PN_CPP_EXTERN virtual void on_sender_detach(sender&);
+
+ /// The remote peer closed the link.
+ PN_CPP_EXTERN virtual void on_sender_close(sender&);
+
+ /// The remote peer closed the link with an error condition.
+ PN_CPP_EXTERN virtual void on_sender_error(sender&);
+
+ /// The receiving peer accepted a transfer.
+ PN_CPP_EXTERN virtual void on_tracker_accept(tracker&);
+
+ /// The receiving peer rejected a transfer.
+ PN_CPP_EXTERN virtual void on_tracker_reject(tracker&);
+
+ /// The receiving peer released a transfer.
+ PN_CPP_EXTERN virtual void on_tracker_release(tracker&);
+
+ /// The receiving peer settled a transfer.
+ PN_CPP_EXTERN virtual void on_tracker_settle(tracker&);
+
+ /// The sending peer settled a transfer.
+ PN_CPP_EXTERN virtual void on_delivery_settle(delivery&);
+
+ /// **Unsettled API** - The receiving peer has requested a drain of
+ /// remaining credit.
+ PN_CPP_EXTERN virtual void on_sender_drain_start(sender&);
+
+ /// **Unsettled API** - The credit outstanding at the time of the
+ /// drain request has been consumed or returned.
+ PN_CPP_EXTERN virtual void on_receiver_drain_finish(receiver&);
+
+ /// **Unsettled API** - An event that can be triggered from
+ /// another thread.
+ ///
+ /// This event is triggered by a call to `connection::wake()`. It
+ /// is used to notify the application that something needs
+ /// attention.
+ ///
+ /// **Thread-safety** - The application handler and the triggering
+ /// thread must use some form of thread-safe state or
+ /// communication to tell the handler what it needs to do. See
+ /// `proton::work_queue` for an easier way to execute code safely
+ /// in the handler thread.
+ ///
+ /// @note Spurious calls to `on_connection_wake()` can occur
+ /// without any application call to `connection::wake()`.
+ PN_CPP_EXTERN virtual void on_connection_wake(connection&);
+
+ /// Fallback error handling.
+ PN_CPP_EXTERN virtual void on_error(const error_condition&);
+};
+
+} // proton
+
+#endif // PROTON_MESSAGING_HANDLER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/namespaces.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/namespaces.hpp b/cpp/include/proton/namespaces.hpp
new file mode 100644
index 0000000..9b756a7
--- /dev/null
+++ b/cpp/include/proton/namespaces.hpp
@@ -0,0 +1,42 @@
+#ifndef PROTON_NAMESPACES_HPP
+#define PROTON_NAMESPACES_HPP
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/// @file
+/// Namespace declarations.
+
+/// The main Proton namespace.
+namespace proton {
+
+/// **Unsettled API** - AMQP data encoding and decoding.
+namespace codec {
+}
+
+/// **Unsettled API** - Interfaces for IO integration.
+namespace io {
+}
+
+namespace internal {
+}
+
+} // proton
+
+#endif // PROTON_NAMESPACES_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/null.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/null.hpp b/cpp/include/proton/null.hpp
new file mode 100644
index 0000000..849c199
--- /dev/null
+++ b/cpp/include/proton/null.hpp
@@ -0,0 +1,50 @@
+#ifndef PROTON_NULL_HPP
+#define PROTON_NULL_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/// @file
+/// @copybrief proton::null
+
+#include "./internal/config.hpp"
+#include "./internal/export.hpp"
+
+#include <iosfwd>
+
+namespace proton {
+
+/// The type of the AMQP null value
+///
+/// @see @ref types_page
+class null {
+ public:
+ null() {}
+#if PN_CPP_HAS_NULLPTR
+ null(decltype(nullptr)) {}
+#endif
+};
+
+PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const null&);
+
+}
+
+#endif // PROTON_NULL_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/receiver.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/receiver.hpp b/cpp/include/proton/receiver.hpp
new file mode 100644
index 0000000..6c8137d
--- /dev/null
+++ b/cpp/include/proton/receiver.hpp
@@ -0,0 +1,114 @@
+#ifndef PROTON_RECEIVER_HPP
+#define PROTON_RECEIVER_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./link.hpp"
+
+#include <proton/type_compat.h>
+
+struct pn_link_t;
+struct pn_session_t;
+
+/// @file
+/// @copybrief proton::receiver
+
+namespace proton {
+
+/// A channel for receiving messages.
+class
+PN_CPP_CLASS_EXTERN receiver : public link {
+ /// @cond INTERNAL
+ PN_CPP_EXTERN receiver(pn_link_t* r);
+ /// @endcond
+
+ public:
+ /// Create an empty receiver.
+ receiver() {}
+
+ /// Open the receiver.
+ ///
+ /// @see endpoint_lifecycle
+ PN_CPP_EXTERN void open();
+
+ /// @copydoc open
+ PN_CPP_EXTERN void open(const receiver_options &opts);
+
+ /// Get the source node.
+ PN_CPP_EXTERN class source source() const;
+
+ /// Get the target node.
+ PN_CPP_EXTERN class target target() const;
+
+ /// Increment the credit available to the sender. Credit granted
+ /// during a drain cycle is not communicated to the receiver until
+ /// the drain completes.
+ PN_CPP_EXTERN void add_credit(uint32_t);
+
+ /// **Unsettled API** - Commence a drain cycle. If there is
+ /// positive credit, a request is sent to the sender to
+ /// immediately use up all of the existing credit balance by
+ /// sending messages that are immediately available and releasing
+ /// any unused credit (see sender::return_credit). Throws
+ /// proton::error if a drain cycle is already in progress. An
+ /// on_receiver_drain_finish event will be generated when the
+ /// outstanding drained credit reaches zero.
+ PN_CPP_EXTERN void drain();
+
+ /// @cond INTERNAL
+ friend class internal::factory<receiver>;
+ friend class receiver_iterator;
+ /// @endcond
+};
+
+/// @cond INTERNAL
+
+/// An iterator of receivers.
+class receiver_iterator : public internal::iter_base<receiver, receiver_iterator> {
+ explicit receiver_iterator(receiver r, pn_session_t* s = 0) :
+ internal::iter_base<receiver, receiver_iterator>(r), session_(s) {}
+
+ public:
+ /// Create an iterator of receivers.
+ explicit receiver_iterator() :
+ internal::iter_base<receiver, receiver_iterator>(0), session_(0) {}
+
+ /// Advance to the next receiver.
+ PN_CPP_EXTERN receiver_iterator operator++();
+
+ private:
+ pn_session_t* session_;
+
+ friend class connection;
+ friend class session;
+};
+
+/// A range of receivers.
+typedef internal::iter_range<receiver_iterator> receiver_range;
+
+/// @endcond
+
+} // proton
+
+#endif // PROTON_RECEIVER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/receiver_options.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/receiver_options.hpp b/cpp/include/proton/receiver_options.hpp
new file mode 100644
index 0000000..2213f88
--- /dev/null
+++ b/cpp/include/proton/receiver_options.hpp
@@ -0,0 +1,119 @@
+#ifndef PROTON_RECEIVER_OPTIONS_HPP
+#define PROTON_RECEIVER_OPTIONS_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./internal/pn_unique_ptr.hpp"
+#include "./delivery_mode.hpp"
+#include <string>
+
+/// @file
+/// @copybrief proton::receiver_options
+
+namespace proton {
+
+/// Options for creating a receiver.
+///
+/// Options can be "chained" like this:
+///
+/// @code
+/// l = container.create_receiver(url, receiver_options().handler(h).auto_accept(true));
+/// @endcode
+///
+/// You can also create an options object with common settings and use
+/// it as a base for different connections that have mostly the same
+/// settings:
+///
+/// @code
+/// receiver_options opts;
+/// opts.auto_accept(true);
+/// c2 = container.open_receiver(url2, opts.handler(h2));
+/// @endcode
+///
+/// Normal value semantics: copy or assign creates a separate copy of
+/// the options.
+class receiver_options {
+ public:
+ /// Create an empty set of options.
+ PN_CPP_EXTERN receiver_options();
+
+ /// Copy options.
+ PN_CPP_EXTERN receiver_options(const receiver_options&);
+
+ PN_CPP_EXTERN ~receiver_options();
+
+ /// Copy options.
+ PN_CPP_EXTERN receiver_options& operator=(const receiver_options&);
+
+ /// Merge with another option set.
+ PN_CPP_EXTERN void update(const receiver_options& other);
+
+ /// Set a messaging_handler for receiver events only. The handler
+ /// is no longer in use when
+ /// messaging_handler::on_receiver_close() is called.
+ PN_CPP_EXTERN receiver_options& handler(class messaging_handler&);
+
+ /// Set the delivery mode on the receiver. The default is
+ /// delivery_mode::AT_LEAST_ONCE.
+ PN_CPP_EXTERN receiver_options& delivery_mode(delivery_mode);
+
+ /// Enable or disable automatic acceptance of messages that aren't
+ /// otherwise released, rejected, or modified. It is enabled by
+ /// default.
+ PN_CPP_EXTERN receiver_options& auto_accept(bool);
+
+ /// @deprecated not applicable to receiver, only to sender
+ PN_CPP_EXTERN receiver_options& auto_settle(bool);
+
+ /// Options for the source node of the receiver.
+ PN_CPP_EXTERN receiver_options& source(source_options&);
+
+ /// Options for the target node of the receiver.
+ PN_CPP_EXTERN receiver_options& target(target_options&);
+
+ /// Automatically replenish credit for flow control up to `count`
+ /// messages. The default is 10. Set to zero to disable
+ /// automatic replenishment.
+ PN_CPP_EXTERN receiver_options& credit_window(int count);
+
+ /// Set the link name. If not set a unique name is generated.
+ PN_CPP_EXTERN receiver_options& name(const std::string& name);
+
+
+ private:
+ void apply(receiver &) const;
+ const std::string* get_name() const; // Pointer to name if set, else 0
+
+ class impl;
+ internal::pn_unique_ptr<impl> impl_;
+
+ /// @cond INTERNAL
+ friend class receiver;
+ friend class session;
+ /// @endcond
+};
+
+} // proton
+
+#endif // PROTON_RECEIVER_OPTIONS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/reconnect_options.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/reconnect_options.hpp b/cpp/include/proton/reconnect_options.hpp
new file mode 100644
index 0000000..bc4e43a
--- /dev/null
+++ b/cpp/include/proton/reconnect_options.hpp
@@ -0,0 +1,93 @@
+#ifndef PROTON_RECONNECT_OPTIONS_HPP
+#define PROTON_RECONNECT_OPTIONS_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./internal/export.hpp"
+#include "./internal/pn_unique_ptr.hpp"
+#include "./duration.hpp"
+#include "./source.hpp"
+
+#include <string>
+#include <vector>
+
+/// @file
+/// @copybrief proton::reconnect_options
+
+namespace proton {
+
+/// **Unsettled API** - Options for reconnect and failover after
+/// connection loss.
+///
+/// These options determine a series of delays to coordinate
+/// reconnection attempts. They may be open-ended or limited in time.
+/// They may be evenly spaced or increasing at an exponential rate.
+///
+/// Options can be "chained". See @ref proton::connection_options.
+///
+/// Normal value semantics: copy or assign creates a separate copy of
+/// the options.
+class reconnect_options {
+ public:
+ /// Create an empty set of options.
+ PN_CPP_EXTERN reconnect_options();
+
+ /// Copy options.
+ PN_CPP_EXTERN reconnect_options(const reconnect_options&);
+
+ PN_CPP_EXTERN ~reconnect_options();
+
+ /// Copy options.
+ PN_CPP_EXTERN reconnect_options& operator=(const reconnect_options&);
+
+ /// The base value for recurring delays. The default is 10
+ /// milliseconds.
+ PN_CPP_EXTERN reconnect_options& delay(duration);
+
+ /// The scaling multiplier for successive reconnect delays. The
+ /// default is 2.0.
+ PN_CPP_EXTERN reconnect_options& delay_multiplier(float);
+
+ /// The maximum delay between successive connect attempts. The
+ /// default duration::FOREVER, meaning no limit.
+ PN_CPP_EXTERN reconnect_options& max_delay(duration);
+
+ /// The maximum number of reconnect attempts. The default is 0,
+ /// meaning no limit.
+ PN_CPP_EXTERN reconnect_options& max_attempts(int);
+
+ /// Alternative connection URLs used for failover. There are none
+ /// by default.
+ PN_CPP_EXTERN reconnect_options& failover_urls(const std::vector<std::string>& conn_urls);
+
+ private:
+ class impl;
+ internal::pn_unique_ptr<impl> impl_;
+
+ /// @cond INTERNAL
+ friend class container;
+ /// @endcond
+};
+
+} // proton
+
+#endif // PROTON_RECONNECT_OPTIONS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/returned.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/returned.hpp b/cpp/include/proton/returned.hpp
new file mode 100644
index 0000000..52ecba7
--- /dev/null
+++ b/cpp/include/proton/returned.hpp
@@ -0,0 +1,70 @@
+#ifndef PROTON_RETURNED_HPP
+#define PROTON_RETURNED_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./internal/export.hpp"
+#include "./internal/object.hpp"
+
+#include "./connection.hpp"
+#include "./receiver.hpp"
+#include "./sender.hpp"
+
+/// @file
+/// @copybrief proton::returned
+
+namespace proton {
+
+namespace internal {
+class returned_factory;
+}
+
+/// A return type for container methods.
+///
+/// **Thread safety** - Container method return values are
+/// *thread-unsafe*. A single-threaded application can safely assign
+/// the `returned<T>` value to a plain `T`. A multithreaded
+/// application *must* ignore the returned value because it may
+/// already be invalid by the time the function returns.
+/// Multithreaded applications can safely access the value inside @ref
+/// messaging_handler functions.
+template <class T>
+class PN_CPP_CLASS_EXTERN returned {
+ public:
+ /// Copy operator required to return a value
+ PN_CPP_EXTERN returned(const returned<T>&);
+
+ /// Convert to the proton::object
+ ///
+ /// @note **Thread-unsafe** - Do not use in a multithreaded application.
+ PN_CPP_EXTERN operator T() const;
+
+ private:
+ typename T::pn_type* ptr_;
+ returned(typename T::pn_type*);
+ returned& operator=(const returned&); // Not defined
+ friend class internal::returned_factory;
+};
+
+} // proton
+
+#endif /*!PROTON_RETURNED_HPP*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/sasl.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/sasl.hpp b/cpp/include/proton/sasl.hpp
new file mode 100644
index 0000000..a054086
--- /dev/null
+++ b/cpp/include/proton/sasl.hpp
@@ -0,0 +1,80 @@
+#ifndef PROTON_SASL_HPP
+#define PROTON_SASL_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./internal/export.hpp"
+#include "./internal/config.hpp"
+#include "./internal/object.hpp"
+
+#include <proton/sasl.h>
+
+#include <string>
+
+/// @file
+/// @copybrief proton::sasl
+
+namespace proton {
+
+/// SASL information.
+class sasl {
+ /// @cond INTERNAL
+ sasl(pn_sasl_t* s) : object_(s) {}
+ /// @endcond
+
+#if PN_CPP_HAS_DELETED_FUNCTIONS
+ sasl() = delete;
+#else
+ sasl();
+#endif
+
+ public:
+ /// The result of the SASL negotiation.
+ enum outcome {
+ NONE = PN_SASL_NONE, ///< Negotiation not completed
+ OK = PN_SASL_OK, ///< Authentication succeeded
+ AUTH = PN_SASL_AUTH, ///< Failed due to bad credentials
+ SYS = PN_SASL_SYS, ///< Failed due to a system error
+ PERM = PN_SASL_PERM, ///< Failed due to unrecoverable error
+ TEMP = PN_SASL_TEMP ///< Failed due to transient error
+ };
+
+ /// Get the outcome.
+ PN_CPP_EXTERN enum outcome outcome() const;
+
+ /// Get the user name.
+ PN_CPP_EXTERN std::string user() const;
+
+ /// Get the mechanism.
+ PN_CPP_EXTERN std::string mech() const;
+
+ /// @cond INTERNAL
+ private:
+ pn_sasl_t* const object_;
+
+ friend class transport;
+ /// @endcond
+};
+
+} // proton
+
+#endif // PROTON_SASL_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/scalar.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/scalar.hpp b/cpp/include/proton/scalar.hpp
new file mode 100644
index 0000000..b1dd8b1
--- /dev/null
+++ b/cpp/include/proton/scalar.hpp
@@ -0,0 +1,89 @@
+#ifndef PROTON_SCALAR_HPP
+#define PROTON_SCALAR_HPP
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "./scalar_base.hpp"
+
+#include "proton/null.hpp"
+
+#include <proton/type_compat.h>
+
+/// @file
+/// @copybrief proton::scalar
+
+namespace proton {
+
+/// A holder for an instance of any scalar AMQP type.
+///
+/// @see @ref types_page
+class scalar : public scalar_base {
+ public:
+ /// Create an empty scalar.
+ PN_CPP_EXTERN scalar() {}
+
+ /// Construct from any scalar type.
+ template <class T> scalar(const T& x) { *this = x; }
+
+ /// Assign from any scalar type.
+ template <class T> scalar& operator=(const T& x) { put(x); return *this; }
+
+ /// Clear the scalar, making it empty().
+ void clear() { *this = null(); }
+};
+
+/// Get a contained value of type T. For example:
+///
+/// uint64_t i = get<uint64_t>(x)
+///
+/// This will succeed if and only if x contains a uint64_t value.
+///
+/// @throw conversion_error if contained value is not of type T.
+/// @relatedalso scalar
+template<class T> T get(const scalar& s) { return internal::get<T>(s); }
+
+/// Coerce the contained value to type T. For example:
+///
+/// uint64_t i = coerce<uint64_t>(x)
+///
+/// This will succeed if x contains any numeric value, but may lose
+/// precision if it contains a float or double value.
+///
+/// @throw conversion_error if the value cannot be converted to T
+/// according to `std::is_convertible`
+/// @relatedalso scalar
+template<class T> T coerce(const scalar& x) { return internal::coerce<T>(x); }
+
+
+/// Coerce the contained value to type T. For example:
+///
+/// uint64_t i = coerce<uint64_t>(x)
+///
+/// This will succeed if x contains any numeric value, but may lose
+/// precision if it contains a float or double value.
+///
+/// @throw conversion_error if the value cannot be converted to T
+/// according to `std::is_convertible`
+/// @relatedalso scalar
+template<class T> T coerce(scalar& x) { return internal::coerce<T>(x); }
+
+} // proton
+
+#endif // PROTON_SCALAR_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/scalar_base.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/scalar_base.hpp b/cpp/include/proton/scalar_base.hpp
new file mode 100644
index 0000000..c88f0a8
--- /dev/null
+++ b/cpp/include/proton/scalar_base.hpp
@@ -0,0 +1,218 @@
+#ifndef PROTON_SCALAR_BASE_HPP
+#define PROTON_SCALAR_BASE_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./binary.hpp"
+#include "./decimal.hpp"
+#include "./error.hpp"
+#include "./internal/comparable.hpp"
+#include "./internal/export.hpp"
+#include "./internal/type_traits.hpp"
+#include "./symbol.hpp"
+#include "./timestamp.hpp"
+#include "./type_id.hpp"
+#include "./types_fwd.hpp"
+#include "./uuid.hpp"
+
+#include <proton/type_compat.h>
+
+#include <iosfwd>
+#include <string>
+#include <typeinfo>
+
+/// @file
+/// @copybrief proton::scalar_base
+
+namespace proton {
+
+class scalar_base;
+
+namespace codec {
+class decoder;
+class encoder;
+}
+
+namespace internal {
+template<class T> T get(const scalar_base& s);
+}
+
+/// The base class for scalar types.
+class scalar_base : private internal::comparable<scalar_base> {
+ public:
+ /// AMQP type of data stored in the scalar
+ PN_CPP_EXTERN type_id type() const;
+
+ /// True if there is no value, i.e. type() == NULL_TYPE.
+ PN_CPP_EXTERN bool empty() const;
+
+ /// Compare
+ friend PN_CPP_EXTERN bool operator<(const scalar_base& x, const scalar_base& y);
+ /// Compare
+ friend PN_CPP_EXTERN bool operator==(const scalar_base& x, const scalar_base& y);
+ /// Print the contained value
+ friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream& o, const scalar_base& x);
+
+ protected:
+ PN_CPP_EXTERN scalar_base(const pn_atom_t& a);
+ PN_CPP_EXTERN scalar_base();
+ PN_CPP_EXTERN scalar_base(const scalar_base&);
+ PN_CPP_EXTERN scalar_base& operator=(const scalar_base&);
+
+ PN_CPP_EXTERN void put_(bool);
+ PN_CPP_EXTERN void put_(uint8_t);
+ PN_CPP_EXTERN void put_(int8_t);
+ PN_CPP_EXTERN void put_(uint16_t);
+ PN_CPP_EXTERN void put_(int16_t);
+ PN_CPP_EXTERN void put_(uint32_t);
+ PN_CPP_EXTERN void put_(int32_t);
+ PN_CPP_EXTERN void put_(uint64_t);
+ PN_CPP_EXTERN void put_(int64_t);
+ PN_CPP_EXTERN void put_(wchar_t);
+ PN_CPP_EXTERN void put_(float);
+ PN_CPP_EXTERN void put_(double);
+ PN_CPP_EXTERN void put_(timestamp);
+ PN_CPP_EXTERN void put_(const decimal32&);
+ PN_CPP_EXTERN void put_(const decimal64&);
+ PN_CPP_EXTERN void put_(const decimal128&);
+ PN_CPP_EXTERN void put_(const uuid&);
+ PN_CPP_EXTERN void put_(const std::string&);
+ PN_CPP_EXTERN void put_(const symbol&);
+ PN_CPP_EXTERN void put_(const binary&);
+ PN_CPP_EXTERN void put_(const char* s); ///< Treated as an AMQP string
+ PN_CPP_EXTERN void put_(const null&);
+
+ template<class T> void put(const T& x) { putter<T>::put(*this, x); }
+
+ private:
+ PN_CPP_EXTERN void get_(bool&) const;
+ PN_CPP_EXTERN void get_(uint8_t&) const;
+ PN_CPP_EXTERN void get_(int8_t&) const;
+ PN_CPP_EXTERN void get_(uint16_t&) const;
+ PN_CPP_EXTERN void get_(int16_t&) const;
+ PN_CPP_EXTERN void get_(uint32_t&) const;
+ PN_CPP_EXTERN void get_(int32_t&) const;
+ PN_CPP_EXTERN void get_(uint64_t&) const;
+ PN_CPP_EXTERN void get_(int64_t&) const;
+ PN_CPP_EXTERN void get_(wchar_t&) const;
+ PN_CPP_EXTERN void get_(float&) const;
+ PN_CPP_EXTERN void get_(double&) const;
+ PN_CPP_EXTERN void get_(timestamp&) const;
+ PN_CPP_EXTERN void get_(decimal32&) const;
+ PN_CPP_EXTERN void get_(decimal64&) const;
+ PN_CPP_EXTERN void get_(decimal128&) const;
+ PN_CPP_EXTERN void get_(uuid&) const;
+ PN_CPP_EXTERN void get_(std::string&) const;
+ PN_CPP_EXTERN void get_(symbol&) const;
+ PN_CPP_EXTERN void get_(binary&) const;
+ PN_CPP_EXTERN void get_(null&) const;
+
+ // use template structs, functions cannot be partially specialized.
+ template <class T, class Enable=void> struct putter {
+ static void put(scalar_base& s, const T& x) { s.put_(x); }
+ };
+ template <class T>
+ struct putter<T, typename internal::enable_if<internal::is_unknown_integer<T>::value>::type> {
+ static void put(scalar_base& s, const T& x) {
+ s.put_(static_cast<typename internal::known_integer<T>::type>(x));
+ }
+ };
+ template <class T, class Enable=void>
+ struct getter {
+ static T get(const scalar_base& s) { T x; s.get_(x); return x; }
+ };
+ template <class T>
+ struct getter<T, typename internal::enable_if<internal::is_unknown_integer<T>::value>::type> {
+ static T get(const scalar_base& s) {
+ typename internal::known_integer<T>::type x; s.get_(x); return x;
+ }
+ };
+
+ void ok(pn_type_t) const;
+ void set(const pn_atom_t&);
+ void set(const binary& x, pn_type_t t);
+
+ pn_atom_t atom_;
+ binary bytes_; // Hold binary data.
+
+ /// @cond INTERNAL
+ friend class message;
+ friend class codec::encoder;
+ friend class codec::decoder;
+ template<class T> friend T internal::get(const scalar_base& s);
+ /// @endcond
+};
+
+namespace internal {
+
+template<class T> T get(const scalar_base& s) {
+ return scalar_base::getter<T>::get(s);
+}
+
+template <class R, class F> R visit(const scalar_base& s, F f) {
+ switch(s.type()) {
+ case BOOLEAN: return f(internal::get<bool>(s));
+ case UBYTE: return f(internal::get<uint8_t>(s));
+ case BYTE: return f(internal::get<int8_t>(s));
+ case USHORT: return f(internal::get<uint16_t>(s));
+ case SHORT: return f(internal::get<int16_t>(s));
+ case UINT: return f(internal::get<uint32_t>(s));
+ case INT: return f(internal::get<int32_t>(s));
+ case CHAR: return f(internal::get<wchar_t>(s));
+ case ULONG: return f(internal::get<uint64_t>(s));
+ case LONG: return f(internal::get<int64_t>(s));
+ case TIMESTAMP: return f(internal::get<timestamp>(s));
+ case FLOAT: return f(internal::get<float>(s));
+ case DOUBLE: return f(internal::get<double>(s));
+ case DECIMAL32: return f(internal::get<decimal32>(s));
+ case DECIMAL64: return f(internal::get<decimal64>(s));
+ case DECIMAL128: return f(internal::get<decimal128>(s));
+ case UUID: return f(internal::get<uuid>(s));
+ case BINARY: return f(internal::get<binary>(s));
+ case STRING: return f(internal::get<std::string>(s));
+ case SYMBOL: return f(internal::get<symbol>(s));
+ default: throw conversion_error("invalid scalar type "+type_name(s.type()));
+ }
+}
+
+PN_CPP_EXTERN conversion_error make_coercion_error(const char* cpp_type, type_id amqp_type);
+
+template<class T> struct coerce_op {
+ template <class U>
+ typename enable_if<is_convertible<U, T>::value, T>::type operator()(const U& x) {
+ return static_cast<T>(x);
+ }
+ template <class U>
+ typename enable_if<!is_convertible<U, T>::value, T>::type operator()(const U&) {
+ throw make_coercion_error(typeid(T).name(), type_id_of<U>::value);
+ }
+};
+
+template <class T> T coerce(const scalar_base& s) { return visit<T>(s, coerce_op<T>()); }
+} // namespace internal
+
+/// Return a readable string representation of x for display purposes.
+PN_CPP_EXTERN std::string to_string(const scalar_base& x);
+
+} // proton
+
+#endif // PROTON_SCALAR_BASE_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/sender.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/sender.hpp b/cpp/include/proton/sender.hpp
new file mode 100644
index 0000000..840032c
--- /dev/null
+++ b/cpp/include/proton/sender.hpp
@@ -0,0 +1,108 @@
+#ifndef PROTON_SENDER_HPP
+#define PROTON_SENDER_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./link.hpp"
+#include "./tracker.hpp"
+
+/// @file
+/// @copybrief proton::sender
+
+struct pn_link_t;
+struct pn_session_t;
+
+namespace proton {
+
+/// A channel for sending messages.
+class
+PN_CPP_CLASS_EXTERN sender : public link {
+ /// @cond INTERNAL
+ PN_CPP_EXTERN sender(pn_link_t* s);
+ /// @endcond
+
+ public:
+ /// Create an empty sender.
+ sender() {}
+
+ /// Open the sender.
+ ///
+ /// @see endpoint_lifecycle
+ PN_CPP_EXTERN void open();
+
+ /// @copydoc open
+ PN_CPP_EXTERN void open(const sender_options &opts);
+
+ /// Send a message on the sender.
+ PN_CPP_EXTERN tracker send(const message &m);
+
+ /// Get the source node.
+ PN_CPP_EXTERN class source source() const;
+
+ /// Get the target node.
+ PN_CPP_EXTERN class target target() const;
+
+ /// **Unsettled API** - Return all unused credit to the receiver in
+ /// response to a drain request. Has no effect unless there has
+ /// been a drain request and there is remaining credit to use or
+ /// return.
+ ///
+ /// @see receiver::drain
+ PN_CPP_EXTERN void return_credit();
+
+ /// @cond INTERNAL
+ friend class internal::factory<sender>;
+ friend class sender_iterator;
+ /// @endcond
+};
+
+/// @cond INTERNAL
+
+/// An iterator of senders.
+class sender_iterator : public internal::iter_base<sender, sender_iterator> {
+ sender_iterator(sender snd, pn_session_t* s = 0) :
+ internal::iter_base<sender, sender_iterator>(snd), session_(s) {}
+
+ public:
+ /// Create an iterator of senders.
+ sender_iterator() :
+ internal::iter_base<sender, sender_iterator>(0), session_(0) {}
+ /// Advance to the next sender.
+ PN_CPP_EXTERN sender_iterator operator++();
+
+ private:
+ pn_session_t* session_;
+
+ friend class connection;
+ friend class session;
+};
+
+/// A range of senders.
+typedef internal::iter_range<sender_iterator> sender_range;
+
+/// @endcond
+
+}
+
+#endif // PROTON_SENDER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/sender_options.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/sender_options.hpp b/cpp/include/proton/sender_options.hpp
new file mode 100644
index 0000000..970da7e
--- /dev/null
+++ b/cpp/include/proton/sender_options.hpp
@@ -0,0 +1,109 @@
+#ifndef PROTON_SENDER_OPTIONS_HPP
+#define PROTON_SENDER_OPTIONS_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./internal/pn_unique_ptr.hpp"
+#include "./delivery_mode.hpp"
+#include <string>
+
+/// @file
+/// @copybrief proton::sender_options
+
+namespace proton {
+
+/// Options for creating a sender.
+///
+/// Options can be "chained" like this:
+///
+/// @code
+/// l = container.create_sender(url, sender_options().handler(h).auto_settle(false));
+/// @endcode
+///
+/// You can also create an options object with common settings and use
+/// it as a base for different connections that have mostly the same
+/// settings:
+///
+/// @code
+/// sender_options opts;
+/// opts.delivery_mode(delivery_mode::AT_MOST_ONCE);
+/// l1 = container.open_sender(url1, opts.handler(h1));
+/// c2 = container.open_receiver(url2, opts.handler(h2));
+/// @endcode
+///
+/// Normal value semantics: copy or assign creates a separate copy of
+/// the options.
+class sender_options {
+ public:
+ /// Create an empty set of options.
+ PN_CPP_EXTERN sender_options();
+
+ /// Copy options.
+ PN_CPP_EXTERN sender_options(const sender_options&);
+
+ PN_CPP_EXTERN ~sender_options();
+
+ /// Copy options.
+ PN_CPP_EXTERN sender_options& operator=(const sender_options&);
+
+ /// Merge with another option set
+ PN_CPP_EXTERN void update(const sender_options& other);
+
+ /// Set a messaging_handler for sender events only.
+ /// The handler is no longer in use when messaging_handler::on_sender_close() is called.
+ /// messaging_handler::on_sender_close() may not be called if a connection is aborted,
+ /// in that case it should be cleaned up in its connection's messaging_handler::on_transport_close()
+ PN_CPP_EXTERN sender_options& handler(class messaging_handler&);
+
+ /// Set the delivery mode on the sender.
+ PN_CPP_EXTERN sender_options& delivery_mode(delivery_mode);
+
+ /// Automatically settle messages (default is true).
+ PN_CPP_EXTERN sender_options& auto_settle(bool);
+
+ /// Options for the source node of the sender.
+ PN_CPP_EXTERN sender_options& source(const source_options&);
+
+ /// Options for the receiver node of the receiver.
+ PN_CPP_EXTERN sender_options& target(const target_options&);
+
+ /// Set the link name. If not set a unique name is generated.
+ PN_CPP_EXTERN sender_options& name(const std::string& name);
+
+ private:
+ void apply(sender&) const;
+ const std::string* get_name() const; // Pointer to name if set, else 0
+
+ class impl;
+ internal::pn_unique_ptr<impl> impl_;
+
+ /// @cond INTERNAL
+ friend class sender;
+ friend class session;
+ /// @endcond
+};
+
+} // proton
+
+#endif // PROTON_SENDER_OPTIONS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/session.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/session.hpp b/cpp/include/proton/session.hpp
new file mode 100644
index 0000000..78a1fd4
--- /dev/null
+++ b/cpp/include/proton/session.hpp
@@ -0,0 +1,126 @@
+#ifndef PROTON_SESSION_HPP
+#define PROTON_SESSION_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./endpoint.hpp"
+#include "./receiver.hpp"
+#include "./sender.hpp"
+
+#include <string>
+
+/// @file
+/// @copybrief proton::session
+
+struct pn_session_t;
+
+namespace proton {
+
+/// A container of senders and receivers.
+class
+PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endpoint {
+ public:
+ /// @cond INTERNAL
+ PN_CPP_EXTERN session(pn_session_t* s) : internal::object<pn_session_t>(s) {}
+ /// @endcond
+
+ public:
+ /// Create an empty session.
+ session() : internal::object<pn_session_t>(0) {}
+
+ PN_CPP_EXTERN bool uninitialized() const;
+ PN_CPP_EXTERN bool active() const;
+ PN_CPP_EXTERN bool closed() const;
+
+ PN_CPP_EXTERN class error_condition error() const;
+
+ /// Open the session.
+ ///
+ /// @see endpoint_lifecycle
+ PN_CPP_EXTERN void open();
+
+ /// @copydoc open
+ PN_CPP_EXTERN void open(const session_options &opts);
+
+ PN_CPP_EXTERN void close();
+ PN_CPP_EXTERN void close(const error_condition&);
+
+ /// Get the container for this session.
+ PN_CPP_EXTERN class container &container() const;
+
+ /// Get the work_queue for the session.
+ PN_CPP_EXTERN class work_queue& work_queue() const;
+
+ /// Get the connection this session belongs to.
+ PN_CPP_EXTERN class connection connection() const;
+
+ /// Open a sender for `addr`.
+ PN_CPP_EXTERN sender open_sender(const std::string &addr);
+
+ /// @copydoc open_sender
+ PN_CPP_EXTERN sender open_sender(const std::string &addr, const sender_options &opts);
+
+ /// Open a receiver for `addr`.
+ PN_CPP_EXTERN receiver open_receiver(const std::string &addr);
+
+ /// @copydoc open_receiver
+ PN_CPP_EXTERN receiver open_receiver(const std::string &addr, const receiver_options &opts);
+
+ /// The number of incoming bytes currently buffered.
+ PN_CPP_EXTERN size_t incoming_bytes() const;
+
+ /// The number of outgoing bytes currently buffered.
+ PN_CPP_EXTERN size_t outgoing_bytes() const;
+
+ /// Return the senders on this session.
+ PN_CPP_EXTERN sender_range senders() const;
+
+ /// Return the receivers on this session.
+ PN_CPP_EXTERN receiver_range receivers() const;
+
+ /// @cond INTERNAL
+ friend class internal::factory<session>;
+ friend class session_iterator;
+ /// @endcond
+};
+
+/// @cond INTERNAL
+
+/// An iterator of sessions.
+class session_iterator : public internal::iter_base<session, session_iterator> {
+ public:
+ explicit session_iterator(session s = 0) : internal::iter_base<session, session_iterator>(s) {}
+
+ /// Advance to the next session.
+ PN_CPP_EXTERN session_iterator operator++();
+};
+
+/// A range of sessions.
+typedef internal::iter_range<session_iterator> session_range;
+
+/// @endcond
+
+} // proton
+
+#endif // PROTON_SESSION_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37136940/cpp/include/proton/session_options.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/session_options.hpp b/cpp/include/proton/session_options.hpp
new file mode 100644
index 0000000..515a798
--- /dev/null
+++ b/cpp/include/proton/session_options.hpp
@@ -0,0 +1,71 @@
+#ifndef PROTON_SESSION_OPTIONS_HPP
+#define PROTON_SESSION_OPTIONS_HPP
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./internal/pn_unique_ptr.hpp"
+
+/// @file
+/// @copybrief proton::session_options
+
+namespace proton {
+
+/// Options for creating a session.
+///
+/// Options can be "chained" (see proton::connection_options).
+///
+/// Normal value semantics: copy or assign creates a separate copy of
+/// the options.
+class session_options {
+ public:
+ /// Create an empty set of options.
+ PN_CPP_EXTERN session_options();
+
+ /// Copy options.
+ PN_CPP_EXTERN session_options(const session_options&);
+
+ PN_CPP_EXTERN ~session_options();
+
+ /// Copy options.
+ PN_CPP_EXTERN session_options& operator=(const session_options&);
+
+ /// Set a messaging_handler for the session.
+ PN_CPP_EXTERN session_options& handler(class messaging_handler &);
+
+ // Other useful session configuration TBD.
+
+ /// @cond INTERNAL
+ private:
+ void apply(session&) const;
+
+ class impl;
+ internal::pn_unique_ptr<impl> impl_;
+
+ friend class session;
+ /// @endcond
+};
+
+} // proton
+
+#endif // PROTON_SESSION_OPTIONS_HPP
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org