[sigc] dynamic signals?



Hello everyone,
I've been looking into libsigc++ briefly, and I like it alot.  I have
one implementation question for you all.  I would like to product the
following behavior:

/***************************************************/
void foo(int i)
{
   std::cout << "called with i="
             << i << std::endl;
}

signal_creator sc;
sc.create("first-signal",sigc::signal<void>());
sc.create("second-signal",sigc::signal<void,int>());

sc.connect("first-signal", sigc::bind(foo,1));
sc.connect("second-signal", sigc::ptr_fun(foo));

sc.emit("first-signal");
sc.emit("second-signal",2);
/***************************************************/

is this possible? my idea was to create a private
std::map<std::string,sigc::signal_base> and insert upon creation.  I
think I may have difficulty when creating both the connect and emit
signatures...

I would assume the "connect" method would be typed with a
"sigc::slot_base" - but I'm curious as to what would happen if a slot
expecting 3 parameters is attached to a signal emitting 1 parameter...

as for the emit signature, I was planning on just overloading it to
take 0 to 7 parameters, and up-cast the signal accordingly before
calling emit

would this work? is there a better way to do it?

Thanks for your time,
Aaron Griffin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]