Boost logo

Boost Users :

From: tcmichals (tcmichals_at_[hidden])
Date: 2005-12-13 10:01:20


(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<int (int,int,int)> signal_a; boost::signal<void (void)>
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
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net