http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/cpp/include/proton/internal/pn_unique_ptr.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/internal/pn_unique_ptr.hpp b/proton-c/bindings/cpp/include/proton/internal/pn_unique_ptr.hpp deleted file mode 100644 index 323c701..0000000 --- a/proton-c/bindings/cpp/include/proton/internal/pn_unique_ptr.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef PROTON_INTERNAL_UNIQUE_PTR_HPP -#define PROTON_INTERNAL_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. - * - */ - -#include "./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; } -#if PN_CPP_HAS_EXPLICIT_CONVERSIONS - explicit operator bool() const { return get(); } -#endif - bool operator !() const { return !get(); } - -#if PN_CPP_HAS_UNIQUE_PTR - operator std::unique_ptr<T>() { T *p = ptr_; ptr_ = 0; return std::unique_ptr<T>(p); } -#endif - - private: - T* ptr_; -}; - -} // internal -} // proton - -#endif // PROTON_INTERNAL_UNIQUE_PTR_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index 8abba55..0000000 --- a/proton-c/bindings/cpp/include/proton/internal/type_traits.hpp +++ /dev/null @@ -1,184 +0,0 @@ -#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. - * - */ - -// Type traits for mapping between AMQP and C++ types. -// -// Also provides workarounds for missing type_traits classes on older -// C++ compilers. - -#include "./config.hpp" -#include "../types_fwd.hpp" -#include "../type_id.hpp" - -#include <proton/type_compat.h> - -#include <limits> - -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> { static const bool value = std::numeric_limits<char>::is_signed; }; - -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 {}; - -// The known/unknown integer type magic is required because the C++ standard is -// vague a about the equivalence of integral types for overloading. E.g. char is -// sometimes equivalent to signed char, sometimes unsigned char, sometimes -// neither. int8_t or uint8_t may or may not be equivalent to a char type. -// int64_t may or may not be equivalent to long long etc. C++ compilers are also -// allowed to add their own non-standard integer types like __int64, which may -// or may not be equivalent to any of the standard integer types. -// -// The solution is to use a fixed, standard set of integer types that are -// guaranteed to be distinct for overloading (see type_id_of) and to use template -// specialization to convert other integer types to a known integer type with the -// same sizeof and is_signed. - -// Map arbitrary integral types to known 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; -}; - -template<class T, class = typename enable_if<is_unknown_integer<T>::value>::type> -struct known_integer : public integer_type<sizeof(T), is_signed<T>::value> {}; - - -// Helper base for SFINAE templates. -struct sfinae { - typedef char yes; - typedef double no; - struct any_t { - template < typename T > any_t(T const&); - }; -}; - -template <class From, class To> struct is_convertible : public sfinae { - static yes test(const To&); - static no test(...); - static const From& from; - // Windows compilers warn about data-loss caused by legal conversions. We - // can't use static_cast because that will cause a hard error instead of - // letting SFINAE overload resolution select the test(...) overload. -#ifdef _WIN32 -#pragma warning( push ) -#pragma warning( disable : 4244 ) -#endif - static bool const value = sizeof(test(from)) == sizeof(yes); -#ifdef _WIN32 -#pragma warning( pop ) -#endif -}; - -} // internal -} // proton - -#endif // PROTON_INTERNAL_TYPE_TRAITS_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/cpp/include/proton/io/connection_driver.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/io/connection_driver.hpp b/proton-c/bindings/cpp/include/proton/io/connection_driver.hpp deleted file mode 100644 index 4a0efe9..0000000 --- a/proton-c/bindings/cpp/include/proton/io/connection_driver.hpp +++ /dev/null @@ -1,214 +0,0 @@ -#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 "../internal/config.hpp" -#include "../connection.hpp" -#include "../connection_options.hpp" -#include "../error.hpp" -#include "../error_condition.hpp" -#include "../internal/export.hpp" -#include "../internal/pn_unique_ptr.hpp" -#include "../transport.hpp" -#include "../types.hpp" - -#include <proton/connection_driver.h> - -#include <cstddef> -#include <utility> -#include <string> - -namespace proton { - -class event_loop; -class proton_handler; - -namespace io { - -/// **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. - - /// Construct a buffer starting at data_ with size_ bytes. - mutable_buffer(char* data_=0, size_t size_=0) : data(data_), size(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. - - /// Construct a buffer starting at data_ with size_ bytes. - const_buffer(const char* data_=0, size_t size_=0) : data(data_), size(size_) {} -}; - -/// **Experimental** - 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 that is not associated with a proton::container or - /// proton::event_loop. - /// - /// Accessing the container or event_loop for this connection in - /// a proton::messaging_handler will throw a proton::error exception. - /// - PN_CPP_EXTERN connection_driver(); - - /// Create a connection driver associated with a proton::container and - /// optional event_loop. If the event_loop is not provided attempts to use - /// it will throw proton::error. - /// - /// Takes ownership of the event_loop. Note the proton::connection created - /// by this connection_driver can outlive the connection_driver itself if - /// the user pins it in memory using the proton::thread_safe<> template. - /// The event_loop is deleted when, and only when, the proton::connection is. - /// - PN_CPP_EXTERN connection_driver(proton::container&); -#if PN_CPP_HAS_RVALUE_REFERENCES - PN_CPP_EXTERN connection_driver(proton::container&, event_loop&& loop); -#endif - - 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(); - - /// 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()); - - /// 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. - /// The event_loop is availabe via proton::thread_safe<connection>(connection()) - 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&); - - messaging_handler* handler_; - proton::container* container_; - pn_connection_driver_t driver_; -}; - -} // io -} // proton - -#endif // PROTON_IO_CONNECTION_DRIVER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index a04b4ff..0000000 --- a/proton-c/bindings/cpp/include/proton/io/container_impl_base.hpp +++ /dev/null @@ -1,144 +0,0 @@ -#ifndef PROTON_IO_CONTAINER_IMPL_BASE_HPP -#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 - * 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 "../container.hpp" - -#include <future> -#include <mutex> -#include <sstream> - -namespace proton { -namespace io { - -/// **Experimental** - A base container implementation. -/// -/// 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 standard_container { - public: - // Pull in base class functions here so that name search finds all the overloads - using standard_container::open_receiver; - using standard_container::open_sender; - - /// @see proton::container::client_connection_options - void client_connection_options(const connection_options & opts) { - store(client_copts_, opts); - } - - /// @see proton::container::client_connection_options - connection_options client_connection_options() const { - return load(client_copts_); - } - - /// @see proton::container::server_connection_options - void server_connection_options(const connection_options & opts) { - store(server_copts_, opts); - } - - /// @see proton::container::server_connection_options - connection_options server_connection_options() const { - return load(server_copts_); - } - - /// @see proton::container::sender_options - void sender_options(const class sender_options & opts) { - store(sender_opts_, opts); - } - - /// @see proton::container::sender_options - class sender_options sender_options() const { - return load(sender_opts_); - } - - /// @see proton::container::receiver_options - void receiver_options(const class receiver_options & opts) { - store(receiver_opts_, opts); - } - - /// @see proton::container::receiver_options - class receiver_options receiver_options() const { - return load(receiver_opts_); - } - - /// @see proton::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); - } - - /// @see proton::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( - const std::string &url_str, const Opts& opts, const connection_options& copts, - T (connection::*open_fn)(const std::string&, const Opts&)) - { - std::string addr = url(url_str).path(); - std::shared_ptr<thread_safe<connection> > ts_connection = connect(url_str, copts); - std::promise<returned<T> > result_promise; - auto do_open = [ts_connection, addr, opts, open_fn, &result_promise]() { - try { - connection c = ts_connection->unsafe(); - returned<T> s = make_thread_safe((c.*open_fn)(addr, opts)); - result_promise.set_value(s); - } catch (...) { - result_promise.set_exception(std::current_exception()); - } - }; - ts_connection->event_loop()->inject(do_open); - std::future<returned<T> > result_future = result_promise.get_future(); - if (!result_future.valid()) - throw error(url_str+": connection closed"); - return result_future.get(); - } - - mutable std::mutex lock_; - template <class T> T load(const T& v) const { - std::lock_guard<std::mutex> g(lock_); - return v; - } - template <class T> void store(T& v, const T& x) const { - std::lock_guard<std::mutex> g(lock_); - v = x; - } - connection_options client_copts_, server_copts_; - class receiver_options receiver_opts_; - class sender_options sender_opts_; -}; - -} // io -} // proton - -#endif // PROTON_IO_CONTAINER_IMPL_BASE_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index a0eea67..0000000 --- a/proton-c/bindings/cpp/include/proton/io/link_namer.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#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 - * 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 <string> - -namespace proton { - -class connection; - -namespace io { - -/// **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; -}; - -/// *Experimental* - Set the link_namer to use on a connection. -PN_CPP_EXTERN void set_link_namer(connection&, link_namer&); - -} // io -} // proton - -#endif // PROTON_IO_LINK_NAMER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index 8534f21..0000000 --- a/proton-c/bindings/cpp/include/proton/link.hpp +++ /dev/null @@ -1,100 +0,0 @@ -#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> - -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; - - /// **Experimental** - 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; - - /// 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-j/blob/2f85988e/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 deleted file mode 100644 index 99f7558..0000000 --- a/proton-c/bindings/cpp/include/proton/listen_handler.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#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" - -namespace proton { - -// 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() {} - - /// 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. - virtual connection_options on_accept()= 0; - - /// Called if there is a listening error, with an error message. - /// close() will also be called. - virtual void on_error(const std::string&) {} - - /// 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-j/blob/2f85988e/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 deleted file mode 100644 index 4b4ca24..0000000 --- a/proton-c/bindings/cpp/include/proton/listener.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#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 "./fwd.hpp" -#include "./internal/export.hpp" - -#include <string> - -namespace proton { - -/// A listener for incoming connections. -class PN_CPP_CLASS_EXTERN listener { - public: - /// Create an empty listener. - PN_CPP_EXTERN listener(); - - /// @cond INTERNAL - PN_CPP_EXTERN listener(container&, const std::string&); - /// @endcond - - /// Stop listening on the address provided to the call to - /// container::listen that returned this listener. - PN_CPP_EXTERN void stop(); - - private: - std::string url_; - container* container_; -}; - -} // proton - -#endif // PROTON_LISTENER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index 85ccff6..0000000 --- a/proton-c/bindings/cpp/include/proton/message.hpp +++ /dev/null @@ -1,342 +0,0 @@ -#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 "./internal/cached_map.hpp" -#include "./internal/pn_unique_ptr.hpp" - -#include <proton/type_compat.h> - -#include <string> -#include <vector> - -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: - /// **Experimental** - A map of string keys and AMQP scalar - /// values. - class property_map : public internal::cached_map<std::string, scalar> {}; - - /// **Experimental** - A map of AMQP annotation keys and AMQP - /// values. - class annotation_map : public internal::cached_map<annotation_key, value> {}; - - /// 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& 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 - /// necessary. - PN_CPP_EXTERN void encode(std::vector<char> &bytes) 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> &bytes); - - /// @} - - /// @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); - - /// 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 &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. - /// - /// 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 &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. - /// - /// 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 - /// @{ - - /// **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; - - /// **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; - - /// **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; - - /// @} - - /// Default priority assigned to new messages. - PN_CPP_EXTERN static const uint8_t default_priority; - - /// @cond INTERNAL - private: - pn_message_t *pn_msg() const; - - mutable pn_message_t *pn_msg_; - mutable internal::value_ref body_; - mutable property_map application_properties_; - mutable annotation_map message_annotations_; - mutable annotation_map delivery_annotations_; - - /// 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; - /// @endcond -}; - -} // proton - -#endif // PROTON_MESSAGE_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index ee12a17..0000000 --- a/proton-c/bindings/cpp/include/proton/message_id.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#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> - -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. @related 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. @related 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. @related 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. @related message_id -template<> inline std::string get<std::string>(const message_id& x) { return internal::get<std::string>(x); } - -/// @copydoc scalar::coerce -/// @related 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-j/blob/2f85988e/proton-c/bindings/cpp/include/proton/messaging_handler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp deleted file mode 100644 index 6653c43..0000000 --- a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp +++ /dev/null @@ -1,160 +0,0 @@ -#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" - -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::condition()`. -/// -/// 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 -/// @ref 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 &c); - - /// 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 &c); - - /// A message is received. - PN_CPP_EXTERN virtual void on_message(delivery &d, message &m); - - /// A message can be sent. - PN_CPP_EXTERN virtual void on_sendable(sender &s); - - /// The underlying network transport is open - PN_CPP_EXTERN virtual void on_transport_open(transport &t); - - /// The underlying network transport has closed. - PN_CPP_EXTERN virtual void on_transport_close(transport &t); - - /// The underlying network transport has closed with an error - /// condition. - PN_CPP_EXTERN virtual void on_transport_error(transport &t); - - /// The remote peer opened the connection. - PN_CPP_EXTERN virtual void on_connection_open(connection &c); - - /// The remote peer closed the connection. - PN_CPP_EXTERN virtual void on_connection_close(connection &c); - - /// The remote peer closed the connection with an error condition. - PN_CPP_EXTERN virtual void on_connection_error(connection &c); - - /// The remote peer opened the session. - PN_CPP_EXTERN virtual void on_session_open(session &s); - - /// The remote peer closed the session. - PN_CPP_EXTERN virtual void on_session_close(session &s); - - /// The remote peer closed the session with an error condition. - PN_CPP_EXTERN virtual void on_session_error(session &s); - - /// The remote peer opened the link. - PN_CPP_EXTERN virtual void on_receiver_open(receiver& l); - - /// The remote peer detached the link. - PN_CPP_EXTERN virtual void on_receiver_detach(receiver& l); - - /// The remote peer closed the link. - PN_CPP_EXTERN virtual void on_receiver_close(receiver& l); - - /// The remote peer closed the link with an error condition. - PN_CPP_EXTERN virtual void on_receiver_error(receiver& l); - - /// The remote peer opened the link. - PN_CPP_EXTERN virtual void on_sender_open(sender& l); - - /// The remote peer detached the link. - PN_CPP_EXTERN virtual void on_sender_detach(sender& l); - - /// The remote peer closed the link. - PN_CPP_EXTERN virtual void on_sender_close(sender& l); - - /// The remote peer closed the link with an error condition. - PN_CPP_EXTERN virtual void on_sender_error(sender& l); - - /// The receiving peer accepted a transfer. - PN_CPP_EXTERN virtual void on_tracker_accept(tracker &d); - - /// The receiving peer rejected a transfer. - PN_CPP_EXTERN virtual void on_tracker_reject(tracker &d); - - /// The receiving peer released a transfer. - PN_CPP_EXTERN virtual void on_tracker_release(tracker &d); - - /// The receiving peer settled a transfer. - PN_CPP_EXTERN virtual void on_tracker_settle(tracker &d); - - /// The sending peer settled a transfer. - PN_CPP_EXTERN virtual void on_delivery_settle(delivery &d); - - /// **Experimental** - The receiving peer has requested a drain of - /// remaining credit. - PN_CPP_EXTERN virtual void on_sender_drain_start(sender &s); - - /// **Experimental** - The credit outstanding at the time of the - /// call to receiver::drain has been consumed or returned. - PN_CPP_EXTERN virtual void on_receiver_drain_finish(receiver &r); - - /// Fallback error handling. - PN_CPP_EXTERN virtual void on_error(const error_condition &c); -}; - -} // proton - -#endif // PROTON_MESSAGING_HANDLER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index 62b4913..0000000 --- a/proton-c/bindings/cpp/include/proton/namespaces.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#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-j/blob/2f85988e/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 deleted file mode 100644 index f92ac96..0000000 --- a/proton-c/bindings/cpp/include/proton/receiver.hpp +++ /dev/null @@ -1,112 +0,0 @@ -#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; - -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); - - /// **Experimental** - 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; - friend class thread_safe<receiver>; - /// @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-j/blob/2f85988e/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 deleted file mode 100644 index 413e4d4..0000000 --- a/proton-c/bindings/cpp/include/proton/receiver_options.hpp +++ /dev/null @@ -1,106 +0,0 @@ -#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" - -namespace proton { - -/// Options for creating a receiver. -/// -/// Options can be "chained" like this: -/// -/// @code -/// l = container.create_receiver(url, receiver_options().handler(h).auto_settle(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_settle(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. - PN_CPP_EXTERN receiver_options& delivery_mode(delivery_mode); - - /// Automatically accept inbound messages that aren't otherwise - /// released, rejected, or modified (default is true). - PN_CPP_EXTERN receiver_options& auto_accept(bool); - - /// Automatically settle messages (default is true). - 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 &); - - /// Set automated flow control to pre-fetch this many messages - /// (default is 10). Set to zero to disable automatic credit - /// replenishing. - PN_CPP_EXTERN receiver_options& credit_window(int); - - /// @cond INTERNAL - private: - void apply(receiver &) const; - - class impl; - internal::pn_unique_ptr<impl> impl_; - - friend class receiver; - /// @endcond -}; - -} // proton - -#endif // PROTON_RECEIVER_OPTIONS_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index 766feb7..0000000 --- a/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef PROTON_RECONNECT_TIMER_HPP -#define PROTON_RECONNECT_TIMER_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 -/// XXX Needs more discussion - -#include "./internal/export.hpp" -#include "./duration.hpp" -#include "./timestamp.hpp" - -#include <proton/type_compat.h> - -namespace proton { - -/// **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: - 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. - 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. - PN_CPP_EXTERN int next_delay(timestamp now); - - private: - duration first_delay_; - duration max_delay_; - duration increment_; - bool doubling_; - int32_t max_retries_; - duration timeout_; - int32_t retries_; - duration next_delay_; - timestamp timeout_deadline_; -}; - -} // proton - -/// @endcond - -#endif // PROTON_RECONNECT_TIMER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index 3857f06..0000000 --- a/proton-c/bindings/cpp/include/proton/sasl.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#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> - -namespace proton { - -/// SASL information. -class sasl { - /// @cond INTERNAL - sasl(pn_sasl_t* s) : object_(s) {} - /// @endcond - - public: -#if PN_CPP_HAS_DELETED_FUNCTIONS - sasl() = delete; - sasl(const sasl&) = delete; - sasl& operator=(const sasl&) = delete; - sasl& operator=(sasl&&) = delete; -#endif -#if PN_CPP_HAS_DEFAULTED_FUNCTIONS - /// @cond INTERNAL - sasl(sasl&&) = default; - /// @endcond -#endif - - /// 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 internal::factory<sasl>; - /// @endcond -}; - -} // proton - -#endif // PROTON_SASL_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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 deleted file mode 100644 index 0559dd9..0000000 --- a/proton-c/bindings/cpp/include/proton/scalar.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#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/type_compat.h> - -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. -/// @related 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 = get<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` -/// @related 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 = get<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` -/// @related 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-j/blob/2f85988e/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 ca3161a..0000000 --- a/proton-c/bindings/cpp/include/proton/scalar_base.hpp +++ /dev/null @@ -1,215 +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 "./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> - -namespace proton { - -class scalar_base; - -namespace codec { -class decoder; -class encoder; -} - -namespace internal { -template<class T> T get(const scalar_base& s); -} - -/// 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-j/blob/2f85988e/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 deleted file mode 100644 index 8979bb4..0000000 --- a/proton-c/bindings/cpp/include/proton/sender.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#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" - -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; - - /// **Experimental** - 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; - friend class thread_safe<sender>; - /// @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 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
