[Clam-devel] Proof of concept: New callback controls

David García Garzón dgarcia at iua.upf.edu
Sun Feb 15 18:45:59 PST 2009

On Pau's demand, I attach a proof of concept of a simplified interface for 
callback based controls.

Instead of using a different class for InControlTmpl's 
(CascadedTypedInControl's in the typed incarnation) and being forced to 
include the concrete Processing type as a second template parameter, the 
proposal is, to use an interface like that:

class Myprocessing ...
    InControl<float> _inControl1;
    InControl<float> _inControl2;
    InControl<std::string> _inControl3;
        : _inControl1(this)
        , _inControl2(this, &MyProcessing::ControlCallback)
        , _inControl3(this, &MyProcessing::StringControlCallback)

instead of something like:

class Myprocessing ...
    InControl<float> _inControl1;
    CascadedInControl<float,MyProcessing> _inControl2;
    CascadedInControl<std::string,MyProcessing> _inControl3;
        : _inControl1(this)
        , _inControl2(this, &MyProcessing::ControlCallback)
        , _inControl3(this, &MyProcessing::StringControlCallback)

The trick, instead of templating the whole control class by the processing 
type, just template an overloaded constructor. The parameter chooses 
implicitly the processing type, keeping the user code template cleaner. The 
templated constructor creates a callback wrapper that is called later, while 
the regular constructor creates a null callback instead, so the same class can 
deal with both by polimorphism.

Changes to be done are minimum and the transition can be progressive.
Overloads can be made to support existing id based callbacks and even 
callbacks receiving a reference to the control object.
Do you buy it?

David García Garzón
(Work) dgarcia at iua dot upf anotherdot es

-------------- next part --------------
A non-text attachment was scrubbed...
Name: callback.cxx
Type: text/x-c++src
Size: 2203 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20090216/d6f4c664/attachment-0003.cxx>

More information about the clam-devel mailing list