Skip to content
Snippets Groups Projects
Commit 4a11e6c3 authored by Ramin Yaghoubzadeh Torky's avatar Ramin Yaghoubzadeh Torky
Browse files

C++ convenience bind macro (to avoid future end-user code changes)

Mental note: MQTT backend (seen in Python) needs threaded event delivery
parent 712423de
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,10 @@
#error "Please do not include this file directly, use ipaaca.h instead"
#endif
// Convenience macro to abstract from the bind implementation being used
// and possible future signature changes.
#define IPAACA_BIND_CLASS_HANDLER(fn, inst) std::bind(fn, inst, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
/// Store for local IUs (used in OutputBuffer)
class IUStore: public std::map<std::string, std::shared_ptr<IU> >
......
......@@ -99,7 +99,7 @@ class TesterCpp {
ipaaca::OutputBuffer::ptr ob = ipaaca::OutputBuffer::create("testerCpp");
ipaaca::InputBuffer::ptr ib = ipaaca::InputBuffer::create("testerCpp", std::set<std::string>{"#"}); // MQTT requires # as a wildcard!
ib->set_resend(true);
ib->register_handler(std::bind(&TesterCpp::handle_iu_inbuf, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
ib->register_handler(IPAACA_BIND_CLASS_HANDLER(&TesterCpp::handle_iu_inbuf, this));
std::cout << "Listening for all IU events and sending a Message after 1 sec ..." << std::endl;
sleep(1);
auto msg = ipaaca::IU::create("testcategory");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment