[Kde-games-devel] A new highscore manager - KScoreManager

Albert Astals Cid aacid at kde.org
Thu May 1 20:23:33 CEST 2008


A Dijous 01 Maig 2008, Parker Coates va escriure:
> 2008/5/1 Matt Williams <matt at milliams.com>:
> >  After some discussion with Albert, I've separated the UI from the
> > management even further. The functions for accessing the information
> > about the scores has now been made private. I've then created an abstract
> > class called KAbstractScoreBoard which is a friend of KScoreManager so
> > that it can access its private functions. This way, whatever funky
> > display widget you can think of will just have to subclass
> > KAbstractScoreBoard.
> >
> >  This way, all the display based functions and enums can be moved to
> >  KAbstractScoreBoard.
>
> Unfortunately, friendship isn't inherited.
> (http://www.parashift.com/c++-faq-lite/friends.html#faq-14.4) So while
> KAbstractScoreBoard will have friend access to KScoreManager, any
> classes derived from it won't. I had thought of using friendship to
> clean up the API a while ago, but couldn't find a way to make it work
> other than declaring every possible display class a friend. But of
> course this would mean new classes couldn't be added without modifying
> the KScoreManager header, which is nasty.
>
> Unless, of course, Albert knows a way around this.

We do not need to inherit friendship, we will access the KScoreManager private 
fields trough protected calls on KAbstractScoreBoard. That way you can have 
an unlimited number of KAbstractScoreBoard derived classes accessing 
KScoreManager private functions.

Albert


More information about the kde-games-devel mailing list