Skip to content

Commit 99ed2b0

Browse files
Merge branch 'BehaviorTree:master' into master
2 parents e525e28 + 2bc72fd commit 99ed2b0

File tree

174 files changed

+6521
-9075
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+6521
-9075
lines changed

3rdparty/cppzmq/LICENSE

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Permission is hereby granted, free of charge, to any person obtaining a copy
2+
of this software and associated documentation files (the "Software"), to
3+
deal in the Software without restriction, including without limitation the
4+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
5+
sell copies of the Software, and to permit persons to whom the Software is
6+
furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in
9+
all copies or substantial portions of the Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
16+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
17+
IN THE SOFTWARE.

3rdparty/cppzmq/README.md

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
[![CI](https://github.com/zeromq/cppzmq/actions/workflows/ci.yml/badge.svg)](https://github.com/zeromq/cppzmq/actions)
2+
[![Coverage Status](https://coveralls.io/repos/github/zeromq/cppzmq/badge.svg?branch=master)](https://coveralls.io/github/zeromq/cppzmq?branch=master)
3+
[![License](https://img.shields.io/github/license/zeromq/cppzmq.svg)](https://github.com/zeromq/cppzmq/blob/master/LICENSE)
4+
5+
Introduction & Design Goals
6+
===========================
7+
8+
cppzmq is a C++ binding for libzmq. It has the following design goals:
9+
- cppzmq maps the libzmq C API to C++ concepts. In particular:
10+
- it is type-safe (the libzmq C API exposes various class-like concepts as void*)
11+
- it provides exception-based error handling (the libzmq C API provides errno-based error handling)
12+
- it provides RAII-style classes that automate resource management (the libzmq C API requires the user to take care to free resources explicitly)
13+
- cppzmq is a light-weight, header-only binding. You only need to include the header file zmq.hpp (and maybe zmq_addon.hpp) to use it.
14+
- zmq.hpp is meant to contain direct mappings of the abstractions provided by the libzmq C API, while zmq_addon.hpp provides additional higher-level abstractions.
15+
16+
There are other C++ bindings for ZeroMQ with different design goals. In particular, none of the following bindings are header-only:
17+
- [zmqpp](https://github.com/zeromq/zmqpp) is a high-level binding to libzmq.
18+
- [czmqpp](https://github.com/zeromq/czmqpp) is a binding based on the high-level czmq API.
19+
- [fbzmq](https://github.com/facebook/fbzmq) is a binding that integrates with Apache Thrift and provides higher-level abstractions in addition. It requires C++14.
20+
21+
Supported platforms
22+
===================
23+
24+
- Only a subset of the platforms that are supported by libzmq itself are supported. Some features already require a compiler supporting C++11. In the future, probably all features will require C++11. To build and run the tests, CMake and Catch are required.
25+
- Any libzmq 4.x version is expected to work. DRAFT features may only work for the most recent tested version. Currently explicitly tested libzmq versions are
26+
- 4.2.0 (without DRAFT API)
27+
- 4.3.4 (with and without DRAFT API)
28+
- Platforms with full support (i.e. CI executing build and tests)
29+
- Ubuntu 18.04 x64 (with gcc 4.8.5, 5.5.0, 7.5.0)
30+
- Ubuntu 20.04 x64 (with gcc 9.3.0, 10.3.0 and clang 12)
31+
- Visual Studio 2017 x64
32+
- Visual Studio 2019 x64
33+
- macOS 10.15 (with clang 12, without DRAFT API)
34+
- Additional platforms that are known to work:
35+
- We have no current reports on additional platforms that are known to work yet. Please add your platform here. If CI can be provided for them with a cloud-based CI service working with GitHub, you are invited to add CI, and make it possible to be included in the list above.
36+
- Additional platforms that probably work:
37+
- Any platform supported by libzmq that provides a sufficiently recent gcc (4.8.1 or newer) or clang (3.4.1 or newer)
38+
- Visual Studio 2012+ x86/x64
39+
40+
Examples
41+
========
42+
These examples require at least C++11.
43+
```c++
44+
#include <zmq.hpp>
45+
46+
int main()
47+
{
48+
zmq::context_t ctx;
49+
zmq::socket_t sock(ctx, zmq::socket_type::push);
50+
sock.bind("inproc://test");
51+
sock.send(zmq::str_buffer("Hello, world"), zmq::send_flags::dontwait);
52+
}
53+
```
54+
This a more complex example where we send and receive multi-part messages over TCP with a wildcard port.
55+
```c++
56+
#include <iostream>
57+
#include <zmq_addon.hpp>
58+
59+
int main()
60+
{
61+
zmq::context_t ctx;
62+
zmq::socket_t sock1(ctx, zmq::socket_type::push);
63+
zmq::socket_t sock2(ctx, zmq::socket_type::pull);
64+
sock1.bind("tcp://127.0.0.1:*");
65+
const std::string last_endpoint =
66+
sock1.get(zmq::sockopt::last_endpoint);
67+
std::cout << "Connecting to "
68+
<< last_endpoint << std::endl;
69+
sock2.connect(last_endpoint);
70+
71+
std::array<zmq::const_buffer, 2> send_msgs = {
72+
zmq::str_buffer("foo"),
73+
zmq::str_buffer("bar!")
74+
};
75+
if (!zmq::send_multipart(sock1, send_msgs))
76+
return 1;
77+
78+
std::vector<zmq::message_t> recv_msgs;
79+
const auto ret = zmq::recv_multipart(
80+
sock2, std::back_inserter(recv_msgs));
81+
if (!ret)
82+
return 1;
83+
std::cout << "Got " << *ret
84+
<< " messages" << std::endl;
85+
return 0;
86+
}
87+
```
88+
89+
See the `examples` directory for more examples. When the project is compiled with tests enabled, each example gets compiled to an executable.
90+
91+
92+
API Overview
93+
============
94+
95+
For an extensive overview of the `zmq.hpp` API in use, see this [Tour of CPPZMQ by @brettviren](https://brettviren.github.io/cppzmq-tour/index.html).
96+
97+
Bindings for libzmq in `zmq.hpp`:
98+
99+
Types:
100+
* class `zmq::context_t`
101+
* enum `zmq::ctxopt`
102+
* class `zmq::socket_t`
103+
* class `zmq::socket_ref`
104+
* enum `zmq::socket_type`
105+
* enum `zmq::sockopt`
106+
* enum `zmq::send_flags`
107+
* enum `zmq::recv_flags`
108+
* class `zmq::message_t`
109+
* class `zmq::const_buffer`
110+
* class `zmq::mutable_buffer`
111+
* struct `zmq::recv_buffer_size`
112+
* alias `zmq::send_result_t`
113+
* alias `zmq::recv_result_t`
114+
* alias `zmq::recv_buffer_result_t`
115+
* class `zmq::error_t`
116+
* class `zmq::monitor_t`
117+
* struct `zmq_event_t`,
118+
* alias `zmq::free_fn`,
119+
* alias `zmq::pollitem_t`,
120+
* alias `zmq::fd_t`
121+
* class `zmq::poller_t` DRAFT
122+
* enum `zmq::event_flags` DRAFT
123+
* enum `zmq::poller_event` DRAFT
124+
125+
Functions:
126+
* `zmq::version`
127+
* `zmq::poll`
128+
* `zmq::proxy`
129+
* `zmq::proxy_steerable`
130+
* `zmq::buffer`
131+
* `zmq::str_buffer`
132+
133+
Extra high-level types and functions `zmq_addon.hpp`:
134+
135+
Types:
136+
* class `zmq::multipart_t`
137+
* class `zmq::active_poller_t` DRAFT
138+
139+
Functions:
140+
* `zmq::recv_multipart`
141+
* `zmq::send_multipart`
142+
* `zmq::send_multipart_n`
143+
* `zmq::encode`
144+
* `zmq::decode`
145+
146+
Compatibility Guidelines
147+
========================
148+
149+
The users of cppzmq are expected to follow the guidelines below to ensure not to break when upgrading cppzmq to newer versions (non-exhaustive list):
150+
151+
* Do not depend on any macros defined in cppzmq unless explicitly declared public here.
152+
153+
The following macros may be used by consumers of cppzmq: `CPPZMQ_VERSION`, `CPPZMQ_VERSION_MAJOR`, `CPPZMQ_VERSION_MINOR`, `CPPZMQ_VERSION_PATCH`.
154+
155+
Contribution policy
156+
===================
157+
158+
The contribution policy is at: http://rfc.zeromq.org/spec:22
159+
160+
Build instructions
161+
==================
162+
163+
Build steps:
164+
165+
1. Build [libzmq](https://github.com/zeromq/libzmq) via cmake. This does an out of source build and installs the build files
166+
- download and unzip the lib, cd to directory
167+
- mkdir build
168+
- cd build
169+
- cmake ..
170+
- sudo make -j4 install
171+
172+
2. Build cppzmq via cmake. This does an out of source build and installs the build files
173+
- download and unzip the lib, cd to directory
174+
- mkdir build
175+
- cd build
176+
- cmake ..
177+
- sudo make -j4 install
178+
179+
3. Build cppzmq via [vcpkg](https://github.com/Microsoft/vcpkg/). This does an out of source build and installs the build files
180+
- git clone https://github.com/Microsoft/vcpkg.git
181+
- cd vcpkg
182+
- ./bootstrap-vcpkg.sh # bootstrap-vcpkg.bat for Powershell
183+
- ./vcpkg integrate install
184+
- ./vcpkg install cppzmq
185+
186+
Using this:
187+
188+
A cmake find package scripts is provided for you to easily include this library.
189+
Add these lines in your CMakeLists.txt to include the headers and library files of
190+
cpp zmq (which will also include libzmq for you).
191+
192+
```
193+
#find cppzmq wrapper, installed by make of cppzmq
194+
find_package(cppzmq)
195+
target_link_libraries(*Your Project Name* cppzmq)
196+
```

3rdparty/cppzmq/zmq.hpp

+47-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147

148148
/* Version macros for compile-time API version detection */
149149
#define CPPZMQ_VERSION_MAJOR 4
150-
#define CPPZMQ_VERSION_MINOR 9
150+
#define CPPZMQ_VERSION_MINOR 10
151151
#define CPPZMQ_VERSION_PATCH 0
152152

153153
#define CPPZMQ_VERSION \
@@ -538,6 +538,11 @@ class message_t
538538
throw error_t();
539539
memcpy(data(), data_, size_);
540540
}
541+
542+
void rebuild(const std::string &str)
543+
{
544+
rebuild(str.data(), str.size());
545+
}
541546

542547
void rebuild(void *data_, size_t size_, free_fn *ffn_, void *hint_ = ZMQ_NULLPTR)
543548
{
@@ -1477,6 +1482,9 @@ ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_CURVE_SERVER, curve_server, int);
14771482
#ifdef ZMQ_CURVE_SERVERKEY
14781483
ZMQ_DEFINE_ARRAY_OPT_BIN_OR_Z85(ZMQ_CURVE_SERVERKEY, curve_serverkey);
14791484
#endif
1485+
#ifdef ZMQ_DISCONNECT_MSG
1486+
ZMQ_DEFINE_ARRAY_OPT_BINARY(ZMQ_DISCONNECT_MSG, disconnect_msg);
1487+
#endif
14801488
#ifdef ZMQ_EVENTS
14811489
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_EVENTS, events, int);
14821490
#endif
@@ -1517,6 +1525,9 @@ ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_HEARTBEAT_TIMEOUT, heartbeat_timeout, int);
15171525
#ifdef ZMQ_HEARTBEAT_TTL
15181526
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_HEARTBEAT_TTL, heartbeat_ttl, int);
15191527
#endif
1528+
#ifdef ZMQ_HELLO_MSG
1529+
ZMQ_DEFINE_ARRAY_OPT_BINARY(ZMQ_HELLO_MSG, hello_msg);
1530+
#endif
15201531
#ifdef ZMQ_IMMEDIATE
15211532
ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_IMMEDIATE, immediate, int);
15221533
#endif
@@ -1562,6 +1573,9 @@ ZMQ_DEFINE_ARRAY_OPT(ZMQ_PLAIN_PASSWORD, plain_password);
15621573
#ifdef ZMQ_PLAIN_USERNAME
15631574
ZMQ_DEFINE_ARRAY_OPT(ZMQ_PLAIN_USERNAME, plain_username);
15641575
#endif
1576+
#ifdef ZMQ_PRIORITY
1577+
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_PRIORITY, priority, int);
1578+
#endif
15651579
#ifdef ZMQ_USE_FD
15661580
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_USE_FD, use_fd, int);
15671581
#endif
@@ -1589,6 +1603,9 @@ ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_RECONNECT_IVL, reconnect_ivl, int);
15891603
#ifdef ZMQ_RECONNECT_IVL_MAX
15901604
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_RECONNECT_IVL_MAX, reconnect_ivl_max, int);
15911605
#endif
1606+
#ifdef ZMQ_RECONNECT_STOP
1607+
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_RECONNECT_STOP, reconnect_stop, int);
1608+
#endif
15921609
#ifdef ZMQ_RECOVERY_IVL
15931610
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_RECOVERY_IVL, recovery_ivl, int);
15941611
#endif
@@ -1619,9 +1636,15 @@ ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_SNDHWM, sndhwm, int);
16191636
#ifdef ZMQ_SNDTIMEO
16201637
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_SNDTIMEO, sndtimeo, int);
16211638
#endif
1639+
#ifdef ZMQ_SOCKS_PASSWORD
1640+
ZMQ_DEFINE_ARRAY_OPT(ZMQ_SOCKS_PASSWORD, socks_password);
1641+
#endif
16221642
#ifdef ZMQ_SOCKS_PROXY
16231643
ZMQ_DEFINE_ARRAY_OPT(ZMQ_SOCKS_PROXY, socks_proxy);
16241644
#endif
1645+
#ifdef ZMQ_SOCKS_USERNAME
1646+
ZMQ_DEFINE_ARRAY_OPT(ZMQ_SOCKS_USERNAME, socks_username);
1647+
#endif
16251648
#ifdef ZMQ_STREAM_NOTIFY
16261649
ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_STREAM_NOTIFY, stream_notify, int);
16271650
#endif
@@ -1679,6 +1702,9 @@ ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_XPUB_VERBOSER, xpub_verboser, int);
16791702
#ifdef ZMQ_XPUB_MANUAL
16801703
ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_XPUB_MANUAL, xpub_manual, int);
16811704
#endif
1705+
#ifdef ZMQ_XPUB_MANUAL_LAST_VALUE
1706+
ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_XPUB_MANUAL_LAST_VALUE, xpub_manual_last_value, int);
1707+
#endif
16821708
#ifdef ZMQ_XPUB_NODROP
16831709
ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_XPUB_NODROP, xpub_nodrop, int);
16841710
#endif
@@ -2637,6 +2663,17 @@ template<typename T = no_user_data> class poller_t
26372663
add_impl(socket, events, nullptr);
26382664
}
26392665

2666+
template<
2667+
typename Dummy = void,
2668+
typename =
2669+
typename std::enable_if<!std::is_same<T, no_user_data>::value, Dummy>::type>
2670+
void add(fd_t fd, event_flags events, T *user_data)
2671+
{
2672+
add_impl(fd, events, user_data);
2673+
}
2674+
2675+
void add(fd_t fd, event_flags events) { add_impl(fd, events, nullptr); }
2676+
26402677
void remove(zmq::socket_ref socket)
26412678
{
26422679
if (0 != zmq_poller_remove(poller_ptr.get(), socket.handle())) {
@@ -2703,6 +2740,15 @@ template<typename T = no_user_data> class poller_t
27032740
throw error_t();
27042741
}
27052742
}
2743+
2744+
void add_impl(fd_t fd, event_flags events, T *user_data)
2745+
{
2746+
if (0
2747+
!= zmq_poller_add_fd(poller_ptr.get(), fd, user_data,
2748+
static_cast<short>(events))) {
2749+
throw error_t();
2750+
}
2751+
}
27062752
};
27072753
#endif // defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) && defined(ZMQ_HAVE_POLLER)
27082754

3rdparty/cppzmq/zmq_addon.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ inline bool is_little_endian()
7777
inline void write_network_order(unsigned char *buf, const uint32_t value)
7878
{
7979
if (is_little_endian()) {
80-
ZMQ_CONSTEXPR_VAR uint32_t mask = std::numeric_limits<std::uint8_t>::max();
80+
ZMQ_CONSTEXPR_VAR uint32_t mask = (std::numeric_limits<std::uint8_t>::max)();
8181
*buf++ = static_cast<unsigned char>((value >> 24) & mask);
8282
*buf++ = static_cast<unsigned char>((value >> 16) & mask);
8383
*buf++ = static_cast<unsigned char>((value >> 8) & mask);
@@ -224,12 +224,12 @@ message_t encode(const Range &parts)
224224
// First pass check sizes
225225
for (const auto &part : parts) {
226226
const size_t part_size = part.size();
227-
if (part_size > std::numeric_limits<std::uint32_t>::max()) {
227+
if (part_size > (std::numeric_limits<std::uint32_t>::max)()) {
228228
// Size value must fit into uint32_t.
229229
throw std::range_error("Invalid size, message part too large");
230230
}
231231
const size_t count_size =
232-
part_size < std::numeric_limits<std::uint8_t>::max() ? 1 : 5;
232+
part_size < (std::numeric_limits<std::uint8_t>::max)() ? 1 : 5;
233233
mmsg_size += part_size + count_size;
234234
}
235235

@@ -240,12 +240,12 @@ message_t encode(const Range &parts)
240240
const unsigned char *part_data =
241241
static_cast<const unsigned char *>(part.data());
242242

243-
if (part_size < std::numeric_limits<std::uint8_t>::max()) {
243+
if (part_size < (std::numeric_limits<std::uint8_t>::max)()) {
244244
// small part
245245
*buf++ = (unsigned char) part_size;
246246
} else {
247247
// big part
248-
*buf++ = std::numeric_limits<uint8_t>::max();
248+
*buf++ = (std::numeric_limits<uint8_t>::max)();
249249
detail::write_network_order(buf, part_size);
250250
buf += sizeof(part_size);
251251
}
@@ -279,7 +279,7 @@ template<class OutputIt> OutputIt decode(const message_t &encoded, OutputIt out)
279279

280280
while (source < limit) {
281281
size_t part_size = *source++;
282-
if (part_size == std::numeric_limits<std::uint8_t>::max()) {
282+
if (part_size == (std::numeric_limits<std::uint8_t>::max)()) {
283283
if (static_cast<size_t>(limit - source) < sizeof(uint32_t)) {
284284
throw std::out_of_range(
285285
"Malformed encoding, overflow in reading size");
@@ -343,10 +343,10 @@ class multipart_t
343343
multipart_t(message_t &&message) { add(std::move(message)); }
344344

345345
// Move constructor
346-
multipart_t(multipart_t &&other) { m_parts = std::move(other.m_parts); }
346+
multipart_t(multipart_t &&other) ZMQ_NOTHROW { m_parts = std::move(other.m_parts); }
347347

348348
// Move assignment operator
349-
multipart_t &operator=(multipart_t &&other)
349+
multipart_t &operator=(multipart_t &&other) ZMQ_NOTHROW
350350
{
351351
m_parts = std::move(other.m_parts);
352352
return *this;

0 commit comments

Comments
 (0)