Re: [linux-audio-dev] Re: MVC

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Re: MVC
From: Paul Davis (paul_AT_linuxaudiosystems.com)
Date: Mon May 12 2003 - 15:35:40 EEST


>Does the model keep a list of views and call back to them?
>for each view do
> view->update(me);
>done

definitely not. that would require the model to know something about
the view. it gets hairy because you generally can't get away with a
single "changed" method if the model has any real complexity. you have
to tell the views what has changed so that they don't have to do too
much work.

to do this properly, i believe its ideal to use some kind of anonymous
callback system so that the model can signal changes, and 0 or more
views can pick them up. its possible to do this in C, though its much
nicer in C++ with libsigc++ (or the boost signals/slots library; i'm
leaving out the Qt one because it requires a preprocessor to run over
your code first, but it could be used if you insisted on it :).

if we allow ourselves to peek inside the callback system, what is
really happening looks something like this (to use C++ syntax):

       model->changed ();

       Model::changed () {
          for each registered callback {
                callback->execute ();
          }
       }

the callback system (e.g. libsigc++) takes care of managing callback
(de-) registration, lifetime management, etc. etc.

--p


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Mon May 12 2003 - 15:49:23 EEST