[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: signals and slots vs. virtual_hook (was [PATCH] KFileDialog
From: Ingo =?utf-8?q?Kl=C3=B6cker?= <kloecker () kde ! org>
Date: 2008-07-15 22:23:03
Message-ID: 200807160023.04058 () thufir ! ingo-kloecker ! de
[Download RAW message or body]
On Tuesday 15 July 2008, Rafael Fernández López wrote:
> Hi,
>
> > 1) There's BaseClass, where virtual_hook is defined initially
> > 2) There's MiddleClass: public BaseClass
> > 3) There's DerivedClass: public MiddleClass
> > 4) We decide that MiddleClass needs a new public, virtual function.
> > We implement that by way of a non-virtual public and by overriding
> > the virtual hook in MiddleClass and in DerivedClass.
> > 5) Where did the enum get defined?
> > 5.a) BaseClass, which means you must modify the most basic class
> > in the hierarchy, which sometimes you can't or don't want to
> > 5.b) MiddleClass, which is the "proper place"
>
> Yes, I'd say 5.b)
>
> > However, if you do modify MiddleClass, what happens when BaseClass
> > needs a virtual? It has to be sure not to use the same enum value
> > that was used in MiddleClass -- wherever that middle class ended up
> > being.
>
> That shouldn't be much trouble.
>
> enum NewVirtualMethods {
> MyNewVirtual1 = 0,
> MyNewVirtual2,
> MyNewVirtual3,
> VirtualMethodCount
> };
>
> so...
>
> enum NewVirtualMiddleClassMethods {
> MyNewVirtual4 = VirtualMethodCount
> };
I don't get what you mean by this. Is NewVirtualMethods defined in
BaseClass and NewVirtualMiddleClassMethods in MiddleClass? If yes, then
the problem is that you cannot add another enum value to
NewVirtualMethods because this would make a recompilation of
MiddleClass necessary so that the new value for VirtualMethodCount is
taken into account. Of course, one might use
enum NewVirtualMiddleClassMethods {
MyNewVirtual4 = VirtualMethodCount + 1000
};
instead in order to allow up to 1000 additional virtual methods to be
added to BaseClass. This reminds me of line numbers in BASIC where you
only used 10, 20, etc. as line numbers for your first version hoping
that you'd never have to add more than 9 additional lines between lines
10 and 20. ;-)
Regards,
Ingo
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic