Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced move_only_function. #953

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/function2"]
path = external/function2
url = https://github.com/Naios/function2
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 14.0.0
* <<<< breaking change >>>> Replaced std::function with move_only_function. (#953)
* Removed old NetworkTS code. (#952)
* Fixed invalid timing async_shutdown handler call. (#950)
* Improved build system. (#948)

## 13.1.0
* Added clear username and password functionality. (#944)
* Refined utility tools. (#941, #942)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CMAKE_MINIMUM_REQUIRED (VERSION 3.13.0)
PROJECT (mqtt_cpp_iface VERSION 13.1.0)
PROJECT (mqtt_cpp_iface VERSION 14.0.0)

SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MQTT client/server for C++14 based on Boost.Asio

Version 13.1.0 [![Actions Status](https://github.com/redboltz/mqtt_cpp/workflows/CI/badge.svg)](https://github.com/redboltz/mqtt_cpp/actions)[![Build Status](https://dev.azure.com/redboltz/redboltz/_apis/build/status/redboltz.mqtt_cpp?branchName=master)](https://dev.azure.com/redboltz/redboltz/_build/latest?definitionId=6&branchName=master)[![codecov](https://codecov.io/gh/redboltz/mqtt_cpp/branch/master/graph/badge.svg)](https://codecov.io/gh/redboltz/mqtt_cpp)
Version 14.0.0 [![Actions Status](https://github.com/redboltz/mqtt_cpp/workflows/CI/badge.svg)](https://github.com/redboltz/mqtt_cpp/actions)[![Build Status](https://dev.azure.com/redboltz/redboltz/_apis/build/status/redboltz.mqtt_cpp?branchName=master)](https://dev.azure.com/redboltz/redboltz/_build/latest?definitionId=6&branchName=master)[![codecov](https://codecov.io/gh/redboltz/mqtt_cpp/branch/master/graph/badge.svg)](https://codecov.io/gh/redboltz/mqtt_cpp)

Important note https://github.com/redboltz/mqtt_cpp/wiki/News.

Expand Down
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ADD_LIBRARY(check_deps OBJECT EXCLUDE_FROM_ALL ${CHK_MQTT})
# We don't need to actually run the whole compiler. We're just checking that all the includes are valid
# So here we ask for only the syntax checking mode to be used.
# We also don't mind that there might be unused constant variables when doing deps checking.
TARGET_COMPILE_OPTIONS(check_deps PUBLIC -Wno-unused-const-variable $<IF:$<CXX_COMPILER_ID:MSVC>,/Zs,-fsyntax-only>)
TARGET_COMPILE_OPTIONS(check_deps PUBLIC -Wno-unneeded-internal-declaration -Wno-unused-const-variable $<IF:$<CXX_COMPILER_ID:MSVC>,/Zs,-fsyntax-only>)

TARGET_LINK_LIBRARIES (check_deps PUBLIC ${PROJECT_NAME})

Expand Down
52 changes: 26 additions & 26 deletions include/mqtt/broker/broker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,43 +721,43 @@ class broker_t {
pubcomp_props_ = force_move(props);
}

void set_connect_props_handler(std::function<void(v5::properties const&)> h) {
void set_connect_props_handler(move_only_function<void(v5::properties const&)> h) {
h_connect_props_ = force_move(h);
}

void set_disconnect_props_handler(std::function<void(v5::properties const&)> h) {
void set_disconnect_props_handler(move_only_function<void(v5::properties const&)> h) {
h_disconnect_props_ = force_move(h);
}

void set_publish_props_handler(std::function<void(v5::properties const&)> h) {
void set_publish_props_handler(move_only_function<void(v5::properties const&)> h) {
h_publish_props_ = force_move(h);
}

void set_puback_props_handler(std::function<void(v5::properties const&)> h) {
void set_puback_props_handler(move_only_function<void(v5::properties const&)> h) {
h_puback_props_ = force_move(h);
}

void set_pubrec_props_handler(std::function<void(v5::properties const&)> h) {
void set_pubrec_props_handler(move_only_function<void(v5::properties const&)> h) {
h_pubrec_props_ = force_move(h);
}

void set_pubrel_props_handler(std::function<void(v5::properties const&)> h) {
void set_pubrel_props_handler(move_only_function<void(v5::properties const&)> h) {
h_pubrel_props_ = force_move(h);
}

void set_pubcomp_props_handler(std::function<void(v5::properties const&)> h) {
void set_pubcomp_props_handler(move_only_function<void(v5::properties const&)> h) {
h_pubcomp_props_ = force_move(h);
}

void set_subscribe_props_handler(std::function<void(v5::properties const&)> h) {
void set_subscribe_props_handler(move_only_function<void(v5::properties const&)> h) {
h_subscribe_props_ = force_move(h);
}

void set_unsubscribe_props_handler(std::function<void(v5::properties const&)> h) {
void set_unsubscribe_props_handler(move_only_function<void(v5::properties const&)> h) {
h_unsubscribe_props_ = force_move(h);
}

void set_auth_props_handler(std::function<void(v5::properties const&)> h) {
void set_auth_props_handler(move_only_function<void(v5::properties const&)> h) {
h_auth_props_ = force_move(h);
}

Expand Down Expand Up @@ -1174,7 +1174,7 @@ class broker_t {
bool session_present,
bool authenticated,
v5::properties props,
std::function<void(error_code)> finish = [](error_code){}
move_only_function<void(error_code)> finish = [](error_code){}
) {
// Reply to the connect message.
switch (ep.get_protocol_version()) {
Expand All @@ -1184,7 +1184,7 @@ class broker_t {
authenticated ? connect_return_code::accepted
: connect_return_code::not_authorized,
[finish = force_move(finish)]
(error_code ec) {
(error_code ec) mutable {
finish(ec);
}
);
Expand All @@ -1201,7 +1201,7 @@ class broker_t {
: v5::connect_reason_code::not_authorized,
force_move(props),
[finish = force_move(finish)]
(error_code ec) {
(error_code ec) mutable {
finish(ec);
}
);
Expand All @@ -1214,7 +1214,7 @@ class broker_t {
: v5::connect_reason_code::not_authorized,
connack_props_,
[finish = force_move(finish)]
(error_code ec) {
(error_code ec) mutable {
finish(ec);
}
);
Expand Down Expand Up @@ -1792,7 +1792,7 @@ class broker_t {
);
};

std::vector<std::function<void()>> retain_deliver;
std::vector<move_only_function<void()>> retain_deliver;
retain_deliver.reserve(entries.size());

// subscription identifier
Expand Down Expand Up @@ -1906,7 +1906,7 @@ class broker_t {
break;
}

for (auto const& f : retain_deliver) {
for (auto& f : retain_deliver) {
f();
}
return true;
Expand Down Expand Up @@ -2175,16 +2175,16 @@ class broker_t {
v5::properties pubrec_props_;
v5::properties pubrel_props_;
v5::properties pubcomp_props_;
std::function<void(v5::properties const&)> h_connect_props_;
std::function<void(v5::properties const&)> h_disconnect_props_;
std::function<void(v5::properties const&)> h_publish_props_;
std::function<void(v5::properties const&)> h_puback_props_;
std::function<void(v5::properties const&)> h_pubrec_props_;
std::function<void(v5::properties const&)> h_pubrel_props_;
std::function<void(v5::properties const&)> h_pubcomp_props_;
std::function<void(v5::properties const&)> h_subscribe_props_;
std::function<void(v5::properties const&)> h_unsubscribe_props_;
std::function<void(v5::properties const&)> h_auth_props_;
move_only_function<void(v5::properties const&)> h_connect_props_;
move_only_function<void(v5::properties const&)> h_disconnect_props_;
move_only_function<void(v5::properties const&)> h_publish_props_;
move_only_function<void(v5::properties const&)> h_puback_props_;
move_only_function<void(v5::properties const&)> h_pubrec_props_;
move_only_function<void(v5::properties const&)> h_pubrel_props_;
move_only_function<void(v5::properties const&)> h_pubcomp_props_;
move_only_function<void(v5::properties const&)> h_subscribe_props_;
move_only_function<void(v5::properties const&)> h_unsubscribe_props_;
move_only_function<void(v5::properties const&)> h_auth_props_;
bool pingresp_ = true;
bool connack_ = true;
};
Expand Down
6 changes: 3 additions & 3 deletions include/mqtt/broker/session_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class session_states;
* Retained messages do not form part of the Session State in the Server, they are not deleted as a result of a Session ending.
*/
struct session_state {
using will_sender_t = std::function<
using will_sender_t = move_only_function<
void(
session_state const& source_ss,
buffer topic,
Expand Down Expand Up @@ -283,7 +283,7 @@ struct session_state {
}
}

void set_clean_handler(std::function<void()> handler) {
void set_clean_handler(move_only_function<void()> handler) {
clean_handler_ = force_move(handler);
}

Expand Down Expand Up @@ -601,7 +601,7 @@ struct session_state {
std::set<packet_id_t> qos2_publish_handled_;

optional<std::string> response_topic_;
std::function<void()> clean_handler_;
move_only_function<void()> clean_handler_;
};

class session_states {
Expand Down
1 change: 1 addition & 0 deletions include/mqtt/broker/topic_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define MQTT_BROKER_TOPIC_FILTER_HPP

#include <algorithm>
#include <limits>

#include <mqtt/broker/broker_namespace.hpp>
#include <mqtt/string_view.hpp>
Expand Down
Loading