From kfm-devel Wed Feb 05 11:59:52 2003 From: Leo Savernik Date: Wed, 05 Feb 2003 11:59:52 +0000 To: kfm-devel Subject: KIO::Slave is inextensible! X-MARC-Message: https://marc.info/?l=kfm-devel&m=104444641401192 Hello, In an attempt to create a highly optimized KIO::Slave for data urls that avoids the need to spawn an own kioslave process, I hit the following problems: KIO::Slave *KIO::Slave::createSlave(...) KIO::Slave *KIO::Slave::holdSlave(...) Those return a Slave and not a SlaveInterface, so I *must* derive from Slave at any rate, leading to another, really grave problem: KIO::Connection *KIO::Slave::connection() { return &slaveconn; } While SlaveInterface also defines this method and returns a pointer to some dynamically allocated Connection object, KIO::Slave::connection() returns an embedded object. That wouldn't be troublesome if this getter method weren't inline. So it's *impossible* to hook in an alternative Connection object for a Slave-derived class, but I need this badly. Possible solutions: - simplest solution: ditch KIO::Slave::connection() and let KIO::SlaveInterface::connection() do the work. However, it's BIC. - alternative solution: have KIO::Slave::createSlave(...) and KIO::Slave::holdSlave(...) return SlaveInterface instead of Slave. But it's also BIC and there's certainly a good reason why they return a Slave object. - utmost ugliest solution: Giving KIO::Connection a hint to morph itself into another class and then pass through the parameters to the effective object in every method. Illustration: void Connection::setSpecial(Connection *effective_connection) { reinterpret_cast(d) = effective_connection; } and passing through would look like (done for every other method): void Connection::init(KSocket *sock) { if (d) { reinterpret_cast(d)->init(sock); return; } delete notifier; ... } Yes, it's butt ugly, but BC. If anybody knows better solutions please tell me. If this is too complicated for KDE 3 to implement, I opt for removal of the offending Slave::connection() method for KDE 4. mfg Leo