[Clam-devel] TypedControls: asking for advice and opinions

Francisco Tufró nictuku at gmail.com
Fri Jul 11 11:12:45 PDT 2008


Hi, I've been trying to do the migration to TypedControls and we've some
problems.
Since the *ControlRegistry now is defined as std::list<BaseTyped*Control*>
the functions Get() and GetByNumber now return a BaseTyped*Control instead
of a *Control.
The same is happening with Get*Controls() which now returns a list<Base..>
instead of a list<*Control *>
So, every single code line using Get*Controls as well as Get() and
GetByNumber() has to be replaced.
As Pau proposed i wrote the function that connected a In to a temporary out
and sends the value, but that was just one of the appearances of the
problem.
Those functiones were used in other circumstances:
  - Assignations: MIDIIO/MIDIKeyboard.cxx:        OutControl& outVelocity =
mNoteIn.GetOutControls().GetByNumber(2);
  - To access in controls defined in parent classes:
SpectralSpread.hxx:
GetInControl("Amount").DoControl(100);
  - also (don't know why) in the Initialization function of some processings
(where the controls were accesible by its own variable name, but anyways
they were referenced with Get*Controls:
FrameTransformation.hxx:
GetInControl("Amount").DoControl(0.);

I tried to solve every one of these problems with the better solution i
thought, now i present these solutions:
 - For the already known problem (the one of this thread) i wrote the
following function
(i made also a version where an int is passed instead of the name, but is
essentially the same, for those places where GetByNumber was used):
    void SendFloatToInControl(Processing & receiver, const std::string &
inControlName, float value){
        TypedOutControl<float> controlSender;
        controlSender.AddLink(receiver.GetInControls().Get(inControlName));
        controlSender.SendControl(value);
    }
The first i had to do a static cast, i don't like this solution, but the
code needs to be rewritten to avoid it, this happends also in NetworkEditor
and Annotator.
The second was solved with this function also, but passed *this as argument.
The third was solved replacing the lines using the variable name.
Another of these problems was that GetInControl was used to ask for
GetLastValue of an InControl, for this i wrote:
float GetFloatFromInControl(Processing & proc, const std::string &
inControlName){
        InControl& in = (InControl&)(proc.GetInControl(inControlName));
        return in.GetLastValue();
    }
This needed a typecast, but static. I'm not so sure about this solution.
This was needed in the SMSDeesser lines 44-47.

Also there were some places that used GetOutControl to do a SendControl,
with these i used this function:

    void SendFloatToOutControl(Processing & sender, int inControlIndex,
float value){
        OutControl& out =
(OutControl&)(sender.GetOutControls().GetByNumber(inControlIndex));
        out.SendControl(value);
    }
Again, a cast was needed, used in MIDIInControl.hxx.
Hope you can help me with this and tell me how to best solve the migration
problem.
bye!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20080711/5dde256f/attachment-0003.htm>


More information about the clam-devel mailing list