Replacing RESTORE() macro with template functions.
Marc Mutz
Marc.Mutz at uni-bielefeld.de
Mon Dec 2 22:38:21 GMT 2002
On Monday 02 December 2002 13:59, Simon Hausmann wrote:
> Just two things I wonder about:
>
> 1) why static? :)
Habit...
> 2) might be worth caching the result of classNameOfTopLevel in the
> loop maybe (would increase readability IMHO)
template <typename T0, typename T1>
inline kRestoreMainWindows() {
const char * classNames[2];
classNames[0] = T0::staticMetaObject()->className();
classNames[1] = T1::staticMetaObject()->className();
for ( int n = 1 ; KMainWindow::canBeRestored( n ) ; ++n ) {
const QString className = KMainWindow::classNameOfTopLevel( n );
if ( className == classNames[0] )
(new T0)->restore();
else if ( className == classNames[1] )
(new T0)->restore();
}
}
Better? :-)
The thing _I_ wonder about:
3. QObject::staticMetaObject() seems to not be part of the public
(ie. documented) QObject API... It's inside the Q_OBJECT macro, but
then so is qt_cast, which is already used all over the place...
Marc
--
They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety. -- Benjamin Franklin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20021202/ae644480/attachment.sig>
More information about the kde-core-devel
mailing list