[Kget] Refactor transferhandler & transfergrouphandler?
Carsten Pfeiffer
carsten.pfeiffer at alumni.tu-berlin.de
Tue Aug 12 23:04:13 CEST 2008
Am Mittwoch, 13. August 2008 schrieb Lukas Appelhans:
> > I thought you would dynamic_cast for TransferGroupHandler instead of the
> > base Handler class? AFAIK there is no problem to
> > dynamic_cast<TransferGroupHandler*>(someHandlerPtr)
>
> that won't work afaik, dynamic_cast can only cast downwards...
If the hierarchy looks like this:
-----------------------
| TransferHandlerBase |
-----------------------
A A
| |
----------------- ----------------------
|TransferHandler| |TransferHandlerGroup|
----------------- ----------------------
then the following works just fine:
TransferHandlerBase *handler = getSomeHandler();// returns one of the two
TransferHandlerGroup *group = dynamic_cast<TransferHandlerGroup*>(handler);
group will be 0 if handler is not of type TransferHandlerGroup *.
group will be a valid pointer if handler is of type TransferHandlerGroup *.
Cheers,
Carsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 447 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kget/attachments/20080812/66190fef/attachment.pgp
More information about the Kget
mailing list