Skip to content

Commit

Permalink
Add missing assignment operators
Browse files Browse the repository at this point in the history
Summary:
related to T13767
- add missing assignment operators
- marked single argument constructors as explicit where needed
- add even more missing includes

Reviewers: ivica

Reviewed By: ivica

Subscribers: iljazovic, miljen

Differential Revision: https://repo.mireo.local/D30813
  • Loading branch information
ksimicevic committed Aug 8, 2024
1 parent b55ec67 commit 0330df7
Show file tree
Hide file tree
Showing 32 changed files with 195 additions and 97 deletions.
13 changes: 8 additions & 5 deletions include/async_mqtt5/detail/async_mutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ class async_mutex {
tracked_op(tracked_op&&) = default;
tracked_op(const tracked_op&) = delete;

using executor_type = tracking_type<Handler, Executor>;
executor_type get_executor() const noexcept {
return _executor;
}
tracked_op& operator=(tracked_op&&) = default;
tracked_op& operator=(const tracked_op&) = delete;

using allocator_type = asio::associated_allocator_t<Handler>;
allocator_type get_allocator() const noexcept {
Expand All @@ -63,6 +61,11 @@ class async_mutex {
return asio::get_associated_cancellation_slot(_handler);
}

using executor_type = tracking_type<Handler, Executor>;
executor_type get_executor() const noexcept {
return _executor;
}

void operator()(error_code ec) {
std::move(_handler)(ec);
}
Expand Down Expand Up @@ -104,7 +107,7 @@ class async_mutex {

public:
template <typename Executor>
async_mutex(Executor&& ex) : _ex(std::forward<Executor>(ex)) {}
explicit async_mutex(Executor&& ex) : _ex(std::forward<Executor>(ex)) {}

async_mutex(const async_mutex&) = delete;
async_mutex& operator=(const async_mutex&) = delete;
Expand Down
1 change: 1 addition & 0 deletions include/async_mqtt5/detail/async_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <type_traits>

#include <boost/asio/associated_executor.hpp>
#include <boost/asio/execution.hpp>
#include <boost/asio/prefer.hpp>
#include <boost/asio/write.hpp>

Expand Down
3 changes: 3 additions & 0 deletions include/async_mqtt5/detail/cancellable_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class cancellable_handler {
cancellable_handler(cancellable_handler&&) = default;
cancellable_handler(const cancellable_handler&) = delete;

cancellable_handler& operator=(cancellable_handler&&) = default;
cancellable_handler& operator=(const cancellable_handler&) = delete;

using allocator_type = asio::associated_allocator_t<Handler>;
allocator_type get_allocator() const noexcept {
return asio::get_associated_allocator(_handler);
Expand Down
11 changes: 10 additions & 1 deletion include/async_mqtt5/detail/control_packet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ class control_packet {

public:
control_packet(control_packet&&) noexcept = default;
control_packet(const control_packet&) noexcept = delete;
control_packet(const control_packet&) = delete;

control_packet& operator=(control_packet&&) noexcept = default;
control_packet& operator=(const control_packet&) = delete;

template <
typename EncodeFun,
Expand Down Expand Up @@ -136,6 +139,12 @@ class packet_id_allocator {
_free_ids.emplace_back(MAX_PACKET_ID, uint16_t(0));
}

packet_id_allocator(packet_id_allocator&&) noexcept = default;
packet_id_allocator(const packet_id_allocator&) = delete;

packet_id_allocator& operator=(packet_id_allocator&&) noexcept = default;
packet_id_allocator& operator=(const packet_id_allocator&) = delete;

uint16_t allocate() {
if (_free_ids.empty()) return 0;
auto& last = _free_ids.back();
Expand Down
13 changes: 8 additions & 5 deletions include/async_mqtt5/impl/assemble_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <string>

#include <boost/asio/append.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/completion_condition.hpp>
#include <boost/asio/dispatch.hpp>
Expand All @@ -24,7 +25,6 @@

#include <async_mqtt5/impl/codecs/message_decoders.hpp>


namespace async_mqtt5::detail {

namespace asio = boost::asio;
Expand Down Expand Up @@ -80,16 +80,19 @@ class assemble_op {
assemble_op(assemble_op&&) noexcept = default;
assemble_op(const assemble_op&) = delete;

using executor_type = typename client_service::executor_type;
executor_type get_executor() const noexcept {
return _svc.get_executor();
}
assemble_op& operator=(assemble_op&&) noexcept = default;
assemble_op& operator=(const assemble_op&) = delete;

using allocator_type = asio::associated_allocator_t<handler_type>;
allocator_type get_allocator() const noexcept {
return asio::get_associated_allocator(_handler);
}

using executor_type = typename client_service::executor_type;
executor_type get_executor() const noexcept {
return _svc.get_executor();
}

template <typename CompletionCondition>
void perform(CompletionCondition cc) {
_read_buff.erase(
Expand Down
12 changes: 12 additions & 0 deletions include/async_mqtt5/impl/async_sender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class write_req {
_handler(std::move(handler))
{}

write_req(write_req&&) = default;
write_req(const write_req&) = delete;

write_req& operator=(write_req&&) = default;
write_req& operator=(const write_req&) = delete;

static serial_num_t next_serial_num(serial_num_t last) {
return last + 1;
}
Expand Down Expand Up @@ -123,6 +129,12 @@ class async_sender {
public:
explicit async_sender(ClientService& svc) : _svc(svc) {}

async_sender(async_sender&&) = default;
async_sender(const async_sender&) = delete;

async_sender& operator=(async_sender&&) = default;
async_sender& operator=(const async_sender&) = delete;

using allocator_type = queue_allocator_type;
allocator_type get_allocator() const noexcept {
return allocator_type {};
Expand Down
3 changes: 3 additions & 0 deletions include/async_mqtt5/impl/autoconnect_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class autoconnect_stream {
replace_next_layer(construct_next_layer());
}

autoconnect_stream(const autoconnect_stream&) = delete;
autoconnect_stream& operator=(const autoconnect_stream&) = delete;

using next_layer_type = stream_type;
next_layer_type& next_layer() {
return *_stream_ptr;
Expand Down
3 changes: 2 additions & 1 deletion include/async_mqtt5/impl/client_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class stream_context<
mqtt_ctx _mqtt_context;
public:
explicit stream_context(std::monostate) {}

stream_context(const stream_context& other) :
_mqtt_context(other._mqtt_context)
{}
Expand Down Expand Up @@ -271,7 +272,7 @@ class client_service {

public:

client_service(
explicit client_service(
const executor_type& ex,
tls_context_type tls_context = {}
) :
Expand Down
16 changes: 11 additions & 5 deletions include/async_mqtt5/impl/connect_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#define ASYNC_MQTT5_CONNECT_OP_HPP

#include <boost/asio/append.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/associated_cancellation_slot.hpp>
#include <boost/asio/cancellation_state.hpp>
#include <boost/asio/consign.hpp>
#include <boost/asio/completion_condition.hpp>
Expand Down Expand Up @@ -76,13 +79,11 @@ class connect_op {
)
{}

connect_op(connect_op&&) noexcept = default;
connect_op(connect_op&&) = default;
connect_op(const connect_op&) = delete;

using executor_type = asio::associated_executor_t<handler_type>;
executor_type get_executor() const noexcept {
return asio::get_associated_executor(_handler);
}
connect_op& operator=(connect_op&&) = default;
connect_op& operator=(const connect_op&) = delete;

using allocator_type = asio::associated_allocator_t<handler_type>;
allocator_type get_allocator() const noexcept {
Expand All @@ -95,6 +96,11 @@ class connect_op {
return _cancellation_state.slot();
}

using executor_type = asio::associated_executor_t<handler_type>;
executor_type get_executor() const noexcept {
return asio::get_associated_executor(_handler);
}

void perform(
const epoints& eps, authority_path ap
) {
Expand Down
4 changes: 2 additions & 2 deletions include/async_mqtt5/impl/disconnect_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class disconnect_op {
disconnect_op(disconnect_op&&) = default;
disconnect_op(const disconnect_op&) = delete;

disconnect_op& operator=(disconnect_op&&) noexcept = default;
disconnect_op& operator=(disconnect_op&&) = default;
disconnect_op& operator=(const disconnect_op&) = delete;

using allocator_type = asio::associated_allocator_t<handler_type>;
Expand Down Expand Up @@ -200,7 +200,7 @@ class terminal_disconnect_op {
terminal_disconnect_op(terminal_disconnect_op&&) = default;
terminal_disconnect_op(const terminal_disconnect_op&) = delete;

terminal_disconnect_op& operator=(terminal_disconnect_op&&) noexcept = default;
terminal_disconnect_op& operator=(terminal_disconnect_op&&) = default;
terminal_disconnect_op& operator=(const terminal_disconnect_op&) = delete;

using allocator_type = asio::associated_allocator_t<handler_type>;
Expand Down
19 changes: 14 additions & 5 deletions include/async_mqtt5/impl/endpoints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#define ASYNC_MQTT5_ENDPOINTS_HPP

#include <boost/asio/append.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/associated_cancellation_slot.hpp>
#include <boost/asio/deferred.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/post.hpp>
Expand Down Expand Up @@ -43,10 +46,8 @@ class resolve_op {
resolve_op(resolve_op&&) = default;
resolve_op(const resolve_op&) = delete;

using executor_type = asio::associated_executor_t<handler_type>;
executor_type get_executor() const noexcept {
return asio::get_associated_executor(_handler);
}
resolve_op& operator=(resolve_op&&) = default;
resolve_op& operator=(const resolve_op&) = delete;

using allocator_type = asio::associated_allocator_t<handler_type>;
allocator_type get_allocator() const noexcept {
Expand All @@ -59,6 +60,11 @@ class resolve_op {
return asio::get_associated_cancellation_slot(_handler);
}

using executor_type = asio::associated_executor_t<handler_type>;
executor_type get_executor() const noexcept {
return asio::get_associated_executor(_handler);
}

void perform() {
namespace asioex = boost::asio::experimental;

Expand Down Expand Up @@ -152,13 +158,16 @@ class endpoints {
_resolver(ex), _connect_timer(timer)
{}

endpoints(const endpoints&) = delete;
endpoints& operator=(const endpoints&) = delete;

void clone_servers(const endpoints& other) {
_servers = other._servers;
}

using executor_type = asio::ip::tcp::resolver::executor_type;
// NOTE: asio::ip::basic_resolver returns executor by value
executor_type get_executor() {
executor_type get_executor() noexcept {
return _resolver.get_executor();
}

Expand Down
9 changes: 6 additions & 3 deletions include/async_mqtt5/impl/ping_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ class ping_op {
ping_op(ping_op&&) noexcept = default;
ping_op(const ping_op&) = delete;

executor_type get_executor() const noexcept {
return _executor;
}
ping_op& operator=(ping_op&&) noexcept = default;
ping_op& operator=(const ping_op&) = delete;

using allocator_type = asio::recycling_allocator<void>;
allocator_type get_allocator() const noexcept {
Expand All @@ -73,6 +72,10 @@ class ping_op {
return _cancellation_state.slot();
}

executor_type get_executor() const noexcept {
return _executor;
}

void perform() {
_ping_timer->expires_after(compute_wait_time());
_ping_timer->async_wait(
Expand Down
14 changes: 9 additions & 5 deletions include/async_mqtt5/impl/publish_rec_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace asio = boost::asio;
template <typename ClientService>
class publish_rec_op {
using client_service = ClientService;

struct on_puback {};
struct on_pubrec {};
struct on_pubrel {};
Expand All @@ -42,23 +43,26 @@ class publish_rec_op {
decoders::publish_message _message;

public:
publish_rec_op(const std::shared_ptr<client_service>& svc_ptr) :
explicit publish_rec_op(const std::shared_ptr<client_service>& svc_ptr) :
_svc_ptr(svc_ptr)
{}

publish_rec_op(publish_rec_op&&) noexcept = default;
publish_rec_op(const publish_rec_op&) = delete;

using executor_type = typename client_service::executor_type;
executor_type get_executor() const noexcept {
return _svc_ptr->get_executor();
}
publish_rec_op& operator=(publish_rec_op&&) noexcept = default;
publish_rec_op& operator=(const publish_rec_op&) = delete;

using allocator_type = asio::recycling_allocator<void>;
allocator_type get_allocator() const noexcept {
return allocator_type {};
}

using executor_type = typename client_service::executor_type;
executor_type get_executor() const noexcept {
return _svc_ptr->get_executor();
}

void perform(decoders::publish_message message) {
auto flags = std::get<2>(message);
auto qos_bits = (flags >> 1) & 0b11;
Expand Down
2 changes: 1 addition & 1 deletion include/async_mqtt5/impl/publish_send_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class publish_send_op {
publish_send_op(publish_send_op&&) = default;
publish_send_op(const publish_send_op&) = delete;

publish_send_op& operator=(publish_send_op&&) noexcept = default;
publish_send_op& operator=(publish_send_op&&) = default;
publish_send_op& operator=(const publish_send_op&) = delete;

using allocator_type = asio::associated_allocator_t<handler_type>;
Expand Down
16 changes: 10 additions & 6 deletions include/async_mqtt5/impl/re_auth_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define ASYNC_MQTT5_RE_AUTH_OP_hpp

#include <boost/asio/detached.hpp>
#include <boost/asio/recycling_allocator.hpp>

#include <async_mqtt5/error.hpp>
#include <async_mqtt5/reason_codes.hpp>
Expand All @@ -34,24 +35,27 @@ class re_auth_op {
any_authenticator& _auth;

public:
re_auth_op(const std::shared_ptr<client_service>& svc_ptr) :
explicit re_auth_op(const std::shared_ptr<client_service>& svc_ptr) :
_svc_ptr(svc_ptr),
_auth(_svc_ptr->_stream_context.mqtt_context().authenticator)
{}

re_auth_op(re_auth_op&&) noexcept = default;
re_auth_op(const re_auth_op&) noexcept = delete;
re_auth_op(const re_auth_op&) = delete;

using executor_type = typename client_service::executor_type;
executor_type get_executor() const noexcept {
return _svc_ptr->get_executor();
}
re_auth_op& operator=(re_auth_op&&) noexcept = default;
re_auth_op& operator=(const re_auth_op&) = delete;

using allocator_type = asio::recycling_allocator<void>;
allocator_type get_allocator() const noexcept {
return allocator_type {};
}

using executor_type = typename client_service::executor_type;
executor_type get_executor() const noexcept {
return _svc_ptr->get_executor();
}

void perform() {
if (_auth.method().empty())
return;
Expand Down
Loading

0 comments on commit 0330df7

Please sign in to comment.