Re: virtual inheritance and Glib::Interface



On 4/5/06, Chris Vine <chris cvine freeserve co uk> wrote:
> On Wednesday 05 April 2006 22:57, Jonathon Jongsma wrote:
> > Yes, I was not trying to suggest that ListStore inherit from TreeModel
> > virtually, I was suggesting that since ListStore inherits from 4
> > classes with a common ancestor (of which TreeModel is one), those 4
> > classes should use virtual inheritance to inherit from Interface,
> > which they don't appear to do.
>
> But then if they have anything other than a default constructor you can make
> them practically unusable, because of the need to invoke the constructor from
> the most derived class.  If it doesn't matter having multiple Interface
> objects (and I do not know if it does or it doesn't) you may be better off
> leaving things as they are.
>

I'm not quite sure I understand your explanation.  In any case, it
seems to work as it is currently, so if there are significant
drawbacks to using virtual inheritance in this case, maybe it's ok to
keep it as it is.  I just wanted people to be aware of it.

Jonner

p.s. Just for fun, I modified the Glib::Interface constructor to print
to stdout.  Then I compiled this simple test case:

========================================
#include <gtkmm.h>

 class MyModelColumns : public Gtk::TreeModel::ColumnRecord
 {
 public:
   Gtk::TreeModelColumn<Glib::ustring> filename;

   MyModelColumns() { add(filename); }
 };

int main(int argc, char** argv)
{
    Gtk::Main app(argc, argv);
    MyModelColumns cols;
    Glib::RefPtr<Gtk::ListStore> refStore = Gtk::ListStore::create(cols);
}
========================================

$ g++ `pkg-config --cflags --libs gtkmm-2.4` main.cc
$ ./a.out
Interface Created
Interface Created
Interface Created
Interface Created



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]