Andre Poenitz wrote:

> On Thu, Mar 06, 2003 at 02:17:48PM +0000, Angus Leeming wrote:
>> Do things become clearer?
> 
> Not sure.
> 
> But
> 
>   ViewCitation(Dialog & parent) : ViewBase(parent) {}
>         virtual void printcontroller() {
>                 std::cout << "ViewCitation's controller is "
>         << getController<ControlCitation>().whoami()
> 
> can _never_ work as I think you want  as the ControlCitation type is
> static, so there is a static tie between  ViewCitation  and
> ControlCitation.

I'm interested only in static ties. I was just looking for a 
shorthand notation... At the moment I have a templatised class from 
which all the different individual views derive:

template<typename Controller>
class FormController : public FormDialogBase {
        FormController(Dialog & parent) : FormDialogBase(paremt) {}
        Controller & controller() { return (Controller &)controller_; }
};

That's all it does. It's just a shorthand. Thereafter
class FormCitation: public FormController<ControlCitation> {
        ...
}

so controller() to FormCitation means ControlCitation.
and to FormTabular it means Controltabular.

I wondered if I could get rid of this intermediate class and yet 
still retain a shorthand notation. It appears not, but no matter. It 
was just idle curiosity, that's all. Sorry it's exercised so much of 
your attention.


> Every such construct _statically_ ties ControlCitation and
> ViewCitation...
> 
> Ok......  Is the situation like that:
> 
>    We have a set of Controlers and a set of View.
>    A dialog has one Controler and one View.
>    In theory any Control can be couple with any View
>    In practice, only a few combinations are useful.
>    These combinations are static, i.e. established at compile
>    time(?)

YES!

// Lazy instatiation. Only build the thing when a particular
// dialog is requested.
Dialog * Dialogs::build(string const & name) {
        if (!isValid(name))
                return 0;

        Dialog * dialog = new Dialog;
        if (name == "citation") {
                dialog.setController(new ControlCitation(*dialog));
                dialog.setView(new FormView(*dialog));
                dialog.setButtonController(new NoRepeatedApplyBC);
        } else if (name == "tabular") {
                ...
        }


        return dialog;
}

-- 
Angus

Reply via email to