[sigc] slots without functors
- From: Paul Davis <paul linuxaudiosystems com>
- To: libsigc-list gnome org
- Subject: [sigc] slots without functors
- Date: Mon, 26 Sep 2005 13:10:39 -0400
libsigc++ 1.2 formed the basis of a very, very powerful and flexible
undo/redo system that is used within ardour (http://ardour.org/). at the
core of it (developed with Brett Viren), was the use of
typedef SigC::Slot0<void> UndoAction;
We then simply stored a series of UndoActions in a pair of lists, one
for undo, one for redo. Anything you could package up into the functor
represented by a SigC::Slot0<void> (i.e. anything) could be inserted
into the lists.
We are just switching to the current version of libsigc++, and i am
finding that it appears not to allow slots to be declared without a
functor argument. ie, given the above typedef,
UndoAction something_to_undo (mem_fun (*object, &Object::method));
is fine, but
UndoAction something_to_undo;
something_to_undo = mem_fun (*object, &Object::method);
is not, because something_to_undo has no zero-argument constructor.
This same design is also the basis of a similarly flexible key binding
system, in which key events in a GUI trigger actions stored as
SigC::Slot0<void>.
while the no-zero-argument-constructor might arguably be a good design,
it is a bit limiting for some cases like this. why? because we have
objects that have UndoActions and/or KeyActions as member variables that
are created without any arguments, then assigned later in the life of
the object.
is there a way to create a sigc::slot<void> with no arguments?
thanks,
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]