http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/internal/type_traits.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/internal/type_traits.hpp b/proton-c/bindings/cpp/include/proton/internal/type_traits.hpp new file mode 100644 index 0000000..3798cee --- /dev/null +++ b/proton-c/bindings/cpp/include/proton/internal/type_traits.hpp @@ -0,0 +1,153 @@ +#ifndef PROTON_INTERNAL_TYPE_TRAITS_HPP +#define PROTON_INTERNAL_TYPE_TRAITS_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 +/// +/// Internal: Type traits for mapping between AMQP and C++ types. +/// +/// Also provides workarounds for missing type_traits classes on older +/// C++ compilers. + +#include "proton/config.hpp" +#include "proton/types_fwd.hpp" +#include "proton/type_id.hpp" + +namespace proton { +namespace internal { + +class decoder; +class encoder; + +template <bool, class T=void> struct enable_if {}; +template <class T> struct enable_if<true, T> { typedef T type; }; + +struct true_type { static const bool value = true; }; +struct false_type { static const bool value = false; }; + +template <class T> struct is_integral : public false_type {}; +template <class T> struct is_signed : public false_type {}; + +template <> struct is_integral<char> : public true_type {}; +template <> struct is_signed<char> : public false_type {}; + +template <> struct is_integral<unsigned char> : public true_type {}; +template <> struct is_integral<unsigned short> : public true_type {}; +template <> struct is_integral<unsigned int> : public true_type {}; +template <> struct is_integral<unsigned long> : public true_type {}; + +template <> struct is_integral<signed char> : public true_type {}; +template <> struct is_integral<signed short> : public true_type {}; +template <> struct is_integral<signed int> : public true_type {}; +template <> struct is_integral<signed long> : public true_type {}; + +template <> struct is_signed<unsigned short> : public false_type {}; +template <> struct is_signed<unsigned int> : public false_type {}; +template <> struct is_signed<unsigned long> : public false_type {}; + +template <> struct is_signed<signed char> : public true_type {}; +template <> struct is_signed<signed short> : public true_type {}; +template <> struct is_signed<signed int> : public true_type {}; +template <> struct is_signed<signed long> : public true_type {}; + +#if PN_CPP_HAS_LONG_LONG +template <> struct is_integral<unsigned long long> : public true_type {}; +template <> struct is_integral<signed long long> : public true_type {}; +template <> struct is_signed<unsigned long long> : public false_type {}; +template <> struct is_signed<signed long long> : public true_type {}; +#endif + +template <class T, class U> struct is_same { static const bool value=false; }; +template <class T> struct is_same<T,T> { static const bool value=true; }; + +template< class T > struct remove_const { typedef T type; }; +template< class T > struct remove_const<const T> { typedef T type; }; + +template <type_id ID, class T> struct type_id_constant { + typedef T type; + static const type_id value = ID; +}; + +/// @name Metafunction returning AMQP type for scalar C++ types. +/// @{ +template <class T> struct type_id_of; +template<> struct type_id_of<bool> : public type_id_constant<BOOLEAN, bool> {}; +template<> struct type_id_of<uint8_t> : public type_id_constant<UBYTE, uint8_t> {}; +template<> struct type_id_of<int8_t> : public type_id_constant<BYTE, int8_t> {}; +template<> struct type_id_of<uint16_t> : public type_id_constant<USHORT, uint16_t> {}; +template<> struct type_id_of<int16_t> : public type_id_constant<SHORT, int16_t> {}; +template<> struct type_id_of<uint32_t> : public type_id_constant<UINT, uint32_t> {}; +template<> struct type_id_of<int32_t> : public type_id_constant<INT, int32_t> {}; +template<> struct type_id_of<uint64_t> : public type_id_constant<ULONG, uint64_t> {}; +template<> struct type_id_of<int64_t> : public type_id_constant<LONG, int64_t> {}; +template<> struct type_id_of<wchar_t> : public type_id_constant<CHAR, wchar_t> {}; +template<> struct type_id_of<float> : public type_id_constant<FLOAT, float> {}; +template<> struct type_id_of<double> : public type_id_constant<DOUBLE, double> {}; +template<> struct type_id_of<timestamp> : public type_id_constant<TIMESTAMP, timestamp> {}; +template<> struct type_id_of<decimal32> : public type_id_constant<DECIMAL32, decimal32> {}; +template<> struct type_id_of<decimal64> : public type_id_constant<DECIMAL64, decimal64> {}; +template<> struct type_id_of<decimal128> : public type_id_constant<DECIMAL128, decimal128> {}; +template<> struct type_id_of<uuid> : public type_id_constant<UUID, uuid> {}; +template<> struct type_id_of<std::string> : public type_id_constant<STRING, std::string> {}; +template<> struct type_id_of<symbol> : public type_id_constant<SYMBOL, symbol> {}; +template<> struct type_id_of<binary> : public type_id_constant<BINARY, binary> {}; +/// @} + +/// Metafunction to test if a class has a type_id. +template <class T, class Enable=void> struct has_type_id : public false_type {}; +template <class T> struct has_type_id<T, typename type_id_of<T>::type> : public true_type {}; + +// Map arbitrary integral types to known AMQP integral types. +template<size_t SIZE, bool IS_SIGNED> struct integer_type; +template<> struct integer_type<1, true> { typedef int8_t type; }; +template<> struct integer_type<2, true> { typedef int16_t type; }; +template<> struct integer_type<4, true> { typedef int32_t type; }; +template<> struct integer_type<8, true> { typedef int64_t type; }; +template<> struct integer_type<1, false> { typedef uint8_t type; }; +template<> struct integer_type<2, false> { typedef uint16_t type; }; +template<> struct integer_type<4, false> { typedef uint32_t type; }; +template<> struct integer_type<8, false> { typedef uint64_t type; }; + +// True if T is an integer type that does not have an explicit type_id. +template <class T> struct is_unknown_integer { + static const bool value = !has_type_id<T>::value && is_integral<T>::value; +}; + +// Helper base for SFINAE test templates. +struct sfinae { + typedef char yes; + typedef double no; + struct wildcard { wildcard(...); }; +}; + +template <class From, class To> struct is_convertible : public sfinae { + static yes test(const To&); + static no test(...); + static const From& from; + static bool const value = sizeof(test(from)) == sizeof(yes); +}; + +} // internal +} // proton + +#endif // PROTON_INTERNAL_TYPE_TRAITS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp b/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp index 8b8838f..c66db5e 100644 --- a/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp +++ b/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp @@ -1,7 +1,8 @@ -#ifndef CONNECTION_ENGINE_HPP -#define CONNECTION_ENGINE_HPP +#ifndef PROTON_IO_CONNECTION_ENGINE_HPP +#define PROTON_IO_CONNECTION_ENGINE_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 @@ -18,6 +19,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ #include "proton/config.hpp" @@ -26,7 +28,7 @@ #include "proton/error.hpp" #include "proton/error_condition.hpp" #include "proton/export.hpp" -#include "proton/pn_unique_ptr.hpp" +#include "proton/internal/pn_unique_ptr.hpp" #include "proton/transport.hpp" #include "proton/types.hpp" @@ -43,26 +45,11 @@ class proton_handler; // FIXME aconway 2016-05-04: doc -/** @page integration - -This namespace contains a low-level "Service Provider Interface" that can be -used to implement the proton API over any native or 3rd party IO library. - -The io::connection_engine is the core engine that converts raw AMQP bytes read -from any IO source into proton::handler event calls, and generates AMQP -byte-encoded output that can be written to any IO destination. - -The integration needs to implement two user-visible interfaces: - - proton::container lets the user initiate or listen for connections. - - proton::event_loop lets the user serialize their own work with a connection. - - @see epoll_container.cpp for an example of an integration. -*/ namespace io { class link_namer; -/// Pointer to a mutable memory region with a size. +/// **Experimental** - 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. @@ -71,7 +58,7 @@ struct mutable_buffer { mutable_buffer(char* data_=0, size_t size_=0) : data(data_), size(size_) {} }; -/// Pointer to a const memory region with a size. +/// **Experimental** - Pointer to a const 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. @@ -80,34 +67,38 @@ struct const_buffer { const_buffer(const char* data_=0, size_t size_=0) : data(data_), size(size_) {} }; -/// A protocol engine to integrate AMQP into any IO or concurrency framework. +/// **Experimental** - An AMQP protocol engine for a single +/// connection. +/// +/// A connection_engine is a protocol engine that integrates AMQP into +/// any IO or concurrency framework. /// /// io::connection_engine manages a single proton::connection and dispatches /// events to a proton::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::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_engine, the -/// \ref broker.cpp example illustrates this. +/// 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_engine. 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::handler. You write output data from the engines -/// write_buffer() to your IO. +/// 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::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 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 etc.) +/// 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_engine { public: @@ -209,6 +200,7 @@ PN_CPP_CLASS_EXTERN connection_engine { proton::container& container_; }; -}} +} // io +} // proton -#endif // CONNECTION_ENGINE_HPP +#endif // PROTON_IO_CONNECTION_ENGINE_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp b/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp index d3fd74a..858102e 100644 --- a/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp +++ b/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp @@ -2,6 +2,7 @@ #define PROTON_IO_CONTAINER_IMPL_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 @@ -18,10 +19,11 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ -#include <proton/io/link_namer.hpp> -#include <proton/container.hpp> +#include "proton/io/link_namer.hpp" +#include "proton/container.hpp" #include <mutex> #include <sstream> @@ -29,53 +31,70 @@ namespace proton { namespace io { -/// Thread-safe partial implementation of proton::container interface to reduce -/// boilerplate code in container implementations. Requires C++11. +/// **Experimental** - A base container implementation. /// -/// You can ignore this class if you want to implement the functions in a -/// different way. +/// This is a thread-safe partial implementation of the +/// proton::container interface to reduce boilerplate code in +/// container implementations. Requires C++11. /// +/// You can ignore this class if you want to implement the functions +/// in a different way. class container_impl_base : public container { public: - + /// @copydoc container::client_connection_options void client_connection_options(const connection_options & opts) { store(client_copts_, opts); } + + /// @copydoc container::client_connection_options connection_options client_connection_options() const { return load(client_copts_); } + + /// @copydoc container::server_connection_options void server_connection_options(const connection_options & opts) { store(server_copts_, opts); } + + /// @copydoc container::server_connection_options connection_options server_connection_options() const { return load(server_copts_); } + + /// @copydoc container::sender_options void sender_options(const class sender_options & opts) { store(sender_opts_, opts); } + + /// @copydoc container::sender_options class sender_options sender_options() const { return load(sender_opts_); } + + /// @copydoc container::receiver_options void receiver_options(const class receiver_options & opts) { store(receiver_opts_, opts); } + + /// @copydoc container::receiver_options class receiver_options receiver_options() const { return load(receiver_opts_); } + /// @copydoc container::open_sender returned<sender> open_sender( const std::string &url, const class sender_options &opts, const connection_options &copts) { return open_link<sender, class sender_options>(url, opts, copts, &connection::open_sender); } + /// @copydoc container::open_receiver returned<receiver> open_receiver( const std::string &url, const class receiver_options &opts, const connection_options &copts) { return open_link<receiver>(url, opts, copts, &connection::open_receiver); } - private: template<class T, class Opts> returned<T> open_link( @@ -115,6 +134,7 @@ class container_impl_base : public container { class sender_options sender_opts_; }; -}} +} // io +} // proton #endif // PROTON_IO_CONTAINER_IMPL_BASE_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/io/link_namer.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/io/link_namer.hpp b/proton-c/bindings/cpp/include/proton/io/link_namer.hpp index 8add9a3..281503b 100644 --- a/proton-c/bindings/cpp/include/proton/io/link_namer.hpp +++ b/proton-c/bindings/cpp/include/proton/io/link_namer.hpp @@ -1,6 +1,8 @@ -#ifndef PROTON_IO_LINK_NAMER -#define PROTON_IO_LINK_NAMER +#ifndef PROTON_IO_LINK_NAMER_HPP +#define PROTON_IO_LINK_NAMER_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 @@ -17,6 +19,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ #include <string> @@ -24,14 +27,18 @@ namespace proton { namespace io { -/// Generate default link names that are unique within a container. -/// base_container provides a default implementation. +/// **Experimental** - Generate default link names that are unique +/// within a container. base_container provides a default +/// implementation. class link_namer { public: virtual ~link_namer() {} + + /// Generate a unique link name. virtual std::string link_name() = 0; }; -}} +} // io +} // proton -#endif // PROTON_IO_LINK_NAMER +#endif // PROTON_IO_LINK_NAMER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/link.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/link.hpp b/proton-c/bindings/cpp/include/proton/link.hpp index 1a5347c..6eca93e 100644 --- a/proton-c/bindings/cpp/include/proton/link.hpp +++ b/proton-c/bindings/cpp/include/proton/link.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_LINK_H -#define PROTON_CPP_LINK_H +#ifndef PROTON_LINK_HPP +#define PROTON_LINK_HPP /* * @@ -22,16 +22,16 @@ * */ -#include <proton/endpoint.hpp> -#include <proton/export.hpp> -#include <proton/message.hpp> -#include <proton/source.hpp> -#include <proton/target.hpp> -#include <proton/object.hpp> -#include <proton/sender_options.hpp> -#include <proton/receiver_options.hpp> +#include "proton/endpoint.hpp" +#include "proton/export.hpp" +#include "proton/message.hpp" +#include "proton/source.hpp" +#include "proton/target.hpp" +#include "proton/internal/object.hpp" +#include "proton/sender_options.hpp" +#include "proton/receiver_options.hpp" -#include <proton/types.h> +#include "proton/types.h" #include <string> @@ -60,60 +60,59 @@ PN_CPP_CLASS_EXTERN link : public internal::object<pn_link_t> , public endpoint /// @endcond public: + /// Create an empty link. link() : internal::object<pn_link_t>(0) {} - // Endpoint behaviours 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; - /// Locally close the link. The operation is not complete till - /// handler::on_link_close. PN_CPP_EXTERN void close(); - - /// Initiate close with an error condition. - /// The operation is not complete till handler::on_connection_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 subscriptions becomes inactive + /// 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; /// True for a receiver if a drain cycle has been started and the - /// corresponding on_receiver_drain_finish event is still pending. - /// @see receiver::drain. True for a sender if the receiver has - /// requested a drain of credit and the sender has unused credit. + /// 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; - /// Return the container for this link + /// The container for this link. PN_CPP_EXTERN class container &container() const; - /// Connection that owns this link. + /// The connection that owns this link. PN_CPP_EXTERN class connection connection() const; - /// Session that owns this link. + /// The session that owns this link. PN_CPP_EXTERN class session session() const; - ///@cond INTERNAL protected: - /// Initiate the AMQP attach frame. The operation is not complete till - /// handler::on_link_open. + /// @cond INTERNAL + + // Initiate the AMQP attach frame. void attach(); - friend class internal::factory<link>; - ///@endcond + friend class internal::factory<link>; + + /// @endcond }; } -#endif // PROTON_CPP_LINK_H +#endif // PROTON_LINK_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/list.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/list.hpp b/proton-c/bindings/cpp/include/proton/list.hpp deleted file mode 100644 index 1a996a0..0000000 --- a/proton-c/bindings/cpp/include/proton/list.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef PROTON_LIST_HPP -#define PROTON_LIST_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 <list> -#include <utility> - -#include <proton/encoder.hpp> -#include <proton/decoder.hpp> - -namespace proton { -namespace codec { -/// std::list<T> for most T is encoded as an AMQP array. -template <class T, class A> -encoder& operator<<(encoder& e, const std::list<T, A>& x) { - return e << encoder::array(x, internal::type_id_of<T>::value); -} - -/// Specialize for std::list<value>, encode as AMQP list (variable type) -template <class A> -encoder& operator<<(encoder& e, const std::list<value, A>& x) { return e << encoder::list(x); } - -/// Specialize for std::list<scalar>, encode as AMQP list (variable type) -template <class A> -encoder& operator<<(encoder& e, const std::list<scalar, A>& x) { return e << encoder::list(x); } - -/// Specialize for std::list<std::pair<k,t> >, encode as AMQP map. -/// Allows control over the order of encoding map entries. -template <class A, class K, class T> -encoder& operator<<(encoder& e, const std::list<std::pair<K,T>, A>& x) { return e << encoder::map(x); } - -/// Decode to std::list<T> from an amqp::LIST or amqp::ARRAY. -template <class T, class A> decoder& operator>>(decoder& d, std::list<T, A>& x) { return d >> decoder::sequence(x); } - -/// Decode to std::list<std::pair<K, T> from an amqp::MAP. -template <class A, class K, class T> decoder& operator>>(decoder& d, std::list<std::pair<K, T> , A>& x) { return d >> decoder::pair_sequence(x); } - -} -} - -#endif // PROTON_LIST_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/listen_handler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/listen_handler.hpp b/proton-c/bindings/cpp/include/proton/listen_handler.hpp index f836513..fc2c49e 100644 --- a/proton-c/bindings/cpp/include/proton/listen_handler.hpp +++ b/proton-c/bindings/cpp/include/proton/listen_handler.hpp @@ -2,6 +2,7 @@ #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 @@ -18,13 +19,16 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ - namespace proton { -/// Implement this interface and pass to proton::container::listen() to be -/// notified of new connections. +// XXX Discuss more +/// **Experimental** - A handler for incoming connections. +/// +/// Implement this interface and pass to proton::container::listen() +/// to be notified of new connections. class listen_handler { public: virtual ~listen_handler() {} @@ -44,7 +48,7 @@ class listen_handler { /// Called when this listen_handler is no longer needed, and can be deleted. virtual void on_close() {} }; -} +} // proton #endif // PROTON_LISTEN_HANDLER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/listener.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/listener.hpp b/proton-c/bindings/cpp/include/proton/listener.hpp index 2441e2b..0cdd7a5 100644 --- a/proton-c/bindings/cpp/include/proton/listener.hpp +++ b/proton-c/bindings/cpp/include/proton/listener.hpp @@ -20,7 +20,7 @@ * under the License. */ -#include <proton/export.hpp> +#include "proton/export.hpp" #include <string> @@ -28,16 +28,18 @@ namespace proton { class container; -/// Returned by container::listen to allow you to stop listening on that address. +/// A listener for incoming connections. class PN_CPP_CLASS_EXTERN listener { public: + /// Create an empty listener. PN_CPP_EXTERN listener(); - ///@cond internal + + /// @cond INTERNAL PN_CPP_EXTERN listener(container&, const std::string&); - ///@endcond internal + /// @endcond - /// Stop listening on the address provided to the call to container::listen that - /// returned this listener. + /// Stop listening on the address provided to the call to + /// container::listen that returned this listener. PN_CPP_EXTERN void stop(); private: @@ -45,7 +47,6 @@ class PN_CPP_CLASS_EXTERN listener { container* container_; }; - -} +} // proton #endif // PROTON_LISTENER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/map.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/map.hpp b/proton-c/bindings/cpp/include/proton/map.hpp deleted file mode 100644 index e640bab..0000000 --- a/proton-c/bindings/cpp/include/proton/map.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#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 <map> -#include <proton/encoder.hpp> -#include <proton/decoder.hpp> - -namespace proton { -namespace codec { - -/// Encode std::map<K, T> as amqp::MAP. -template <class K, class T, class C, class A> -encoder& operator<<(encoder& e, const std::map<K, T, C, A>& m) { return e << encoder::map(m); } - -/// Decode to std::map<K, T> from amqp::MAP. -template <class K, class T, class C, class A> -decoder& operator>>(decoder& d, std::map<K, T, C, A>& m) { return d >> decoder::associative(m); } - -} // internal -} // proton - -#endif // PROTON_MAP_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/message.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp index 2dbb4ec..a6bc215 100644 --- a/proton-c/bindings/cpp/include/proton/message.hpp +++ b/proton-c/bindings/cpp/include/proton/message.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_MESSAGE_H -#define PROTON_CPP_MESSAGE_H +#ifndef PROTON_MESSAGE_HPP +#define PROTON_MESSAGE_HPP /* * @@ -22,13 +22,13 @@ * */ -#include <proton/map.hpp> -#include <proton/annotation_key.hpp> -#include <proton/duration.hpp> -#include <proton/export.hpp> -#include <proton/message_id.hpp> -#include <proton/pn_unique_ptr.hpp> -#include <proton/value.hpp> +#include "proton/annotation_key.hpp" +#include "proton/codec/map.hpp" +#include "proton/duration.hpp" +#include "proton/export.hpp" +#include "proton/message_id.hpp" +#include "proton/internal/pn_unique_ptr.hpp" +#include "proton/value.hpp" #include <string> #include <vector> @@ -44,13 +44,16 @@ class annotation_key; /// An AMQP message. /// -/// Value semantics: can be copied or assigned to make a new 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. + /// **Experimental** - A map of string keys and AMQP scalar + /// values. typedef std::map<std::string, scalar> property_map; - /// A map of AMQP annotation keys and AMQP values. + /// **Experimental** - A map of AMQP annotation keys and AMQP + /// values. typedef std::map<annotation_key, value> annotation_map; /// Create an empty message. @@ -65,6 +68,8 @@ class 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 @@ -80,10 +85,19 @@ class message { /// 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& 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 &user); + + /// Get the user name or ID. PN_CPP_EXTERN std::string user() const; /// Encode entire message into a byte vector, growing it if @@ -101,17 +115,28 @@ class message { /// @name Routing /// @{ + /// Set the destination address. PN_CPP_EXTERN void to(const std::string &addr); + + /// 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 &addr); PN_CPP_EXTERN std::string address() const; + /// @endcond + /// Set the address for replies. PN_CPP_EXTERN void reply_to(const std::string &addr); - PN_CPP_EXTERN std::string reply_to() const; + /// 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; /// @} @@ -119,34 +144,49 @@ class message { /// @name Content /// @{ - /// Set the body, equivalent to body() = x + /// 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. + /// 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 &s); + + /// 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 &s); + + /// 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 &s); + + /// 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 t); + + /// Get the expiration time. PN_CPP_EXTERN timestamp expiry_time() const; + /// Set the creation time. PN_CPP_EXTERN void creation_time(timestamp t); + + /// Get the creation time. PN_CPP_EXTERN timestamp creation_time() const; - /// Get the inferred flag for a message. + /// Get the inferred flag. /// /// The inferred flag for a message indicates how the message - /// content is encoded into AMQP sections. If inferred is true + /// 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 @@ -154,7 +194,7 @@ class message { /// regardless of their type. PN_CPP_EXTERN bool inferred() const; - /// Set the inferred flag for a message. + /// Set the inferred flag. PN_CPP_EXTERN void inferred(bool); /// @} @@ -162,39 +202,38 @@ class message { /// @name Transfer headers /// @{ - /// Get the durable flag for a message. + /// Get the durable flag. /// /// The durable flag indicates that any parties taking /// responsibility for the message must durably store the content. - /// - /// @return the value of the durable flag PN_CPP_EXTERN bool durable() const; - /// Set the durable flag for a message. + + /// Set the durable flag. PN_CPP_EXTERN void durable(bool); - /// Get the TTL for a message. + /// 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. + /// dead, it may be dropped. PN_CPP_EXTERN duration ttl() const; - /// Set the TTL for a message. + /// Set the TTL. PN_CPP_EXTERN void ttl(duration); - /// Get the priority for a message. + /// 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. PN_CPP_EXTERN uint8_t priority() const; - /// Set the priority for a message. + /// Set the priority. PN_CPP_EXTERN void priority(uint8_t); - /// Get the first acquirer flag for a message. + /// 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 @@ -202,18 +241,21 @@ class message { /// 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 for a message. + /// Set the first acquirer flag. PN_CPP_EXTERN void first_acquirer(bool); - /// Get the delivery count for a message. + /// Get the delivery count. /// - /// The delivery count field tracks how many attempts have been made to - /// delivery a message. + /// 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 for a message. + /// Get the delivery count. PN_CPP_EXTERN void delivery_count(uint32_t); /// @} @@ -221,18 +263,25 @@ class message { /// @name Message groups /// @{ + /// Set the message group ID. PN_CPP_EXTERN void group_id(const std::string &s); + + /// 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 &s); + + /// Get the reply-to group ID. PN_CPP_EXTERN std::string reply_to_group_id() const; - /// Get the group sequence for a message. + /// 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); @@ -241,16 +290,28 @@ class message { /// @name Extended attributes /// @{ - /// Application properties map, can be modified in place. + /// **Experimental** - Get the application properties map. It can + /// be modified in place. PN_CPP_EXTERN property_map& properties(); + + /// **Experimental** - Get the application properties map. It can + /// be modified in place. PN_CPP_EXTERN const property_map& properties() const; - /// Message annotations map, can be modified in place. + /// **Experimental** - Get the message annotations map. It can be + /// modified in place. PN_CPP_EXTERN annotation_map& message_annotations(); + + /// **Experimental** - Get the message annotations map. It can be + /// modified in place. PN_CPP_EXTERN const annotation_map& message_annotations() const; - /// Delivery annotations map, can be modified in place. + /// **Experimental** - Get the delivery annotations map. It can + /// be modified in place. PN_CPP_EXTERN annotation_map& delivery_annotations(); + + /// **Experimental** - Get the delivery annotations map. It can + /// be modified in place. PN_CPP_EXTERN const annotation_map& delivery_annotations() const; /// @} @@ -268,11 +329,11 @@ class message { /// Decode the message corresponding to a delivery from a link. void decode(proton::delivery); - PN_CPP_EXTERN friend void swap(message&, message&); - friend class messaging_adapter; + PN_CPP_EXTERN friend void swap(message&, message&); + friend class messaging_adapter; /// @endcond }; -} +} // proton -#endif // PROTON_CPP_MESSAGE_H +#endif // PROTON_MESSAGE_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/message_id.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/message_id.hpp b/proton-c/bindings/cpp/include/proton/message_id.hpp index abf4fe2..59b6f75 100644 --- a/proton-c/bindings/cpp/include/proton/message_id.hpp +++ b/proton-c/bindings/cpp/include/proton/message_id.hpp @@ -1,7 +1,8 @@ -#ifndef MESSAGE_ID_HPP -#define MESSAGE_ID_HPP +#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 @@ -18,11 +19,12 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ -#include <proton/binary.hpp> -#include <proton/scalar_base.hpp> -#include <proton/uuid.hpp> +#include "proton/binary.hpp" +#include "proton/internal/scalar_base.hpp" +#include "proton/uuid.hpp" #include <string> @@ -39,10 +41,10 @@ namespace proton { /// class message_id : public internal::scalar_base { public: - /// An empty message_id has a uint64_t == 0 value. + /// An empty message_id has a uint64_t value set to 0. message_id() { put_(uint64_t(0)); } - /// Construct from any type that can be assigned + /// Construct from any type that can be assigned. template <class T> message_id(const T& x) { *this = x; } /// @name Assignment operators @@ -65,9 +67,10 @@ class message_id : public internal::scalar_base { ///@endcond }; -///@cond internal +/// @cond INTERNAL +// XXX Document this? template <class T> T get(const message_id& x); -///@endcond +/// @endcond /// Get the uint64_t value or throw conversion_error. @related message_id template<> inline uint64_t get<uint64_t>(const message_id& x) { return internal::get<uint64_t>(x); } @@ -81,5 +84,7 @@ template<> inline std::string get<std::string>(const message_id& x) { return int /// @copydoc scalar::coerce /// @related message_id template<class T> T coerce(const message_id& x) { return internal::coerce<T>(x); } -} -#endif // MESSAGE_ID_HPP + +} // proton + +#endif // PROTON_MESSAGE_ID_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/namespaces.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/namespaces.hpp b/proton-c/bindings/cpp/include/proton/namespaces.hpp new file mode 100644 index 0000000..62b4913 --- /dev/null +++ b/proton-c/bindings/cpp/include/proton/namespaces.hpp @@ -0,0 +1,44 @@ +#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. + */ + +/// The main Proton namespace. +namespace proton { + +/// **Experimental** - AMQP data encoding and decoding. +/// +/// You can use these classes on an experimental basis to create your +/// own AMQP encodings for C++ types, but they may change in the +/// future. For examples of use see the built-in encodings, for +/// example in proton/vector.hpp or proton/map.hpp +namespace codec { +} + +/// **Experimental** - An SPI for multithreaded network IO. +namespace io { +} + +namespace internal { +} + +} // proton + +#endif // PROTON_NAMESPACES_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/object.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/object.hpp b/proton-c/bindings/cpp/include/proton/object.hpp deleted file mode 100644 index e94e4e6..0000000 --- a/proton-c/bindings/cpp/include/proton/object.hpp +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef OBJECT_HPP -#define OBJECT_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. - */ - -/// @cond INTERNAL - -#include "proton/config.hpp" -#include "proton/export.hpp" -#include "proton/comparable.hpp" -#include <memory> - -namespace proton { - -template <class T> class thread_safe; - -namespace internal { - -class pn_ptr_base { - protected: - PN_CPP_EXTERN static void incref(void* p); - PN_CPP_EXTERN static void decref(void* p); -}; - -template <class T> class pn_ptr : private pn_ptr_base, private comparable<pn_ptr<T> > { - public: - pn_ptr() : ptr_(0) {} - pn_ptr(T* p) : ptr_(p) { incref(ptr_); } - pn_ptr(const pn_ptr& o) : ptr_(o.ptr_) { incref(ptr_); } - -#if PN_CPP_HAS_RVALUE_REFERENCES - pn_ptr(pn_ptr&& o) : ptr_(0) { std::swap(ptr_, o.ptr_); } -#endif - - ~pn_ptr() { decref(ptr_); } - - pn_ptr& operator=(pn_ptr o) { std::swap(ptr_, o.ptr_); return *this; } - - T* get() const { return ptr_; } - T* release() { T *p = ptr_; ptr_ = 0; return p; } - - bool operator!() const { return !ptr_; } - -#if PN_CPP_HAS_EXPLICIT_CONVERSIONS - explicit operator bool() const { return !!ptr_; } -#endif - - static pn_ptr take_ownership(T* p) { return pn_ptr<T>(p, true); } - - private: - T *ptr_; - - // Note that it is the presence of the bool in the constructor signature that matters - // to get the "transfer ownership" constructor: The value of the bool isn't checked. - pn_ptr(T* p, bool) : ptr_(p) {} - - friend bool operator==(const pn_ptr& a, const pn_ptr& b) { return a.ptr_ == b.ptr_; } - friend bool operator<(const pn_ptr& a, const pn_ptr& b) { return a.ptr_ < b.ptr_; } -}; - -template <class T> pn_ptr<T> take_ownership(T* p) { return pn_ptr<T>::take_ownership(p); } - -/// Base class for proton object types. -template <class T> class object : private comparable<object<T> > { - public: - bool operator!() const { return !object_; } -#if PN_CPP_HAS_EXPLICIT_CONVERSIONS - explicit operator bool() const { return object_; } -#endif - - protected: - typedef T pn_type; - object(pn_ptr<T> o) : object_(o) {} - T* pn_object() const { return object_.get(); } - - private: - pn_ptr<T> object_; - - friend bool operator==(const object& a, const object& b) { return a.object_ == b.object_; } - friend bool operator<(const object& a, const object& b) { return a.object_ < b.object_; } - template <class U> friend class proton::thread_safe; -}; - -/// Factory class used internally to make wrappers and extract proton objects -template <class T> class factory; - -}} - -/// @endcond - -#endif // OBJECT_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/pn_unique_ptr.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/pn_unique_ptr.hpp b/proton-c/bindings/cpp/include/proton/pn_unique_ptr.hpp deleted file mode 100644 index 56f8aba..0000000 --- a/proton-c/bindings/cpp/include/proton/pn_unique_ptr.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef UNIQUE_PTR_HPP -#define UNIQUE_PTR_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. - */ - -/// @cond INTERNAL - -#include "proton/config.hpp" -#include <memory> - -namespace proton { -namespace internal { - -/// A simple unique ownership pointer, used as a return value from -/// functions that transfer ownership to the caller. -/// -/// pn_unique_ptr return values should be converted immediately to -/// std::unique_ptr if that is available or std::auto_ptr (by calling -/// release()) for older C++. You should not use pn_unique_ptr in your -/// own code. It is a limited pointer class designed only to work -/// around differences between C++11 and C++03. -template <class T> class pn_unique_ptr { - public: - pn_unique_ptr(T* p=0) : ptr_(p) {} -#if PN_CPP_HAS_RVALUE_REFERENCES - pn_unique_ptr(pn_unique_ptr&& x) : ptr_(0) { std::swap(ptr_, x.ptr_); } -#else - pn_unique_ptr(const pn_unique_ptr& x) : ptr_() { std::swap(ptr_, const_cast<pn_unique_ptr&>(x).ptr_); } -#endif - ~pn_unique_ptr() { delete(ptr_); } - T& operator*() const { return *ptr_; } - T* operator->() const { return ptr_; } - T* get() const { return ptr_; } - void reset(T* p = 0) { pn_unique_ptr<T> tmp(p); std::swap(ptr_, tmp.ptr_); } - T* release() { T *p = ptr_; ptr_ = 0; return p; } - operator bool() const { return get(); } - bool operator !() const { return get(); } - -#if PN_CPP_HAS_STD_PTR - operator std::unique_ptr<T>() { T *p = ptr_; ptr_ = 0; return std::unique_ptr<T>(p); } -#endif - - private: - T* ptr_; -}; - -}} - -/// @endcond - -#endif // UNIQUE_PTR_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/receiver.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/receiver.hpp b/proton-c/bindings/cpp/include/proton/receiver.hpp index f0fd2c0..3a3b69b 100644 --- a/proton-c/bindings/cpp/include/proton/receiver.hpp +++ b/proton-c/bindings/cpp/include/proton/receiver.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_RECEIVER_H -#define PROTON_CPP_RECEIVER_H +#ifndef PROTON_RECEIVER_HPP +#define PROTON_RECEIVER_HPP /* * @@ -26,6 +26,7 @@ #include "proton/endpoint.hpp" #include "proton/link.hpp" #include "proton/types.h" + #include <string> struct pn_connection_t; @@ -33,7 +34,7 @@ struct pn_connection_t; namespace proton { template <class T> class thread_safe; -/// A link for receiving messages. +/// A channel for receiving messages. class PN_CPP_CLASS_EXTERN receiver : public link { /// @cond INTERNAL @@ -41,11 +42,15 @@ PN_CPP_CLASS_EXTERN receiver : public link { /// @endcond public: + /// Create an empty receiver. receiver() {} - /// Locally open the receiver. The operation is not complete till - /// handler::on_receiver_open. + /// 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. @@ -76,29 +81,33 @@ PN_CPP_CLASS_EXTERN receiver : public link { /// @endcond }; +/// @cond INTERNAL + +/// An iterator of receivers. class receiver_iterator : public internal::iter_base<receiver, receiver_iterator> { - ///@cond INTERNAL explicit receiver_iterator(receiver r, pn_session_t* s = 0) : internal::iter_base<receiver, receiver_iterator>(r), session_(s) {} - ///@endcond public: + /// Create an iterator of receivers. explicit receiver_iterator() : internal::iter_base<receiver, receiver_iterator>(0), session_(0) {} - /// Advance + + /// Advance to the next receiver. PN_CPP_EXTERN receiver_iterator operator++(); private: pn_session_t* session_; - friend class connection; - friend class session; + friend class connection; + friend class session; }; /// A range of receivers. typedef internal::iter_range<receiver_iterator> receiver_range; +/// @endcond -} +} // proton -#endif // PROTON_CPP_RECEIVER_H +#endif // PROTON_RECEIVER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/receiver_options.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/receiver_options.hpp b/proton-c/bindings/cpp/include/proton/receiver_options.hpp index f40066f..6621232 100644 --- a/proton-c/bindings/cpp/include/proton/receiver_options.hpp +++ b/proton-c/bindings/cpp/include/proton/receiver_options.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_RECEIVER_OPTIONS_H -#define PROTON_CPP_RECEIVER_OPTIONS_H +#ifndef PROTON_RECEIVER_OPTIONS_HPP +#define PROTON_RECEIVER_OPTIONS_HPP /* * @@ -24,7 +24,7 @@ #include "proton/config.hpp" #include "proton/export.hpp" -#include "proton/pn_unique_ptr.hpp" +#include "proton/internal/pn_unique_ptr.hpp" #include "proton/types.hpp" #include "proton/delivery_mode.hpp" #include "proton/terminus.hpp" @@ -83,10 +83,10 @@ class receiver_options { PN_CPP_EXTERN receiver_options& delivery_mode(delivery_mode); /// Automatically accept inbound messages that aren't otherwise - /// released, rejected or modified (default value:true). + /// released, rejected, or modified (default is true). PN_CPP_EXTERN receiver_options& auto_accept(bool); - /// Automatically settle messages (default value: true). + /// Automatically settle messages (default is true). PN_CPP_EXTERN receiver_options& auto_settle(bool); /// Options for the source node of the receiver. @@ -95,13 +95,10 @@ class receiver_options { /// Options for the target node of the receiver. PN_CPP_EXTERN receiver_options& target(target_options &); - /// @cond INTERNAL - /// XXX moving to ??? /// Set automated flow control to pre-fetch this many messages - /// (default value:10). Set to zero to disable automatic credit + /// (default is 10). Set to zero to disable automatic credit /// replenishing. PN_CPP_EXTERN receiver_options& credit_window(int); - /// @endcond /// @cond INTERNAL private: @@ -114,6 +111,6 @@ class receiver_options { /// @endcond }; -} +} // proton -#endif // PROTON_CPP_RECEIVER_OPTIONS_H +#endif // PROTON_RECEIVER_OPTIONS_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp b/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp index 802863c..8ac157d 100644 --- a/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp +++ b/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_RECONNECT_H -#define PROTON_CPP_RECONNECT_H +#ifndef PROTON_RECONNECT_TIMER_HPP +#define PROTON_RECONNECT_TIMER_HPP /* * @@ -23,29 +23,34 @@ */ /// @cond INTERNAL -/// XXX more discussion +/// XXX Needs more discussion #include "proton/export.hpp" #include "proton/duration.hpp" #include "proton/timestamp.hpp" #include "proton/types.hpp" + #include <string> namespace proton { -/** A class that generates a series of delays to coordinate reconnection attempts. They may be open ended or limited in time. They may be evenly spaced or doubling at an exponential rate. */ -class reconnect_timer -{ +/// **Experimental** - A class that generates a series of delays to +/// coordinate reconnection attempts. They may be open ended or +/// limited in time. They may be evenly spaced or doubling at an +/// exponential rate. +class reconnect_timer { public: - /** TODO: - */ PN_CPP_EXTERN reconnect_timer(uint32_t first = 0, int32_t max = -1, uint32_t increment = 100, bool doubling = true, int32_t max_retries = -1, int32_t timeout = -1); - /** Indicate a successful connection, resetting the internal timer values */ + /// Indicate a successful connection, resetting the internal timer + /// values. PN_CPP_EXTERN void reset(); - /** Obtain the timer's computed time to delay before attempting a reconnection attempt (in milliseconds). -1 means that the retry limit or timeout has been exceeded and reconnection attempts should cease. */ + /// Obtain the timer's computed time to delay before attempting a + /// reconnection attempt (in milliseconds). -1 means that the + /// retry limit or timeout has been exceeded and reconnection + /// attempts should cease. PN_CPP_EXTERN int next_delay(timestamp now); private: @@ -60,7 +65,8 @@ class reconnect_timer timestamp timeout_deadline_; }; +} // proton + /// @endcond -} -#endif // PROTON_CPP_RECONNECT_H +#endif // PROTON_RECONNECT_TIMER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/sasl.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/sasl.hpp b/proton-c/bindings/cpp/include/proton/sasl.hpp index db6b77a..0359c99 100644 --- a/proton-c/bindings/cpp/include/proton/sasl.hpp +++ b/proton-c/bindings/cpp/include/proton/sasl.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_SASL_H -#define PROTON_CPP_SASL_H +#ifndef PROTON_SASL_HPP +#define PROTON_SASL_HPP /* * @@ -24,9 +24,10 @@ #include "proton/export.hpp" #include "proton/config.hpp" -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include "proton/sasl.h" + #include <string> namespace proton { @@ -75,6 +76,6 @@ class sasl { /// @endcond }; -} +} // proton -#endif // PROTON_CPP_SASL_H +#endif // PROTON_SASL_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/scalar.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/scalar.hpp b/proton-c/bindings/cpp/include/proton/scalar.hpp index a08aa48..2aa73b9 100644 --- a/proton-c/bindings/cpp/include/proton/scalar.hpp +++ b/proton-c/bindings/cpp/include/proton/scalar.hpp @@ -20,7 +20,7 @@ * under the License. */ -#include <proton/scalar_base.hpp> +#include "proton/internal/scalar_base.hpp" namespace proton { @@ -29,32 +29,32 @@ class decoder; class encoder; } -/// A holder for an instance of any scalar AMQP type, see \ref types. +/// A holder for an instance of any scalar AMQP type. /// +/// @see @ref types_page class scalar : public internal::scalar_base { public: /// Create an empty scalar. PN_CPP_EXTERN scalar() {} - /// Construct from any scalar type, see \ref types. + /// Construct from any scalar type. template <class T> scalar(const T& x) { *this = x; } - /// Assign from any scalar type, see \ref types. + /// Assign from any scalar type. template <class T> scalar& operator=(const T& x) { put_(x); return *this; } - /// No contents, type() == NULL_TYPE + /// True if type() == NULL_TYPE. bool empty() const { return type() == NULL_TYPE; } - /// Clear the scalar, make it empty() + /// 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) /// -/// Will succeed if and only if x contains a uint64_t value. +/// This will succeed if and only if x contains a uint64_t value. /// /// @throw conversion_error if contained value is not of type T. /// @related scalar @@ -64,13 +64,14 @@ template<class T> T get(const scalar& s) { return internal::get<T>(s); } /// /// uint64_t i = get<uint64_t>(x) /// -/// Will succeed if x contains any numeric value, but may lose precision if it -/// contains a float or double value. +/// 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` +/// @throw conversion_error if the value cannot be converted to T +/// according to `std::is_convertible` /// @related scalar template<class T> T coerce(const scalar& x) { return internal::coerce<T>(x); } -} +} // proton -#endif /*!PROTON_SCALAR_HPP*/ +#endif // PROTON_SCALAR_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/scalar_base.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/scalar_base.hpp b/proton-c/bindings/cpp/include/proton/scalar_base.hpp deleted file mode 100644 index eea3fb2..0000000 --- a/proton-c/bindings/cpp/include/proton/scalar_base.hpp +++ /dev/null @@ -1,177 +0,0 @@ -#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 <proton/binary.hpp> -#include <proton/comparable.hpp> -#include <proton/decimal.hpp> -#include <proton/error.hpp> -#include <proton/export.hpp> -#include <proton/symbol.hpp> -#include <proton/timestamp.hpp> -#include <proton/type_id.hpp> -#include <proton/types_fwd.hpp> -#include <proton/type_traits.hpp> -#include <proton/uuid.hpp> - -#include <iosfwd> -#include <string> - -namespace proton { -class message; - -namespace codec { -class decoder; -class encoder; -} - -namespace internal { - -/// Base class for scalar types. -class scalar_base : private comparable<scalar_base> { - public: - /// AMQP type of data stored in the scalar - PN_CPP_EXTERN type_id type() const; - - /// @cond INTERNAL - /// deprecated - template <class T> void get(T& x) const { get_(x); } - template <class T> T get() const { T x; get_(x); return x; } - /// @endcond - - /// 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 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&); - - 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; - - private: - 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. - - friend class proton::message; - friend class codec::encoder; - friend class codec::decoder; -}; - -template<class T> T get(const scalar_base& s) { T x; s.get(x); return x; } - -template <class R, class F> R visit(const scalar_base& s, F f) { - switch(s.type()) { - case BOOLEAN: return f(s.get<bool>()); - case UBYTE: return f(s.get<uint8_t>()); - case BYTE: return f(s.get<int8_t>()); - case USHORT: return f(s.get<uint16_t>()); - case SHORT: return f(s.get<int16_t>()); - case UINT: return f(s.get<uint32_t>()); - case INT: return f(s.get<int32_t>()); - case CHAR: return f(s.get<wchar_t>()); - case ULONG: return f(s.get<uint64_t>()); - case LONG: return f(s.get<int64_t>()); - case TIMESTAMP: return f(s.get<timestamp>()); - case FLOAT: return f(s.get<float>()); - case DOUBLE: return f(s.get<double>()); - case DECIMAL32: return f(s.get<decimal32>()); - case DECIMAL64: return f(s.get<decimal64>()); - case DECIMAL128: return f(s.get<decimal128>()); - case UUID: return f(s.get<uuid>()); - case BINARY: return f(s.get<binary>()); - case STRING: return f(s.get<std::string>()); - case SYMBOL: return f(s.get<symbol>()); - default: throw conversion_error("invalid scalar type "+type_name(s.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 conversion_error("cannot coerce from " + type_name(type_id_of<U>::value)); - } -}; - -template <class T> T coerce(const scalar_base& s) { return visit<T>(s, coerce_op<T>()); } - -} // internal - - -} // proton - -#endif /*!PROTON_SCALAR_BASE_HPP*/ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/sender.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/sender.hpp b/proton-c/bindings/cpp/include/proton/sender.hpp index 114e8bb..1944e36 100644 --- a/proton-c/bindings/cpp/include/proton/sender.hpp +++ b/proton-c/bindings/cpp/include/proton/sender.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_SENDER_H -#define PROTON_CPP_SENDER_H +#ifndef PROTON_SENDER_HPP +#define PROTON_SENDER_HPP /* * @@ -28,6 +28,7 @@ #include "proton/tracker.hpp" #include "proton/types.h" + #include <string> struct pn_connection_t; @@ -35,20 +36,23 @@ struct pn_connection_t; namespace proton { template <class T> class thread_safe; -/// A link for sending messages. +/// A channel for sending messages. class -PN_CPP_CLASS_EXTERN sender : public link -{ +PN_CPP_CLASS_EXTERN sender : public link { /// @cond INTERNAL PN_CPP_EXTERN sender(pn_link_t* s); /// @endcond public: + /// Create an empty sender. sender() {} - /// Locally open the sender. The operation is not complete till - /// handler::on_sender_open. + /// 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. @@ -63,39 +67,43 @@ PN_CPP_CLASS_EXTERN sender : public link /// 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. + /// + /// @see receiver::drain PN_CPP_EXTERN void return_credit(); - /// @cond INTERNAL + /// @cond INTERNAL friend class internal::factory<sender>; friend class sender_iterator; friend class thread_safe<sender>; - /// @endcond + /// @endcond }; +/// @cond INTERNAL + +/// An iterator of senders. class sender_iterator : public internal::iter_base<sender, sender_iterator> { - ///@cond INTERNAL sender_iterator(sender snd, pn_session_t* s = 0) : internal::iter_base<sender, sender_iterator>(snd), session_(s) {} - ///@endcond public: + /// Create an iterator of senders. sender_iterator() : internal::iter_base<sender, sender_iterator>(0), session_(0) {} - /// Advance + /// Advance to the next sender. PN_CPP_EXTERN sender_iterator operator++(); private: pn_session_t* session_; - friend class connection; - friend class session; + friend class connection; + friend class session; }; /// A range of senders. typedef internal::iter_range<sender_iterator> sender_range; +/// @endcond } -#endif // PROTON_CPP_SENDER_H +#endif // PROTON_SENDER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/sender_options.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/sender_options.hpp b/proton-c/bindings/cpp/include/proton/sender_options.hpp index d74f1f8..b3f1f4c 100644 --- a/proton-c/bindings/cpp/include/proton/sender_options.hpp +++ b/proton-c/bindings/cpp/include/proton/sender_options.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_SENDER_OPTIONS_H -#define PROTON_CPP_SENDER_OPTIONS_H +#ifndef PROTON_SENDER_OPTIONS_HPP +#define PROTON_SENDER_OPTIONS_HPP /* * @@ -24,7 +24,7 @@ #include "proton/config.hpp" #include "proton/export.hpp" -#include "proton/pn_unique_ptr.hpp" +#include "proton/internal/pn_unique_ptr.hpp" #include "proton/types.hpp" #include "proton/delivery_mode.hpp" #include "proton/terminus.hpp" @@ -60,6 +60,7 @@ class target_options; /// /// Normal value semantics: copy or assign creates a separate copy of /// the options. +// XXX opts.browsing is not a good example here class sender_options { public: /// Create an empty set of options. @@ -85,7 +86,7 @@ class sender_options { /// Set the delivery mode on the sender. PN_CPP_EXTERN sender_options& delivery_mode(delivery_mode); - /// Automatically settle messages (default value: true). + /// Automatically settle messages (default is true). PN_CPP_EXTERN sender_options& auto_settle(bool); /// Options for the source node of the sender. @@ -94,7 +95,6 @@ class sender_options { /// Options for the receiver node of the receiver. PN_CPP_EXTERN sender_options& target(target_options &); - /// @cond INTERNAL private: void apply(sender&) const; @@ -106,6 +106,6 @@ class sender_options { /// @endcond }; -} +} // proton -#endif // PROTON_CPP_SENDER_OPTIONS_H +#endif // PROTON_SENDER_OPTIONS_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/session.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/session.hpp b/proton-c/bindings/cpp/include/proton/session.hpp index 540f1bd..164a5bd 100644 --- a/proton-c/bindings/cpp/include/proton/session.hpp +++ b/proton-c/bindings/cpp/include/proton/session.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_SESSION_H -#define PROTON_CPP_SESSION_H +#ifndef PROTON_SESSION_HPP +#define PROTON_SESSION_HPP /* * @@ -30,6 +30,7 @@ #include "proton/types.h" #include "proton/link.h" + #include <string> struct pn_connection_t; @@ -43,39 +44,34 @@ template <class T> class thread_safe; /// A container of senders and receivers. class -PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endpoint -{ +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) {} - // Endpoint behaviours - - /// Get the state of this session. 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; - /// Initiate local open. The operation is not complete till - /// handler::on_session_open(). + /// Open the session. + /// + /// @see endpoint_lifecycle PN_CPP_EXTERN void open(); + + /// @copydoc open PN_CPP_EXTERN void open(const session_options &opts); - /// Initiate local close. The operation is not complete till - /// handler::on_session_close(). PN_CPP_EXTERN void close(); - - /// Initiate close with an error condition. - /// The operation is not complete till handler::on_connection_close(). PN_CPP_EXTERN void close(const error_condition&); - - /// Return the container for this session + /// Get the container for this session. PN_CPP_EXTERN class container &container() const; /// Get the connection this session belongs to. @@ -83,10 +79,14 @@ PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endp /// 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. @@ -101,24 +101,29 @@ PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endp /// Return the receivers on this session. PN_CPP_EXTERN receiver_range receivers() const; - friend class internal::factory<session>; - friend class session_iterator; - friend class thread_safe<session>; + /// @cond INTERNAL + friend class internal::factory<session>; + friend class session_iterator; + friend class thread_safe<session>; + /// @endcond }; - -/// An iterator for sessions. +/// @cond INTERNAL + +/// An iterator of sessions. class session_iterator : public internal::iter_base<session, session_iterator> { public: - ///@cond INTERNAL explicit session_iterator(session s = 0) : internal::iter_base<session, session_iterator>(s) {} - ///@endcond - PN_CPP_EXTERN session_iterator operator++(); ///< Advance + + /// 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_CPP_SESSION_H +#endif // PROTON_SESSION_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/session_options.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/session_options.hpp b/proton-c/bindings/cpp/include/proton/session_options.hpp index 0711022..bf88f51 100644 --- a/proton-c/bindings/cpp/include/proton/session_options.hpp +++ b/proton-c/bindings/cpp/include/proton/session_options.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_SESSION_OPTIONS_H -#define PROTON_CPP_SESSION_OPTIONS_H +#ifndef PROTON_SESSION_OPTIONS_HPP +#define PROTON_SESSION_OPTIONS_HPP /* * @@ -24,25 +24,23 @@ #include "proton/config.hpp" #include "proton/export.hpp" -#include "proton/pn_unique_ptr.hpp" +#include "proton/internal/pn_unique_ptr.hpp" #include "proton/types.hpp" - namespace proton { class handler; class session; - /// Options for creating a session. /// -/// Options can be "chained" (@see proton::connection_options). +/// Options can be "chained" (see proton::connection_options). /// /// Normal value semantics: copy or assign creates a separate copy of /// the options. +// XXX Does this need the CLASS_EXTERN stuff? - Add just for consistency class session_options { public: - /// Create an empty set of options. PN_CPP_EXTERN session_options(); @@ -69,6 +67,6 @@ class session_options { /// @endcond }; -} +} // proton -#endif // PROTON_CPP_SESSION_OPTIONS_H +#endif // PROTON_SESSION_OPTIONS_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/source.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/source.hpp b/proton-c/bindings/cpp/include/proton/source.hpp index a30a866..7546f7d 100644 --- a/proton-c/bindings/cpp/include/proton/source.hpp +++ b/proton-c/bindings/cpp/include/proton/source.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_SOURCE_H -#define PROTON_CPP_SOURCE_H +#ifndef PROTON_SOURCE_HPP +#define PROTON_SOURCE_HPP /* * @@ -23,10 +23,10 @@ */ #include "proton/export.hpp" -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include "proton/value.hpp" #include "proton/terminus.hpp" -#include <proton/map.hpp> +#include "proton/codec/map.hpp" #include <string> @@ -35,21 +35,28 @@ namespace proton { class sender; class receiver; -/// /// The source node is where messages originate. /// -/// @see proton::sender proton::receiver proton::target +/// @see proton::sender, proton::receiver, proton::target class source : public terminus { public: - /// A map of AMQP symbol keys and filter specifiers. + /// **Experimental** - A map of AMQP symbol keys and filter + /// specifiers. typedef std::map<symbol, value> filter_map; + /// Create an empty source. source() : terminus() {} + /// The policy for distributing messages. enum distribution_mode { - UNSPECIFIED = PN_DIST_MODE_UNSPECIFIED, - COPY = PN_DIST_MODE_COPY, - MOVE = PN_DIST_MODE_MOVE + // XXX Why is unspecified needed? The protocol doesn't have + // it. + /// Unspecified + UNSPECIFIED = PN_DIST_MODE_UNSPECIFIED, + /// Once transferred, the message remains available to ther links + COPY = PN_DIST_MODE_COPY, + /// Once transferred, the message is unavailable to other links + MOVE = PN_DIST_MODE_MOVE }; using terminus::durability_mode; @@ -61,19 +68,21 @@ class source : public terminus { /// Get the distribution mode. PN_CPP_EXTERN enum distribution_mode distribution_mode() const; - /// Obtain the set of message filters. + /// **Experimental** - Obtain the set of message filters. PN_CPP_EXTERN filter_map filters() const; - /// @cond INTERNAL + private: source(pn_terminus_t* t); source(const sender&); source(const receiver&); + + /// @cond INTERNAL friend class proton::internal::factory<source>; friend class sender; friend class receiver; /// @endcond }; -} +} // proton -#endif // PROTON_CPP_SOURCE_H +#endif // PROTON_SOURCE_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/source_options.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/source_options.hpp b/proton-c/bindings/cpp/include/proton/source_options.hpp index 0312d06..3738184 100644 --- a/proton-c/bindings/cpp/include/proton/source_options.hpp +++ b/proton-c/bindings/cpp/include/proton/source_options.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_SOURCE_OPTIONS_H -#define PROTON_CPP_SOURCE_OPTIONS_H +#ifndef PROTON_SOURCE_OPTIONS_HPP +#define PROTON_SOURCE_OPTIONS_HPP /* * @@ -24,7 +24,7 @@ #include "proton/config.hpp" #include "proton/export.hpp" -#include "proton/pn_unique_ptr.hpp" +#include "proton/internal/pn_unique_ptr.hpp" #include "proton/types.hpp" #include "proton/delivery_mode.hpp" #include "proton/source.hpp" @@ -36,7 +36,6 @@ namespace proton { class proton_handler; - /// Options for creating a source node for a sender or receiver. /// /// Options can be "chained" (@see proton::connection_options). @@ -76,23 +75,24 @@ class source_options { /// Control when the clock for expiration begins. PN_CPP_EXTERN source_options& expiry_policy(enum source::expiry_policy); - /// Specify a filter mechanism on the source that restricts - /// message flow to a subset of the available messages. + /// **Experimental** - Specify a filter mechanism on the source + /// that restricts message flow to a subset of the available + /// messages. PN_CPP_EXTERN source_options& filters(const source::filter_map&); - /// @cond INTERNAL private: void apply(source&) const; class impl; internal::pn_unique_ptr<impl> impl_; - friend class source; - friend class sender_options; - friend class receiver_options; + /// @cond INTERNAL + friend class source; + friend class sender_options; + friend class receiver_options; /// @endcond }; -} +} // proton -#endif // PROTON_CPP_SOURCE_OPTIONS_H +#endif // PROTON_SOURCE_OPTIONS_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2dc4afe0/proton-c/bindings/cpp/include/proton/ssl.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/ssl.hpp b/proton-c/bindings/cpp/include/proton/ssl.hpp index b41b657..b6e3917 100644 --- a/proton-c/bindings/cpp/include/proton/ssl.hpp +++ b/proton-c/bindings/cpp/include/proton/ssl.hpp @@ -1,5 +1,5 @@ -#ifndef PROTON_CPP_SSL_H -#define PROTON_CPP_SSL_H +#ifndef PROTON_SSL_HPP +#define PROTON_SSL_HPP /* * @@ -23,9 +23,10 @@ */ #include "proton/export.hpp" -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include "proton/ssl.h" + #include <string> namespace proton { @@ -39,6 +40,7 @@ class ssl { /// @endcond public: + /// Create an empty ssl object. ssl() : object_(0) {} /// Determines the level of peer validation. @@ -85,25 +87,28 @@ class ssl { /// @endcond - /// @cond INTERNAL private: pn_ssl_t* object_; - friend class internal::factory<ssl>; + /// @cond INTERNAL + friend class internal::factory<ssl>; /// @endcond }; +/// **Experimental** - An SSL certificate. class ssl_certificate { public: /// Create an SSL certificate. PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main); + + // XXX Document the following constructors + + /// @copydoc ssl_certificate PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra); - /// Create an SSL certificate. - /// - /// @internal - /// XXX what is the difference between these? + /// @copydoc ssl_certificate PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra, const std::string &passwd); + /// @endcond private: std::string certdb_main_; @@ -112,8 +117,8 @@ class ssl_certificate { bool pw_set_; /// @cond INTERNAL - friend class ssl_client_options; - friend class ssl_server_options; + friend class ssl_client_options; + friend class ssl_server_options; /// @endcond }; @@ -139,7 +144,7 @@ class ssl_domain { } -/// SSL configuration for inbound connections. +/// **Experimental** - SSL configuration for inbound connections. class ssl_server_options : private internal::ssl_domain { public: /// Server SSL options based on the supplied X.509 certificate @@ -162,11 +167,11 @@ class ssl_server_options : private internal::ssl_domain { using internal::ssl_domain::pn_domain; /// @cond INTERNAL - friend class connection_options; + friend class connection_options; /// @endcond }; -/// SSL configuration for outbound connections. +/// **Experimental** - SSL configuration for outbound connections. class ssl_client_options : private internal::ssl_domain { public: /// Create SSL client options (no client certificate). @@ -187,10 +192,10 @@ class ssl_client_options : private internal::ssl_domain { using internal::ssl_domain::pn_domain; /// @cond INTERNAL - friend class connection_options; + friend class connection_options; /// @endcond }; -} +} // proton -#endif // PROTON_CPP_SSL_H +#endif // PROTON_SSL_HPP --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
