Ver código fonte

ctkServiceFactory not templated anymore.

Sascha Zelzer 14 anos atrás
pai
commit
a11c82ffe8

+ 0 - 1
Libs/PluginFramework/CMakeLists.txt

@@ -84,7 +84,6 @@ SET(KIT_SRCS
 # Headers that should run through moc
 SET(KIT_MOC_SRCS
   ctkPluginFrameworkListeners_p.h
-  ctkServiceFactory.h
   ctkTrackedPluginListener_p.h
   ctkTrackedServiceListener_p.h
 )

+ 3 - 5
Libs/PluginFramework/ctkServiceFactory.h

@@ -51,11 +51,9 @@
  * not made available to other plugins in the plugin environment. The Framework
  * may concurrently call a <code>ctkServiceFactory</code>.
  *
- * @tparam S Type of Service
  * @see ctkPluginContext#getService
  * @threadsafe
  */
-template<class S>
 class ctkServiceFactory
 {
 
@@ -90,7 +88,7 @@ public:
    *         the classes named when the service was registered.
    * @see ctkPluginContext#getService
    */
-  virtual S getService(QSharedPointer<ctkPlugin> plugin, const ctkServiceRegistration& registration) = 0;
+  virtual QObject* getService(QSharedPointer<ctkPlugin> plugin, ctkServiceRegistration registration) = 0;
 
   /**
    * Releases a service object.
@@ -106,8 +104,8 @@ public:
    *        <code>ctkServiceFactory::getService</code> method.
    * @see ctkPluginContext#ungetService
    */
-  virtual void ungetService(QSharedPointer<ctkPlugin> plugin, const ctkServiceRegistration registration,
-                            S service) = 0;
+  virtual void ungetService(QSharedPointer<ctkPlugin> plugin, ctkServiceRegistration registration,
+                            QObject* service) = 0;
 };
 
 Q_DECLARE_INTERFACE(ctkServiceFactory, "org.commontk.services.ctkServiceFactory")

+ 2 - 2
Libs/PluginFramework/ctkServiceReferencePrivate.cpp

@@ -56,7 +56,7 @@ QObject* ctkServiceReferencePrivate::getService(QSharedPointer<ctkPlugin> plugin
         {
           try
           {
-            s = serviceFactory->getService(plugin, registration->q_func());
+            s = serviceFactory->getService(plugin, *(registration->q_func()));
           }
           catch (const std::exception& pe)
           {
@@ -147,7 +147,7 @@ bool ctkServiceReferencePrivate::ungetService(QSharedPointer<ctkPlugin> plugin,
       try
       {
         qobject_cast<ctkServiceFactory*>(registration->getService())->ungetService(plugin,
-                                                                                   registration->q_func(), sfi);
+                                                                                   *(registration->q_func()), sfi);
       }
       catch (const std::exception& e)
       {

+ 2 - 2
Libs/PluginFramework/ctkServiceRegistration.cpp

@@ -159,8 +159,8 @@ void ctkServiceRegistration::unregister()
           {
             // NYI, don't call inside lock
             qobject_cast<ctkServiceFactory*>(d->service)->ungetService(i.key(),
-                                                       this,
-                                                       obj);
+                                                                       *this,
+                                                                       obj);
           }
           catch (const std::exception& ue)
           {

+ 2 - 2
Plugins/org.commontk.qtmobility.service/ctkQtMobilityServiceFactory.cpp

@@ -39,7 +39,7 @@ ctkQtMobilityServiceFactory::ctkQtMobilityServiceFactory(
 }
 
 QObject* ctkQtMobilityServiceFactory::getService(
-  QSharedPointer<ctkPlugin> usingPlugin, ctkServiceRegistration* registration)
+  QSharedPointer<ctkPlugin> usingPlugin, ctkServiceRegistration registration)
 {
   Q_UNUSED(usingPlugin)
   Q_UNUSED(registration)
@@ -67,7 +67,7 @@ QObject* ctkQtMobilityServiceFactory::getService(
 }
 
 void ctkQtMobilityServiceFactory::ungetService(
-  QSharedPointer<ctkPlugin> usingPlugin, ctkServiceRegistration* registration, QObject* service)
+  QSharedPointer<ctkPlugin> usingPlugin, ctkServiceRegistration registration, QObject* service)
 {
   Q_UNUSED(usingPlugin)
   Q_UNUSED(registration)

+ 4 - 3
Plugins/org.commontk.qtmobility.service/ctkQtMobilityServiceFactory_p.h

@@ -31,16 +31,17 @@ class ctkQtMobilityServiceRuntime;
 
 using namespace QtMobility;
 
-class ctkQtMobilityServiceFactory : public ctkServiceFactory
+class ctkQtMobilityServiceFactory : public QObject, public ctkServiceFactory
 {
+  Q_OBJECT
 
 public:
 
   ctkQtMobilityServiceFactory(const QServiceInterfaceDescriptor& descr,
                               ctkQtMobilityServiceRuntime* sr, QSharedPointer<ctkPlugin> plugin);
 
-  QObject* getService(QSharedPointer<ctkPlugin> usingPlugin, ctkServiceRegistration* registration);
-  void ungetService(QSharedPointer<ctkPlugin> usingPlugin, ctkServiceRegistration* registration, QObject* service);
+  QObject* getService(QSharedPointer<ctkPlugin> usingPlugin, ctkServiceRegistration registration);
+  void ungetService(QSharedPointer<ctkPlugin> usingPlugin, ctkServiceRegistration registration, QObject* service);
 
 private: