Skip to content

Commit 6018812

Browse files
committed
Update to latest DelegateMQ library source
1 parent 56bba3a commit 6018812

File tree

15 files changed

+473
-72
lines changed

15 files changed

+473
-72
lines changed

DelegateMQ/DelegateMQ.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
#elif defined(DMQ_TRANSPORT_WIN32_UDP)
9595
#include "predef/dispatcher/Dispatcher.h"
9696
#include "predef/transport/win32-udp/Win32UdpTransport.h"
97+
#elif defined(DMQ_TRANSPORT_MQTT)
98+
#include "predef/dispatcher/Dispatcher.h"
99+
#include "predef/transport/mqtt/MqttTransport.h"
97100
#elif defined(DMQ_TRANSPORT_NONE)
98101
// Create a custom application-specific transport
99102
#else

DelegateMQ/External.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ if(DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_ZEROMQ")
2020
message(FATAL_ERROR "ZeroMQ not found!")
2121
endif()
2222
endif()
23+
24+
# MQTT C library
25+
# https://github.com/eclipse-paho/paho.mqtt.c
26+
if(DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_MQTT")
27+
set_and_check(MQTT_INCLUDE_DIR "${DMQ_ROOT_DIR}/../../../mqtt/paho-c/include")
28+
set_and_check(MQTT_LIBRARY_DIR "${DMQ_ROOT_DIR}/../../../mqtt/paho-c/lib")
29+
set_and_check(MQTT_BINARY_DIR "${DMQ_ROOT_DIR}/../../../mqtt/paho-c/bin")
30+
#set_and_check(MQTT_INCLUDE_DIR "/usr/local/include")
31+
#set_and_check(MQTT_LIBRARY_DIR "/usr/local/lib")
32+
#set_and_check(MQTT_BINARY_DIR "/usr/local/bin/MQTTVersion")
33+
endif()
2334

2435
# MessagePack C++ library (msgpack.hpp)
2536
# https://github.com/msgpack/msgpack-c/tree/cpp_master

DelegateMQ/Predef.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,22 @@ elseif (DMQ_SERIALIZE STREQUAL "DMQ_SERIALIZE_RAPIDJSON")
2626
add_compile_definitions(DMQ_SERIALIZE_RAPIDJSON)
2727
elseif (DMQ_SERIALIZE STREQUAL "DMQ_SERIALIZE_MSGPACK")
2828
add_compile_definitions(DMQ_SERIALIZE_MSGPACK)
29+
else()
30+
message(FATAL_ERROR "Must set DMQ_SERIALIZE option.")
2931
endif()
3032

3133
if (DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_NONE")
3234
add_compile_definitions(DMQ_TRANSPORT_NONE)
3335
elseif (DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_ZEROMQ")
3436
add_compile_definitions(DMQ_TRANSPORT_ZEROMQ)
37+
elseif (DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_MQTT")
38+
add_compile_definitions(DMQ_TRANSPORT_MQTT)
3539
elseif (DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_WIN32_PIPE")
3640
add_compile_definitions(DMQ_TRANSPORT_WIN32_PIPE)
3741
elseif (DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_WIN32_UDP")
3842
add_compile_definitions(DMQ_TRANSPORT_WIN32_UDP)
43+
else()
44+
message(FATAL_ERROR "Must set DMQ_TRANSPORT option.")
3945
endif()
4046

4147
if (DMQ_ALLOCATOR STREQUAL "ON")

DelegateMQ/delegate/Delegate.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ class DelegateFree<RetType(Args...)> : public Delegate<RetType(Args...)> {
140140
/// @brief Creates a copy of the current object.
141141
/// @details Clones the current instance of the class by creating a new object
142142
/// and copying the state of the current object to it.
143-
/// @return A pointer to a new `ClassType` instance.
144-
/// @post The caller is responsible for deleting the clone object.
143+
/// @return A pointer to a new `ClassType` instance or nullptr if allocation fails.
144+
/// @post The caller is responsible for deleting the clone object and checking for
145+
/// nullptr.
145146
virtual ClassType* Clone() const override {
146147
return new(std::nothrow) ClassType(*this);
147148
}
@@ -349,8 +350,9 @@ class DelegateMember<TClass, RetType(Args...)> : public Delegate<RetType(Args...
349350
/// @brief Creates a copy of the current object.
350351
/// @details Clones the current instance of the class by creating a new object
351352
/// and copying the state of the current object to it.
352-
/// @return A pointer to a new `ClassType` instance.
353-
/// @post The caller is responsible for deleting the clone object.
353+
/// @return A pointer to a new `ClassType` instance or nullptr if allocation fails.
354+
/// @post The caller is responsible for deleting the clone object and checking for
355+
/// nullptr.
354356
virtual ClassType* Clone() const override {
355357
return new(std::nothrow) ClassType(*this);
356358
}
@@ -547,8 +549,9 @@ class DelegateFunction<RetType(Args...)> : public Delegate<RetType(Args...)> {
547549
/// @brief Creates a copy of the current object.
548550
/// @details Clones the current instance of the class by creating a new object
549551
/// and copying the state of the current object to it.
550-
/// @return A pointer to a new `ClassType` instance.
551-
/// @post The caller is responsible for deleting the clone object.
552+
/// @return A pointer to a new `ClassType` instance or nullptr if allocation fails.
553+
/// @post The caller is responsible for deleting the clone object and checking for
554+
/// nullptr.
552555
virtual ClassType* Clone() const override {
553556
return new(std::nothrow) ClassType(*this);
554557
}

DelegateMQ/delegate/DelegateAsync.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ class DelegateFreeAsync<RetType(Args...)> : public DelegateFree<RetType(Args...)
182182
/// @brief Creates a copy of the current object.
183183
/// @details Clones the current instance of the class by creating a new object
184184
/// and copying the state of the current object to it.
185-
/// @return A pointer to a new `ClassType` instance.
186-
/// @post The caller is responsible for deleting the clone object.
187-
/// @throws std::bad_alloc If dynamic memory allocation fails and DMQ_ASSERTS not defined.
185+
/// @return A pointer to a new `ClassType` instance or nullptr if allocation fails.
186+
/// @post The caller is responsible for deleting the clone object and checking for
187+
/// nullptr.
188188
virtual ClassType* Clone() const override {
189189
return new(std::nothrow) ClassType(*this);
190190
}
@@ -482,9 +482,9 @@ class DelegateMemberAsync<TClass, RetType(Args...)> : public DelegateMember<TCla
482482
/// @brief Creates a copy of the current object.
483483
/// @details Clones the current instance of the class by creating a new object
484484
/// and copying the state of the current object to it.
485-
/// @return A pointer to a new `ClassType` instance.
486-
/// @post The caller is responsible for deleting the clone object.
487-
/// @throws std::bad_alloc If dynamic memory allocation fails and DMQ_ASSERTS not defined.
485+
/// @return A pointer to a new `ClassType` instance or nullptr if allocation fails.
486+
/// @post The caller is responsible for deleting the clone object and checking for
487+
/// nullptr.
488488
virtual ClassType* Clone() const override {
489489
return new(std::nothrow) ClassType(*this);
490490
}
@@ -723,9 +723,9 @@ class DelegateFunctionAsync<RetType(Args...)> : public DelegateFunction<RetType(
723723
/// @brief Creates a copy of the current object.
724724
/// @details Clones the current instance of the class by creating a new object
725725
/// and copying the state of the current object to it.
726-
/// @return A pointer to a new `ClassType` instance.
727-
/// @post The caller is responsible for deleting the clone object.
728-
/// @throws std::bad_alloc If dynamic memory allocation fails and DMQ_ASSERTS not defined.
726+
/// @return A pointer to a new `ClassType` instance or nullptr if allocation fails.
727+
/// @post The caller is responsible for deleting the clone object and checking for
728+
/// nullptr.
729729
virtual ClassType* Clone() const override {
730730
return new(std::nothrow) ClassType(*this);
731731
}

DelegateMQ/delegate/DelegateAsyncWait.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ class DelegateFreeAsyncWait<RetType(Args...)> : public DelegateFree<RetType(Args
208208
/// @brief Creates a copy of the current object.
209209
/// @details Clones the current instance of the class by creating a new object
210210
/// and copying the state of the current object to it.
211-
/// @return A pointer to a new `ClassType` instance.
212-
/// @post The caller is responsible for deleting the clone object.
213-
/// @throws std::bad_alloc If dynamic memory allocation fails and DMQ_ASSERTS not defined.
211+
/// @return A pointer to a new `ClassType` instance or nullptr if allocation fails.
212+
/// @post The caller is responsible for deleting the clone object and checking for
213+
/// nullptr.
214214
virtual ClassType* Clone() const override {
215215
return new(std::nothrow) ClassType(*this);
216216
}
@@ -611,9 +611,9 @@ class DelegateMemberAsyncWait<TClass, RetType(Args...)> : public DelegateMember<
611611
/// @brief Creates a copy of the current object.
612612
/// @details Clones the current instance of the class by creating a new object
613613
/// and copying the state of the current object to it.
614-
/// @return A pointer to a new `ClassType` instance.
615-
/// @post The caller is responsible for deleting the clone object.
616-
/// @throws std::bad_alloc If dynamic memory allocation fails and DMQ_ASSERTS not defined.
614+
/// @return A pointer to a new `ClassType` instance or nullptr if allocation fails.
615+
/// @post The caller is responsible for deleting the clone object and checking for
616+
/// nullptr.
617617
virtual ClassType* Clone() const override {
618618
return new(std::nothrow) ClassType(*this);
619619
}
@@ -933,9 +933,9 @@ class DelegateFunctionAsyncWait<RetType(Args...)> : public DelegateFunction<RetT
933933
/// @brief Creates a copy of the current object.
934934
/// @details Clones the current instance of the class by creating a new object
935935
/// and copying the state of the current object to it.
936-
/// @return A pointer to a new `ClassType` instance.
937-
/// @post The caller is responsible for deleting the clone object.
938-
/// @throws std::bad_alloc If dynamic memory allocation fails and DMQ_ASSERTS not defined.
936+
/// @return A pointer to a new `ClassType` instance or nullptr if allocation fails.
937+
/// @post The caller is responsible for deleting the clone object and checking for
938+
/// nullptr.
939939
virtual ClassType* Clone() const override {
940940
return new(std::nothrow) ClassType(*this);
941941
}

DelegateMQ/delegate/DelegateOpt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
using xlist = std::list<T, Alloc>;
3434

3535
typedef std::basic_ostringstream<char, std::char_traits<char>> xostringstream;
36+
typedef std::basic_stringstream<char, std::char_traits<char>> xstringstream;
3637

3738
// Not using xallocator; define as nothing
3839
#define XALLOCATOR

0 commit comments

Comments
 (0)