17 #ifndef ZMQPP_MESSAGE_HPP_
18 #define ZMQPP_MESSAGE_HPP_
23 #include <unordered_map>
61 template <
typename T,
typename ...Args>
65 add(part, std::forward<Args>(args)...);
69 size_t size(
size_t const part)
const;
70 std::string
get(
size_t const part)
const;
72 void get(int8_t& integer,
size_t const part)
const;
73 void get(int16_t& integer,
size_t const part)
const;
74 void get(int32_t& integer,
size_t const part)
const;
75 void get(int64_t& integer,
size_t const part)
const;
76 void get(
signal& sig,
size_t const part)
const;
78 void get(uint8_t& unsigned_integer,
size_t const part)
const;
79 void get(uint16_t& unsigned_integer,
size_t const part)
const;
80 void get(uint32_t& unsigned_integer,
size_t const part)
const;
81 void get(uint64_t& unsigned_integer,
size_t const part)
const;
83 void get(
float& floating_point,
size_t const part)
const;
84 void get(
double& double_precision,
size_t const part)
const;
85 void get(
bool& boolean,
size_t const part)
const;
87 void get(std::string& string,
size_t const part)
const;
91 template<
typename Type>
92 Type
get(
size_t const part)
99 template<
int part=0,
typename T,
typename ...Args>
102 assert(part <
parts());
104 extract<part+1>(args...);
107 template<
int part=0,
typename T>
110 assert(part <
parts());
117 template<
typename Type>
118 void get(Type*& value,
size_t const part)
const
120 value =
static_cast<Type*
>(
raw_data(part));
125 template<
typename Type>
126 void get(Type** value,
size_t const part)
const
128 *value =
static_cast<Type*
>(
raw_data(part));
132 void move(
void* part,
size_t const size, release_function
const& release);
135 template<
typename Object>
138 move(part,
sizeof(Object), &deleter_callback<Object>);
142 template<
typename Type,
typename ...Args>
143 void add(Type
const& part, Args &&...args)
146 add(std::forward<Args>(args)...);
149 template<
typename Type>
156 template<
typename Type>
157 void add_raw(Type *part,
size_t const data_size)
165 template<
typename Type>
168 _parts.push_back(
frame( part, data_size,
nullptr,
nullptr ) );
174 template<
typename Type>
210 void push_front(uint8_t
const unsigned_integer);
211 void push_front(uint16_t
const unsigned_integer);
212 void push_front(uint32_t
const unsigned_integer);
213 void push_front(uint64_t
const unsigned_integer);
216 void push_front(
double const double_precision);
224 void push_back(
void const* part,
size_t const data_size)
229 template<
typename Type>
237 void remove(
size_t const part);
248 void sent(
size_t const part);
251 void const*
raw_data(
size_t const part = 0) const;
252 zmq_msg_t&
raw_msg(
size_t const part = 0);
254 zmq_msg_t& raw_new_msg(
size_t const reserve_data_size);
281 #if (ZMQ_VERSION_MAJOR == 4 && ZMQ_VERSION_MINOR >= 1)
288 bool get_property(
const std::string &property, std::string &out);
302 template<typename Object>
305 delete static_cast<Object*
>(data);
message copy() const
Definition: message.cpp:444
void add(Type const &part, Args &&...args)
Definition: message.hpp:143
bool is_signal() const
Check if the message is a signal.
Definition: message.cpp:483
void extract(T &nextpart)
Definition: message.hpp:108
void extract(T &nextpart, Args &...args)
Definition: message.hpp:100
void move(void *part, size_t const size, release_function const &release)
Definition: message.cpp:107
void const * raw_data(size_t const part=0) const
Definition: message.cpp:66
#define ZMQPP_EXPLICITLY_DELETED
Definition: compatibility.hpp:100
C++ wrapper around zmq.
Definition: actor.cpp:29
message & operator>>(Type &value)
Definition: message.hpp:175
size_t next() NOEXCEPT
Moves the read cursor to the next element.
Definition: message.hpp:278
message(T const &part, Args &&...args)
Definition: message.hpp:62
message & operator<<(int8_t const integer)
Definition: message.cpp:225
std::vector< frame > parts_type
Definition: message.hpp:292
size_t remaining() const NOEXCEPT
Gets the remaining number of parts in the message.
Definition: message.hpp:272
void reset_read_cursor()
Definition: message.cpp:116
zmq_msg_t & raw_msg(size_t const part=0)
Definition: message.cpp:76
static void release_callback(void *data, void *hint)
Definition: message.cpp:475
void push_back(Type const part)
Definition: message.hpp:230
void move(Object *part)
Definition: message.hpp:136
void add_raw(Type *part, size_t const data_size)
Definition: message.hpp:157
void sent(size_t const part)
Definition: message.cpp:465
#define NOEXCEPT
Definition: compatibility.hpp:104
void push_back(void const *part, size_t const data_size)
Definition: message.hpp:224
~message()
Definition: message.cpp:40
size_t read_cursor() const NOEXCEPT
Gets the read cursor.
Definition: message.hpp:267
size_t size(size_t const part) const
Definition: message.cpp:56
std::function< void(void *)> release_function
callback to release user allocated data.
Definition: message.hpp:56
void push_front(void const *part, size_t const size)
Definition: message.cpp:330
void pop_back()
Definition: message.cpp:423
size_t _read_cursor
Definition: message.hpp:294
message()
Definition: message.cpp:34
size_t parts() const
Definition: message.cpp:45
parts_type _parts
Definition: message.hpp:293
void add(Type const part)
Definition: message.hpp:150
a zmq message with optional multipart support
Definition: message.hpp:43
void add_const(Type *part, size_t const data_size)
Definition: message.hpp:166
static void deleter_callback(void *data)
Definition: message.hpp:303
signal
Signal is a 8 bytes integer.
Definition: signal.hpp:23
zmq_msg_t & raw_new_msg()
Definition: message.cpp:86
an internal frame wrapper for a single zmq message
Definition: frame.hpp:33
void pop_front()
Definition: message.cpp:418