[Telepathy-commits] [telepathy-qt4/master] OptionalInterfaceFactory: expect and require AbstractInterface subclasses
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Jan 22 03:45:08 PST 2009
Also fix coding style
---
TelepathyQt4/Client/optional-interface-factory.cpp | 12 ++++++------
TelepathyQt4/Client/optional-interface-factory.h | 19 ++++++++++---------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/TelepathyQt4/Client/optional-interface-factory.cpp b/TelepathyQt4/Client/optional-interface-factory.cpp
index 00958bf..a44c7b3 100644
--- a/TelepathyQt4/Client/optional-interface-factory.cpp
+++ b/TelepathyQt4/Client/optional-interface-factory.cpp
@@ -33,7 +33,7 @@ namespace Client
struct OptionalInterfaceFactory::Private
{
- QMap<QString, QDBusAbstractInterface*> interfaces;
+ QMap<QString, AbstractInterface*> interfaces;
};
OptionalInterfaceFactory::OptionalInterfaceFactory()
@@ -46,9 +46,9 @@ OptionalInterfaceFactory::~OptionalInterfaceFactory()
{
debug() << "Destroying OptionalInterfaceFactory";
- for (QMap<QString, QDBusAbstractInterface*>::iterator i = mPriv->interfaces.begin();
- i != mPriv->interfaces.end();
- ++i) {
+ for (QMap<QString, AbstractInterface *>::iterator i = mPriv->interfaces.begin();
+ i != mPriv->interfaces.end();
+ ++i) {
debug().nospace() << " ~" << i.key();
delete i.value();
}
@@ -56,7 +56,7 @@ OptionalInterfaceFactory::~OptionalInterfaceFactory()
delete mPriv;
}
-QDBusAbstractInterface* OptionalInterfaceFactory::getCached(const QString& name) const
+AbstractInterface *OptionalInterfaceFactory::getCached(const QString &name) const
{
if (mPriv->interfaces.contains(name)) {
debug() << "Returning cached interface for" << name;
@@ -67,7 +67,7 @@ QDBusAbstractInterface* OptionalInterfaceFactory::getCached(const QString& name)
}
}
-void OptionalInterfaceFactory::cache(QDBusAbstractInterface* interface) const
+void OptionalInterfaceFactory::cache(AbstractInterface *interface) const
{
QString name = interface->interface();
Q_ASSERT(!mPriv->interfaces.contains(name));
diff --git a/TelepathyQt4/Client/optional-interface-factory.h b/TelepathyQt4/Client/optional-interface-factory.h
index a74a393..ac3b2bf 100644
--- a/TelepathyQt4/Client/optional-interface-factory.h
+++ b/TelepathyQt4/Client/optional-interface-factory.h
@@ -37,9 +37,10 @@
* backwards compatibility helpers for older services and other utilities.
*/
-#include <QDBusAbstractInterface>
#include <QtGlobal>
+#include <TelepathyQt4/Client/AbstractInterface>
+
namespace Telepathy
{
namespace Client
@@ -94,15 +95,15 @@ class OptionalInterfaceFactory
template <typename OptionalInterface, typename MainInterface>
inline OptionalInterface* interface(const MainInterface& mainInterface) const
{
- // Check that the types given are both subclasses of QDBusAbstractInterface
- QDBusAbstractInterface* mainInterfaceMustBeASubclassOfQDBusAbstractInterface = static_cast<MainInterface*>(NULL);
- QDBusAbstractInterface* optionalInterfaceMustBeASubclassOfQDBusAbstractInterface = static_cast<OptionalInterface*>(NULL);
- Q_UNUSED(mainInterfaceMustBeASubclassOfQDBusAbstractInterface);
- Q_UNUSED(optionalInterfaceMustBeASubclassOfQDBusAbstractInterface);
+ // Check that the types given are both subclasses of AbstractInterface
+ AbstractInterface* mainInterfaceMustBeASubclassOfAbstractInterface = static_cast<MainInterface*>(NULL);
+ AbstractInterface* optionalInterfaceMustBeASubclassOfAbstractInterface = static_cast<OptionalInterface*>(NULL);
+ Q_UNUSED(mainInterfaceMustBeASubclassOfAbstractInterface);
+ Q_UNUSED(optionalInterfaceMustBeASubclassOfAbstractInterface);
// If there is a interface cached already, return it
QString name(OptionalInterface::staticInterfaceName());
- QDBusAbstractInterface* cached = getCached(name);
+ AbstractInterface* cached = getCached(name);
if (cached)
return static_cast<OptionalInterface*>(cached);
@@ -113,8 +114,8 @@ class OptionalInterfaceFactory
}
private:
- QDBusAbstractInterface* getCached(const QString& name) const;
- void cache(QDBusAbstractInterface* interface) const;
+ AbstractInterface *getCached(const QString &name) const;
+ void cache(AbstractInterface *interface) const;
struct Private;
Private* mPriv;
--
1.5.6.5
More information about the Telepathy-commits
mailing list