The examples in this documentation typically use operators to create connections. The operators use the connect function directly, and can be replaced by invocations of connect if preferred.
Chaining
Chaining of components can be done using operator
>>=.
// instantiate all of the components we need signals::storage<void ()> banger; signals::storage<void (float)> floater(2.5f); signals::storage<void (float)> collector(0.0f); // ---Connect the dataflow network ----------------------------- // // ,--------. void() // | banger | -------. // `--------' | // | // V // ,-(send_slot)-. void(float) ,-----------. // | floater | -------------> | collector | // `-------------' `-----------' // // ------------------------------------------------------------- banger >>= floater.send_slot(); floater >>= collector; // signal from banger is will invoke floater.send(), which causes // floater to output 2.5 banger(); BOOST_CHECK_EQUAL(floater.at<0>(), 2.5f); BOOST_CHECK_EQUAL(collector.at<0>(), 2.5f); floater.close(); floater(1.5f); // change the value in floater // we can also signal floater directly, which will again cause it to // output its stored value: invoke(floater); BOOST_CHECK_EQUAL(collector.at<0>(), 1.5f);
Branching
More complex connections can also be made relatively easily using both
operator >>=
and operator |,
with operator |
being used for branching.
signals::storage<void ()> banger; signals::counter<void ()> counter; signals::storage<void (float)> floater(2.5f); signals::storage<void (float)> collector(0.0f); // ---Connect the dataflow network ----------------------------- // // ,--------. void() ,---------. // | banger | -------+-------> | counter | // `--------' | `---------' // | // V // ,-(send_slot)-. void(float) ,-----------. // | floater | -------------> | collector | // `-------------' `-----------' // // ------------------------------------------------------------- banger | counter | floater.send_slot(); floater >>= collector; banger(); BOOST_CHECK_EQUAL(counter.count(), 1); BOOST_CHECK_EQUAL(collector.at<0>(), 2.5f);