Am 18.08.2010, 19:08 Uhr, schrieb Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>:
Hm got the following problem: In the decorator I buffer the decorator footprint. Therefore I implemented the buffering in the base class and call the derived implementation from there e.g.: void Decorator::SetLook(DesktopSettings& settings, window_look look, BRegion* updateRect) { _SetLook(settings, look, updateRect); _InvalidateFootprint(); // the border very likely changed } So any good idea / convention how I should rename the protected _SetLook function?Not really, but if SetLook() is only two lines of code, why not simply call InvalidateFootprint() from the inherited version? Or have the decorators call the base version.
The problem is that in this case every sub class has to take care about the caching. There are ~10 function of this kind. Maybe keep the underscore for this kind of functions?
Calling the base class would be an option but there are two problems you can forget to call it (a minor one) and you can't do stuff like this:
void Decorator::SetFlags(uint32 flags, BRegion* updateRegion) { // we're nice to our subclasses - we make sure B_NOT_{H|V|}_RESIZABLE // are in sync (it's only a semantical simplification, not a necessity) if ((flags & (B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE)) == (B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE)) flags |= B_NOT_RESIZABLE; if (flags & B_NOT_RESIZABLE) flags |= B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE; _SetFlags(flags, updateRegion); InvalidateFootprint(); // the border might have changed (smaller/larger tab) } I could also use the decorator pattern to do the caching... Regards, Clemens