4 #include <boost/signals2.hpp> 5 #include <boost/optional.hpp> 42 typedef boost::signals2::signal<int ()>
signal;
47 cerr <<
"Consumed: " << val <<
endl;
61 int addresses[] = {1,2,3,0,0,0,2,4,4,4,4,4,1,1,2,1,1,-1};
62 int want_val[] = {0,1,2,3,4,5,2,0,1,2,3,4,1,2,3,3,4,-1};
67 for (
int ind=0; addresses[ind] >= 0; ++ind) {
68 int addr = addresses[ind];
69 if (addr < 0) {
break; }
70 int want = want_val[ind];
71 int got = fanout(addr);
72 cerr <<
"addr=" << addr <<
" got:" << got <<
" want:" << want <<
endl;
87 consumer0.
sig.connect(boost::ref(addr0));
88 consumer1.
sig.connect(boost::ref(addr1));
90 cerr << consumer0() <<
endl;
91 cerr << consumer1() <<
endl;
104 addr0.connect(boost::ref(fanout));
105 addr1.
connect(boost::ref(fanout));
108 consumer0.
sig.connect(boost::ref(addr0));
109 consumer1.
sig.connect(boost::ref(addr1));
111 cerr << consumer1() <<
endl;
112 cerr << consumer0() <<
endl;
113 cerr << consumer0() <<
endl;
114 cerr << consumer0() <<
endl;
115 cerr << consumer1() <<
endl;
116 cerr << consumer0() <<
endl;
123 Counter
c1(10),c2(20),c3(30);
128 boost::signals2::signal< int (), Fanin< std::vector<int> > > sig;
133 for (
int ind=0; ind<10; ++ind) {
moved to templated version in Faninout.h
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
void test_fanout_addressing()
void address(const address_type &addr)
Register an address.
void connect(const slot &s)
signal::slot_type slot_type
void test_plug_and_play()
boost::signals2::signal< int()> signal
constexpr std::enable_if_t< are_cv_compatible< TO, FROM >::value, std::add_pointer_t< std::remove_pointer_t< TO > > > addr(FROM &from)
void connect(const slot &s)
QTextStream & endl(QTextStream &s)