(Excuse the crude example) I'm trying to create a simple publisher/subscribe
service app, using signals, the issue I'm trying to resolve is how to
register the callbacks correctly to each signal. Callbacks will have
different parameter types. When attempting to typecast the subscriber, it
does not register correctly due to different parameters? Is there a better
way?
Boost::signal< void (void)> simple_t;
boost::signal signal_a; boost::signal
signal_b;
typedef void (*callbackFunc) (void);
typedef callbackFunc func_t;
int Callback1(int, int,int) { ..... return 0;} void callback2( void ) { };
setup()
{
publish("signal/a", signal_a);
publish("signal/b", signal_b);
}
App()
{
Subscribe("signal/a", &callback1);
Subscribe("signal/b", &callback2);
}
API:
void publish(stl::string uri, simple_t &) {
// add uri
// add generic boost::signal??
}
void subscribe(stl::string uri, func_t func) {
//Find entry
simple_t t= find(uri);
t.Connect(func); //This does
}