7#if !defined(ASYNC_MQTT_UTIL_STREAM_HPP)
8#define ASYNC_MQTT_UTIL_STREAM_HPP
14#include <boost/asio/async_result.hpp>
16#include <async_mqtt/util/stream_traits.hpp>
17#include <async_mqtt/util/static_vector.hpp>
18#include <async_mqtt/util/ioc_queue.hpp>
19#include <async_mqtt/util/buffer.hpp>
20#include <async_mqtt/error.hpp>
21#include <async_mqtt/util/log.hpp>
23#include <async_mqtt/util/detail/stream_impl.hpp>
26namespace as = boost::asio;
27namespace sys = boost::system;
29template <
typename NextLayer>
32 using this_type = stream<NextLayer>;
33 using impl_type = detail::stream_impl<NextLayer>;
34 using next_layer_type =
typename std::remove_reference<NextLayer>::type;
35 using lowest_layer_type =
36 typename std::remove_reference<
37 decltype(get_lowest_layer(std::declval<next_layer_type&>()))
39 using executor_type = async_mqtt::executor_type<next_layer_type>;
44 std::enable_if_t<!std::is_same_v<std::decay_t<T>, this_type>>* =
nullptr
47 stream(T&& t, Args&&... args)
49 std::make_shared<impl_type>(
51 std::forward<Args>(args)...
58 ASYNC_MQTT_LOG(
"mqtt_impl",
trace)
59 << ASYNC_MQTT_ADD_VALUE(address,
this)
63 stream(this_type&&) =
default;
64 stream(this_type
const&) =
delete;
65 this_type& operator=(this_type&&) =
default;
66 this_type& operator=(this_type
const&) =
delete;
68 next_layer_type
const& next_layer()
const {
69 return impl_->next_layer();
71 next_layer_type& next_layer() {
72 return impl_->next_layer();
75 lowest_layer_type
const& lowest_layer()
const {
76 return impl_->lowest_layer();
78 lowest_layer_type& lowest_layer() {
79 return impl_->lowest_layer();
83 typename CompletionToken = as::default_completion_token_t<executor_type>
85 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
90 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
95 typename CompletionToken = as::default_completion_token_t<executor_type>
97 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
103 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
106 as::any_io_executor get_executor() {
107 return impl_->get_executor();
111 typename CompletionToken = as::default_completion_token_t<executor_type>
113 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
118 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
121 void set_bulk_write(
bool val) {
122 impl_->set_bulk_write(val);
125 template <
typename Executor1>
126 struct rebind_executor {
127 using other = stream<
128 typename NextLayer::template rebind_executor<Executor1>::other
132 void set_bulk_read_buffer_size(std::size_t size) {
133 impl_->set_bulk_read_buffer_size(size);
138 template <
typename Other>
141 stream<Other>&& other
143 :impl_{force_move(other.impl_)}
148 std::shared_ptr<impl_type> impl_;
153#include <async_mqtt/util/impl/stream_read_packet.hpp>
154#include <async_mqtt/util/impl/stream_write_packet.hpp>
155#include <async_mqtt/util/impl/stream_close.hpp>
sys::error_code error_code
sys is a namespace alias of boost::sytem.
Definition error.hpp:56
@ trace
trace level for detaied behavior and reporting issue