Browse Source

Fixed indentation and code style.

Sascha Zelzer 14 years ago
parent
commit
b40ec41ee3

+ 169 - 170
Libs/PluginFramework/ctkPluginDatabase_p.h

@@ -25,182 +25,181 @@
 #include <QtSql>
 #include <QList>
 
-
-
 // CTK class forward declarations
 class ctkPluginStorage;
 class ctkPluginArchive;
 
 class ctkPluginDatabase {
 
-  public:
-    ctkPluginDatabase(ctkPluginStorage* storage);
-
-    virtual ~ctkPluginDatabase();
-
-    /**
-     * Opens the plugin database. If the database does not
-     * yet exist, it is created using the path from getDatabasePath().
-     *
-     * @see setDatabasePath(const QString&)
-     * @see getDatabasePath()
-     * @see ctkPluginDatabaseException
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    void open();
-
-    /**
-     * Closes the plugin database. Throws a ctkPluginDatabaseException
-     * of type DB_CONNECTION_INVALID if the database is invalid.
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    void close();
-
-    /**
-     * Checks if the database is open
-     */
-    bool isOpen() const;
-
-    /**
-     * Sets the path of the service database to \a databasePath
-     */
-    void setDatabasePath(const QString &databasePath);
-
-    /**
-     * Returns the path of the plugin database
-     */
-    QString getDatabasePath() const;
-
-    /**
-     * Get a Qt resource cached in the database. The resource path \a res
-     * must be relative to the plugin specific resource prefix, but may
-     * start with a '/'.
-     *
-     * @param pluginId The id of the plugin from which to get the resource
-     * @param res The path to the resource in the plugin
-     * @return The byte array of the cached resource
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    QByteArray getPluginResource(long pluginId, const QString& res) const;
-
-    /**
-     * Get a list of resource entries under the given path.
-     *
-     * @param pluginId The id of the plugin from which to get the entries
-     * @param path A resource path relative to the plugin specific resource prefix.
-     * @return A QStringList containing the cached resource entries.
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    QStringList findResourcesPath(long pluginId, const QString& path) const;
-
-    /**
-     * Inserts a new plugin into the database. This method assumes that
-     * the an entry with the same \a location and \a localPath does not
-     * yet exist in the database.
-     *
-     * @param location The URL to the plugin.
-     * @param localPath The path to the plugin library on the local file system.
-     * @param createArchive If \c true (default) a new ctkPluginArchive instance is returned.
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    ctkPluginArchive* insertPlugin(const QUrl& location, const QString& localPath, bool createArchive = true);
-
-    /**
-     * Removes all persisted data related to the given ctkPluginArchive.
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    void removeArchive(const ctkPluginArchive* pa);
-
-    /**
-     * Reads the persisted plugin data and returns a ctkPluginArchive object
-     * for each plugin which is not in state UNINSTALLED.
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    QList<ctkPluginArchive*> getPluginArchives() const;
-
-
-  private:
-
-    enum TransactionType{Read, Write};
-
-    /**
-     *  Helper method that creates the database tables:
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    void createTables();
-    bool dropTables();
-
-    /**
-     * Helper method that checks if all the expected tables exist in the database.
-     *
-     * Returns true if they all exist and false if any of them don't
-     */
-    bool checkTables() const;
-
-    /**
-     * Checks the database connection.
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    void checkConnection() const;
-
-    /**
-     * Compares the persisted plugin modification time with the
-     * file system modification time and updates the database
-     * if the persisted data is outdated.
-     *
-     * This should only be called once when the database is initially opened.
-     */
-    void updateDB();
-
-    /**
-     * Helper function that executes the sql query specified in \a statement.
-     * It is assumed that the \a statement uses positional placeholders and
-     * corresponding parameters are placed in the list of \a bindValues.
-     *
-     * Aside: This function may be safely called standalone or within an explicit
-     * transaction.  If called standalone, it's single query is implicitly
-     * wrapped in it's own transaction.
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    void executeQuery(QSqlQuery* query, const QString &statement, const QList<QVariant> &bindValues = QList<QVariant>()) const;
-
-    /**
-     * Begins a transcaction based on the \a type which can be Read or Write.
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    void beginTransaction(QSqlQuery* query, TransactionType);
-
-    /**
-     * Commits a transaction
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    void commitTransaction(QSqlQuery* query);
-
-    /**
-     * Rolls back a transaction
-     *
-     * @throws ctkPluginDatabaseException
-     */
-    void rollbackTransaction(QSqlQuery* query);
-
-
-    QString m_databasePath;
-    QString m_connectionName;
-    bool m_isDatabaseOpen;
-    bool m_inTransaction;
-    ctkPluginStorage* m_PluginStorage;
+public:
+
+  ctkPluginDatabase(ctkPluginStorage* storage);
+
+  virtual ~ctkPluginDatabase();
+
+  /**
+   * Opens the plugin database. If the database does not
+   * yet exist, it is created using the path from getDatabasePath().
+   *
+   * @see setDatabasePath(const QString&)
+   * @see getDatabasePath()
+   * @see ctkPluginDatabaseException
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  void open();
+
+  /**
+   * Closes the plugin database. Throws a ctkPluginDatabaseException
+   * of type DB_CONNECTION_INVALID if the database is invalid.
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  void close();
+
+  /**
+   * Checks if the database is open
+   */
+  bool isOpen() const;
+
+  /**
+   * Sets the path of the service database to \a databasePath
+   */
+  void setDatabasePath(const QString &databasePath);
+
+  /**
+   * Returns the path of the plugin database
+   */
+  QString getDatabasePath() const;
+
+  /**
+   * Get a Qt resource cached in the database. The resource path \a res
+   * must be relative to the plugin specific resource prefix, but may
+   * start with a '/'.
+   *
+   * @param pluginId The id of the plugin from which to get the resource
+   * @param res The path to the resource in the plugin
+   * @return The byte array of the cached resource
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  QByteArray getPluginResource(long pluginId, const QString& res) const;
+
+  /**
+   * Get a list of resource entries under the given path.
+   *
+   * @param pluginId The id of the plugin from which to get the entries
+   * @param path A resource path relative to the plugin specific resource prefix.
+   * @return A QStringList containing the cached resource entries.
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  QStringList findResourcesPath(long pluginId, const QString& path) const;
+
+  /**
+   * Inserts a new plugin into the database. This method assumes that
+   * the an entry with the same \a location and \a localPath does not
+   * yet exist in the database.
+   *
+   * @param location The URL to the plugin.
+   * @param localPath The path to the plugin library on the local file system.
+   * @param createArchive If \c true (default) a new ctkPluginArchive instance is returned.
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  ctkPluginArchive* insertPlugin(const QUrl& location, const QString& localPath, bool createArchive = true);
+
+  /**
+   * Removes all persisted data related to the given ctkPluginArchive.
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  void removeArchive(const ctkPluginArchive* pa);
+
+  /**
+   * Reads the persisted plugin data and returns a ctkPluginArchive object
+   * for each plugin which is not in state UNINSTALLED.
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  QList<ctkPluginArchive*> getPluginArchives() const;
+
+
+private:
+
+  enum TransactionType{Read, Write};
+
+  /**
+   *  Helper method that creates the database tables:
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  void createTables();
+  bool dropTables();
+
+  /**
+   * Helper method that checks if all the expected tables exist in the database.
+   *
+   * Returns true if they all exist and false if any of them don't
+   */
+  bool checkTables() const;
+
+  /**
+   * Checks the database connection.
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  void checkConnection() const;
+
+  /**
+   * Compares the persisted plugin modification time with the
+   * file system modification time and updates the database
+   * if the persisted data is outdated.
+   *
+   * This should only be called once when the database is initially opened.
+   */
+  void updateDB();
+
+  /**
+   * Helper function that executes the sql query specified in \a statement.
+   * It is assumed that the \a statement uses positional placeholders and
+   * corresponding parameters are placed in the list of \a bindValues.
+   *
+   * Aside: This function may be safely called standalone or within an explicit
+   * transaction.  If called standalone, it's single query is implicitly
+   * wrapped in it's own transaction.
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  void executeQuery(QSqlQuery* query, const QString &statement, const QList<QVariant> &bindValues = QList<QVariant>()) const;
+
+  /**
+   * Begins a transcaction based on the \a type which can be Read or Write.
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  void beginTransaction(QSqlQuery* query, TransactionType);
+
+  /**
+   * Commits a transaction
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  void commitTransaction(QSqlQuery* query);
+
+  /**
+   * Rolls back a transaction
+   *
+   * @throws ctkPluginDatabaseException
+   */
+  void rollbackTransaction(QSqlQuery* query);
+
+
+  QString m_databasePath;
+  QString m_connectionName;
+  bool m_isDatabaseOpen;
+  bool m_inTransaction;
+  ctkPluginStorage* m_PluginStorage;
 };
 
 

+ 98 - 100
Libs/PluginFramework/ctkPluginFramework.cpp

@@ -28,134 +28,132 @@
 #include "ctkPluginArchive_p.h"
 
 
+ctkPluginFramework::ctkPluginFramework(ctkPluginFrameworkContext* fw)
+  : ctkPlugin(*new ctkPluginFrameworkPrivate(*this, fw))
+{
+  qRegisterMetaType<ctkPluginFrameworkEvent>("ctkPluginFrameworkEvent");
+  qRegisterMetaType<ctkPluginEvent>("ctkPluginEvent");
+}
+
+void ctkPluginFramework::init()
+{
+  Q_D(ctkPluginFramework);
 
-  ctkPluginFramework::ctkPluginFramework(ctkPluginFrameworkContext* fw)
-    : ctkPlugin(*new ctkPluginFrameworkPrivate(*this, fw))
+  QMutexLocker sync(&d->lock);
+  // waitOnActivation(d->lock, "Framework.init", true);
+  switch (d->state)
   {
-    qRegisterMetaType<ctkPluginFrameworkEvent>("ctkPluginFrameworkEvent");
-    qRegisterMetaType<ctkPluginEvent>("ctkPluginEvent");
+  case ctkPlugin::INSTALLED:
+  case ctkPlugin::RESOLVED:
+    break;
+  case ctkPlugin::STARTING:
+  case ctkPlugin::ACTIVE:
+    return;
+  default:
+    throw std::logic_error("INTERNAL ERROR, Illegal state");
   }
+  d->init();
+}
 
-  void ctkPluginFramework::init()
-  {
-    Q_D(ctkPluginFramework);
+void ctkPluginFramework::start(const ctkPlugin::StartOptions& options)
+{
+  Q_UNUSED(options);
+  Q_D(ctkPluginFramework);
 
+  QStringList pluginsToStart;
+  {
     QMutexLocker sync(&d->lock);
-    // waitOnActivation(d->lock, "Framework.init", true);
+    // TODO: parallel start
+    //waitOnActivation(lock, "ctkPluginFramework::start", true);
+
     switch (d->state)
     {
-    case ctkPlugin::INSTALLED:
-    case ctkPlugin::RESOLVED:
+    case INSTALLED:
+    case RESOLVED:
+      d->init();
+    case STARTING:
+      d->activating = true;
       break;
-    case ctkPlugin::STARTING:
-    case ctkPlugin::ACTIVE:
+    case ACTIVE:
       return;
     default:
       throw std::logic_error("INTERNAL ERROR, Illegal state");
     }
-    d->init();
+
+    pluginsToStart = d->fwCtx->storage->getStartOnLaunchPlugins();
   }
 
-  void ctkPluginFramework::start(const ctkPlugin::StartOptions& options)
+  // Start plugins according to their autostart setting.
+  QStringListIterator i(pluginsToStart);
+  while (i.hasNext())
   {
-    Q_UNUSED(options);
-    Q_D(ctkPluginFramework);
-
-    QStringList pluginsToStart;
-    {
-      QMutexLocker sync(&d->lock);
-      // TODO: parallel start
-      //waitOnActivation(lock, "ctkPluginFramework::start", true);
-
-      switch (d->state)
+    ctkPlugin* plugin = d->fwCtx->plugins->getPlugin(i.next());
+    try {
+      const int autostartSetting = plugin->d_func()->archive->getAutostartSetting();
+      // Launch must not change the autostart setting of a plugin
+      StartOptions option = ctkPlugin::START_TRANSIENT;
+      if (ctkPlugin::START_ACTIVATION_POLICY == autostartSetting)
       {
-      case INSTALLED:
-      case RESOLVED:
-        d->init();
-      case STARTING:
-        d->activating = true;
-        break;
-      case ACTIVE:
-        return;
-      default:
-        throw std::logic_error("INTERNAL ERROR, Illegal state");
+        // Transient start according to the plugins activation policy.
+        option |= ctkPlugin::START_ACTIVATION_POLICY;
       }
-
-      pluginsToStart = d->fwCtx->storage->getStartOnLaunchPlugins();
+      plugin->start(option);
     }
-
-    // Start plugins according to their autostart setting.
-    QStringListIterator i(pluginsToStart);
-    while (i.hasNext())
+    catch (const ctkPluginException& pe)
     {
-      ctkPlugin* plugin = d->fwCtx->plugins->getPlugin(i.next());
-      try {
-        const int autostartSetting = plugin->d_func()->archive->getAutostartSetting();
-        // Launch must not change the autostart setting of a plugin
-        StartOptions option = ctkPlugin::START_TRANSIENT;
-        if (ctkPlugin::START_ACTIVATION_POLICY == autostartSetting)
-        {
-          // Transient start according to the plugins activation policy.
-          option |= ctkPlugin::START_ACTIVATION_POLICY;
-        }
-        plugin->start(option);
-      }
-      catch (const ctkPluginException& pe)
-      {
-        d->fwCtx->listeners.frameworkError(plugin, pe);
-      }
-    }
-
-    {
-      QMutexLocker sync(&d->lock);
-      d->state = ACTIVE;
-      d->activating = false;
-      d->fwCtx->listeners.emitFrameworkEvent(
-          ctkPluginFrameworkEvent(ctkPluginFrameworkEvent::STARTED, this));
+      d->fwCtx->listeners.frameworkError(plugin, pe);
     }
   }
 
-  QStringList ctkPluginFramework::getResourceList(const QString& path) const
   {
-    QString resourcePath = QString(":/") + ctkPluginConstants::SYSTEM_PLUGIN_SYMBOLICNAME;
-    if (path.startsWith('/'))
-      resourcePath += path;
-    else
-      resourcePath += QString("/") + path;
-
-    QStringList paths;
-    QFileInfoList entryInfoList = QDir(resourcePath).entryInfoList();
-    QListIterator<QFileInfo> infoIter(entryInfoList);
-    while (infoIter.hasNext())
-    {
-      const QFileInfo& resInfo = infoIter.next();
-      QString entry = resInfo.canonicalFilePath().mid(resourcePath.size());
-      if (resInfo.isDir())
-        entry += "/";
-
-      paths << entry;
-    }
-
-    return paths;
+    QMutexLocker sync(&d->lock);
+    d->state = ACTIVE;
+    d->activating = false;
+    d->fwCtx->listeners.emitFrameworkEvent(
+        ctkPluginFrameworkEvent(ctkPluginFrameworkEvent::STARTED, this));
   }
+}
 
-  QByteArray ctkPluginFramework::getResource(const QString& path) const
+QStringList ctkPluginFramework::getResourceList(const QString& path) const
+{
+  QString resourcePath = QString(":/") + ctkPluginConstants::SYSTEM_PLUGIN_SYMBOLICNAME;
+  if (path.startsWith('/'))
+    resourcePath += path;
+  else
+    resourcePath += QString("/") + path;
+
+  QStringList paths;
+  QFileInfoList entryInfoList = QDir(resourcePath).entryInfoList();
+  QListIterator<QFileInfo> infoIter(entryInfoList);
+  while (infoIter.hasNext())
   {
-    QString resourcePath = QString(":/") + ctkPluginConstants::SYSTEM_PLUGIN_SYMBOLICNAME;
-    if (path.startsWith('/'))
-      resourcePath += path;
-    else
-      resourcePath += QString("/") + path;
-
-    QFile resourceFile(resourcePath);
-    resourceFile.open(QIODevice::ReadOnly);
-    return resourceFile.readAll();
+    const QFileInfo& resInfo = infoIter.next();
+    QString entry = resInfo.canonicalFilePath().mid(resourcePath.size());
+    if (resInfo.isDir())
+      entry += "/";
+
+    paths << entry;
   }
 
-  QHash<QString, QString> ctkPluginFramework::getHeaders()
-  {
-    //TODO security
-    Q_D(ctkPluginFramework);
-    return d->systemHeaders;
+  return paths;
+}
+
+QByteArray ctkPluginFramework::getResource(const QString& path) const
+{
+  QString resourcePath = QString(":/") + ctkPluginConstants::SYSTEM_PLUGIN_SYMBOLICNAME;
+  if (path.startsWith('/'))
+    resourcePath += path;
+  else
+    resourcePath += QString("/") + path;
+
+  QFile resourceFile(resourcePath);
+  resourceFile.open(QIODevice::ReadOnly);
+  return resourceFile.readAll();
+}
 
+QHash<QString, QString> ctkPluginFramework::getHeaders()
+{
+  //TODO security
+  Q_D(ctkPluginFramework);
+  return d->systemHeaders;
 }

+ 84 - 84
Libs/PluginFramework/ctkPluginFramework.h

@@ -28,96 +28,96 @@
 #include "ctkPluginFrameworkExport.h"
 
 
-  class ctkPluginFrameworkContext;
-  class ctkPluginFrameworkPrivate;
+class ctkPluginFrameworkContext;
+class ctkPluginFrameworkPrivate;
+
+/**
+ * A %ctkPluginFramework instance. A %ctkPluginFramework is also known as a System %Plugin.
+ *
+ * <p>
+ * %ctkPluginFramework instances are created using a ctkPluginFrameworkFactory. The methods
+ * of this class can be used to manage and control the created plugin framework
+ * instance.
+ *
+ * @threadsafe
+ */
+class CTK_PLUGINFW_EXPORT ctkPluginFramework : public ctkPlugin
+{
+
+  Q_DECLARE_PRIVATE(ctkPluginFramework)
+
+public:
 
   /**
-   * A %ctkPluginFramework instance. A %ctkPluginFramework is also known as a System %Plugin.
+   * Initialize this %ctkPluginFramework. After calling this method, this %ctkPluginFramework
+   * must:
+   * <ul>
+   * <li>Be in the {@link #STARTING} state.</li>
+   * <li>Have a valid Plugin Context.</li>
+   * <li>Be at start level 0.</li>
+   * <li>Have event handling enabled.</li>
+   * <li>Have create ctkPlugin objects for all installed plugins.</li>
+   * <li>Have registered any framework services.</li>
+   * </ul>
    *
    * <p>
-   * %ctkPluginFramework instances are created using a ctkPluginFrameworkFactory. The methods
-   * of this class can be used to manage and control the created plugin framework
-   * instance.
+   * This %ctkPluginFramework will not actually be started until {@link #start() start}
+   * is called.
    *
-   * @threadsafe
+   * <p>
+   * This method does nothing if called when this %ctkPluginFramework is in the
+   * {@link #STARTING}, {@link #ACTIVE} or {@link #STOPPING} states.
+   *
+   * @throws ctkPluginException If this %ctkPluginFramework could not be initialized.
+   */
+  void init();
+
+  /**
+   * Start this %ctkPluginFramework.
+   *
+   * <p>
+   * The following steps are taken to start this %ctkPluginFramework:
+   * <ol>
+   * <li>If this %ctkPluginFramework is not in the {@link #STARTING} state,
+   * {@link #init() initialize} this %ctkPluginFramework.</li>
+   * <li>All installed plugins must be started in accordance with each
+   * plugin's persistent <i>autostart setting</i>. This means some plugins
+   * will not be started, some will be started with <i>lazy activation</i>
+   * and some will be started with their <i>declared activation</i> policy.
+   * Any exceptions that occur during plugin starting must be wrapped in a
+   * {@link ctkPluginException} and then published as a plugin framework event of type
+   * {@link ctkPluginFrameworkEvent::ERROR}</li>
+   * <li>This %PluinFramework's state is set to {@link #ACTIVE}.</li>
+   * <li>A plugin framework event of type {@link ctkPluginFrameworkEvent::STARTED} is fired</li>
+   * </ol>
+   *
+   * @param options Ignored. There are no start options for the %ctkPluginFramework.
+   * @throws ctkPluginException If this %ctkPluginFramework could not be started.
+   */
+  void start(const ctkPlugin::StartOptions& options = 0);
+
+  /**
+   * @see ctkPlugin::getHeaders()
    */
-  class CTK_PLUGINFW_EXPORT ctkPluginFramework : public ctkPlugin
-  {
-
-    Q_DECLARE_PRIVATE(ctkPluginFramework)
-
-  public:
-
-    /**
-     * Initialize this %ctkPluginFramework. After calling this method, this %ctkPluginFramework
-     * must:
-     * <ul>
-     * <li>Be in the {@link #STARTING} state.</li>
-     * <li>Have a valid Plugin Context.</li>
-     * <li>Be at start level 0.</li>
-     * <li>Have event handling enabled.</li>
-     * <li>Have create ctkPlugin objects for all installed plugins.</li>
-     * <li>Have registered any framework services.</li>
-     * </ul>
-     *
-     * <p>
-     * This %ctkPluginFramework will not actually be started until {@link #start() start}
-     * is called.
-     *
-     * <p>
-     * This method does nothing if called when this %ctkPluginFramework is in the
-     * {@link #STARTING}, {@link #ACTIVE} or {@link #STOPPING} states.
-     *
-     * @throws ctkPluginException If this %ctkPluginFramework could not be initialized.
-     */
-    void init();
-
-    /**
-     * Start this %ctkPluginFramework.
-     *
-     * <p>
-     * The following steps are taken to start this %ctkPluginFramework:
-     * <ol>
-     * <li>If this %ctkPluginFramework is not in the {@link #STARTING} state,
-     * {@link #init() initialize} this %ctkPluginFramework.</li>
-     * <li>All installed plugins must be started in accordance with each
-     * plugin's persistent <i>autostart setting</i>. This means some plugins
-     * will not be started, some will be started with <i>lazy activation</i>
-     * and some will be started with their <i>declared activation</i> policy.
-     * Any exceptions that occur during plugin starting must be wrapped in a
-     * {@link ctkPluginException} and then published as a plugin framework event of type
-     * {@link ctkPluginFrameworkEvent::ERROR}</li>
-     * <li>This %PluinFramework's state is set to {@link #ACTIVE}.</li>
-     * <li>A plugin framework event of type {@link ctkPluginFrameworkEvent::STARTED} is fired</li>
-     * </ol>
-     *
-     * @param options Ignored. There are no start options for the %ctkPluginFramework.
-     * @throws ctkPluginException If this %ctkPluginFramework could not be started.
-     */
-    void start(const ctkPlugin::StartOptions& options = 0);
-
-    /**
-     * @see ctkPlugin::getHeaders()
-     */
-    QHash<QString, QString> getHeaders();
-
-    /**
-     * @see ctkPlugin::getResourceList()
-     */
-    QStringList getResourceList(const QString& path) const;
-
-    /**
-     * @see ctkPlugin::getResource()
-     */
-    QByteArray getResource(const QString& path) const;
-
-  protected:
-
-    friend class ctkPluginFrameworkContext;
-
-    ctkPluginFramework(ctkPluginFrameworkContext* fw);
-
-  };
+  QHash<QString, QString> getHeaders();
+
+  /**
+   * @see ctkPlugin::getResourceList()
+   */
+  QStringList getResourceList(const QString& path) const;
+
+  /**
+   * @see ctkPlugin::getResource()
+   */
+  QByteArray getResource(const QString& path) const;
+
+protected:
+
+  friend class ctkPluginFrameworkContext;
+
+  ctkPluginFramework(ctkPluginFrameworkContext* fw);
+
+};
 
 
 #endif // CTKPLUGINFRAMEWORK_H

+ 115 - 118
Libs/PluginFramework/ctkPluginFrameworkContext.cpp

@@ -28,163 +28,160 @@
 #include "ctkServices_p.h"
 
 
-  QMutex ctkPluginFrameworkContext::globalFwLock;
-  int ctkPluginFrameworkContext::globalId = 1;
+QMutex ctkPluginFrameworkContext::globalFwLock;
+int ctkPluginFrameworkContext::globalId = 1;
 
 
-  ctkPluginFrameworkContext::ctkPluginFrameworkContext(
-      const ctkProperties& initProps)
-        : plugins(0), services(0), systemPlugin(this),
-        storage(0), firstInit(true), props(initProps)
+ctkPluginFrameworkContext::ctkPluginFrameworkContext(
+    const ctkProperties& initProps)
+      : plugins(0), services(0), systemPlugin(this),
+      storage(0), firstInit(true), props(initProps)
+{
   {
+    QMutexLocker lock(&globalFwLock);
+    id = globalId++;
+  }
 
-    {
-      QMutexLocker lock(&globalFwLock);
-      id = globalId++;
-    }
+  log() << "created";
+}
 
-    log() << "created";
-  }
+void ctkPluginFrameworkContext::init()
+{
+  log() << "initializing";
 
-  void ctkPluginFrameworkContext::init()
+  if (firstInit && ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT
+      == props[ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN])
   {
-    log() << "initializing";
-
-    if (firstInit && ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT
-        == props[ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN])
-    {
-      deleteFWDir();
-      firstInit = false;
-    }
+    deleteFWDir();
+    firstInit = false;
+  }
 
-    ctkPluginFrameworkPrivate* const systemPluginPrivate = systemPlugin.d_func();
-    systemPluginPrivate->initSystemPlugin();
+  ctkPluginFrameworkPrivate* const systemPluginPrivate = systemPlugin.d_func();
+  systemPluginPrivate->initSystemPlugin();
 
-    storage = new ctkPluginStorage(this);
-    services = new ctkServices(this);
-    plugins = new ctkPlugins(this);
+  storage = new ctkPluginStorage(this);
+  services = new ctkServices(this);
+  plugins = new ctkPlugins(this);
 
-    plugins->load();
+  plugins->load();
 
-    log() << "inited";
+  log() << "inited";
 
-    log() << "Installed plugins:";
-    // Use the ordering in the plugin storage to get a sorted list of plugins.
-    QList<ctkPluginArchive*> allPAs = storage->getAllPluginArchives();
-    for (int i = 0; i < allPAs.size(); ++i)
-    {
-      ctkPluginArchive* pa = allPAs[i];
-      ctkPlugin* plugin = plugins->getPlugin(pa->getPluginLocation().toString());
-      log() << " #" << plugin->getPluginId() << " " << plugin->getSymbolicName() << ":"
-          << plugin->getVersion() << " location:" << plugin->getLocation();
-    }
+  log() << "Installed plugins:";
+  // Use the ordering in the plugin storage to get a sorted list of plugins.
+  QList<ctkPluginArchive*> allPAs = storage->getAllPluginArchives();
+  for (int i = 0; i < allPAs.size(); ++i)
+  {
+    ctkPluginArchive* pa = allPAs[i];
+    ctkPlugin* plugin = plugins->getPlugin(pa->getPluginLocation().toString());
+    log() << " #" << plugin->getPluginId() << " " << plugin->getSymbolicName() << ":"
+        << plugin->getVersion() << " location:" << plugin->getLocation();
   }
+}
 
-  void ctkPluginFrameworkContext::uninit()
-  {
-    log() << "uninit";
+void ctkPluginFrameworkContext::uninit()
+{
+  log() << "uninit";
 
-    ctkPluginFrameworkPrivate* const systemPluginPrivate = systemPlugin.d_func();
-    systemPluginPrivate->uninitSystemPlugin();
+  ctkPluginFrameworkPrivate* const systemPluginPrivate = systemPlugin.d_func();
+  systemPluginPrivate->uninitSystemPlugin();
 
-    plugins->clear();
-    delete plugins;
-    plugins = 0;
+  plugins->clear();
+  delete plugins;
+  plugins = 0;
 
-    storage->close();
-    delete storage;
-    storage = 0;
+  storage->close();
+  delete storage;
+  storage = 0;
 
-    delete services;
-    services = 0;
-  }
+  delete services;
+  services = 0;
+}
 
-  int ctkPluginFrameworkContext::getId() const
-  {
-    return id;
-  }
+int ctkPluginFrameworkContext::getId() const
+{
+  return id;
+}
 
-  void ctkPluginFrameworkContext::checkOurPlugin(ctkPlugin* plugin) const
+void ctkPluginFrameworkContext::checkOurPlugin(ctkPlugin* plugin) const
+{
+  ctkPluginPrivate* pp = plugin->d_func();
+  if (this != pp->fwCtx)
   {
-    ctkPluginPrivate* pp = plugin->d_func();
-    if (this != pp->fwCtx)
-    {
-      throw std::invalid_argument("ctkPlugin does not belong to this framework: " + plugin->getSymbolicName().toStdString());
-    }
+    throw std::invalid_argument("ctkPlugin does not belong to this framework: " + plugin->getSymbolicName().toStdString());
   }
+}
 
-  QDebug ctkPluginFrameworkContext::log() const
-  {
-    QDebug dbg(qDebug());
-    dbg << "Framework instance " << getId() << ": ";
-    return dbg;
-  }
+QDebug ctkPluginFrameworkContext::log() const
+{
+  QDebug dbg(qDebug());
+  dbg << "Framework instance " << getId() << ": ";
+  return dbg;
+}
 
-  void ctkPluginFrameworkContext::resolvePlugin(ctkPluginPrivate* plugin)
-  {
-    qDebug() << "resolve:" << plugin->symbolicName << "[" << plugin->id << "]";
+void ctkPluginFrameworkContext::resolvePlugin(ctkPluginPrivate* plugin)
+{
+  qDebug() << "resolve:" << plugin->symbolicName << "[" << plugin->id << "]";
 
-    // If we enter with tempResolved set, it means that we already have
-    // resolved plugins. Check that it is true!
-    if (tempResolved.size() > 0 && !tempResolved.contains(plugin))
-    {
-      ctkPluginException pe("resolve: InternalError1!", ctkPluginException::RESOLVE_ERROR);
-      listeners.frameworkError(plugin->q_func(), pe);
-      throw pe;
-    }
+  // If we enter with tempResolved set, it means that we already have
+  // resolved plugins. Check that it is true!
+  if (tempResolved.size() > 0 && !tempResolved.contains(plugin))
+  {
+    ctkPluginException pe("resolve: InternalError1!", ctkPluginException::RESOLVE_ERROR);
+    listeners.frameworkError(plugin->q_func(), pe);
+    throw pe;
+  }
 
-    tempResolved.clear();
-    tempResolved.insert(plugin);
+  tempResolved.clear();
+  tempResolved.insert(plugin);
 
-    checkRequirePlugin(plugin);
+  checkRequirePlugin(plugin);
 
-    tempResolved.clear();
+  tempResolved.clear();
 
-    qDebug() << "resolve: Done for" << plugin->symbolicName << "[" << plugin->id << "]";
-  }
+  qDebug() << "resolve: Done for" << plugin->symbolicName << "[" << plugin->id << "]";
+}
 
-  void ctkPluginFrameworkContext::checkRequirePlugin(ctkPluginPrivate *plugin)
+void ctkPluginFrameworkContext::checkRequirePlugin(ctkPluginPrivate *plugin)
+{
+  if (!plugin->require.isEmpty())
   {
-    if (!plugin->require.isEmpty())
-    {
-      qDebug() << "checkRequirePlugin: check requiring plugin" << plugin->id;
+    qDebug() << "checkRequirePlugin: check requiring plugin" << plugin->id;
 
-      QListIterator<ctkRequirePlugin*> i(plugin->require);
-      while (i.hasNext())
+    QListIterator<ctkRequirePlugin*> i(plugin->require);
+    while (i.hasNext())
+    {
+      ctkRequirePlugin* pr = i.next();
+      QList<ctkPlugin*> pl = plugins->getPlugins(pr->name, pr->pluginRange);
+      ctkPluginPrivate* ok = 0;
+      for (QListIterator<ctkPlugin*> pci(pl); pci.hasNext() && ok == 0; )
       {
-        ctkRequirePlugin* pr = i.next();
-        QList<ctkPlugin*> pl = plugins->getPlugins(pr->name, pr->pluginRange);
-        ctkPluginPrivate* ok = 0;
-        for (QListIterator<ctkPlugin*> pci(pl); pci.hasNext() && ok == 0; )
+        ctkPluginPrivate* p2 = pci.next()->d_func();
+        if (tempResolved.contains(p2))
         {
-          ctkPluginPrivate* p2 = pci.next()->d_func();
-          if (tempResolved.contains(p2))
-          {
-            ok = p2;
-          }
-          else if (ctkPluginPrivate::RESOLVED_FLAGS & p2->state)
-          {
-            ok = p2;
-          }
-          else if (p2->state == ctkPlugin::INSTALLED) {
-            QSet<ctkPluginPrivate*> oldTempResolved = tempResolved;
-            tempResolved.insert(p2);
-            checkRequirePlugin(p2);
-            tempResolved = oldTempResolved;
-            ok = p2;
-          }
+          ok = p2;
         }
-
-        if (!ok && pr->resolution == ctkPluginConstants::RESOLUTION_MANDATORY)
+        else if (ctkPluginPrivate::RESOLVED_FLAGS & p2->state)
         {
-          tempResolved.clear();
-          qDebug() << "checkRequirePlugin: failed to satisfy:" << pr->name;
-          throw ctkPluginException(QString("Failed to resolve required plugin: %1").arg(pr->name));
+          ok = p2;
+        }
+        else if (p2->state == ctkPlugin::INSTALLED) {
+          QSet<ctkPluginPrivate*> oldTempResolved = tempResolved;
+          tempResolved.insert(p2);
+          checkRequirePlugin(p2);
+          tempResolved = oldTempResolved;
+          ok = p2;
         }
       }
-    }
-
 
+      if (!ok && pr->resolution == ctkPluginConstants::RESOLUTION_MANDATORY)
+      {
+        tempResolved.clear();
+        qDebug() << "checkRequirePlugin: failed to satisfy:" << pr->name;
+        throw ctkPluginException(QString("Failed to resolve required plugin: %1").arg(pr->name));
+      }
+    }
+  }
 }
 
 void ctkPluginFrameworkContext::deleteFWDir()

+ 91 - 91
Libs/PluginFramework/ctkPluginFrameworkContext_p.h

@@ -32,124 +32,124 @@
 #include "ctkPluginFrameworkListeners_p.h"
 
 
-  class ctkPlugin;
-  class ctkPluginStorage;
-  class ctkServices;
-
-  class ctkPluginFrameworkContext {
+class ctkPlugin;
+class ctkPluginStorage;
+class ctkServices;
+
+class ctkPluginFrameworkContext {
 
-  public:
+public:
 
-      /**
-       * All plugins in this framework.
-       */
-      ctkPlugins* plugins;
+  /**
+   * All plugins in this framework.
+   */
+  ctkPlugins* plugins;
 
-      /**
-       * All listeners in this framework.
-       */
-      ctkPluginFrameworkListeners listeners;
+  /**
+   * All listeners in this framework.
+   */
+  ctkPluginFrameworkListeners listeners;
 
-      /**
-       * All registered services in this framework.
-       */
-      ctkServices* services;
+  /**
+   * All registered services in this framework.
+   */
+  ctkServices* services;
 
-      /**
-       * System plugin
-       */
-      ctkPluginFramework systemPlugin;
+  /**
+   * System plugin
+   */
+  ctkPluginFramework systemPlugin;
 
-      /**
-       * ctkPlugin storage
-       */
-      ctkPluginStorage* storage;
+  /**
+   * ctkPlugin storage
+   */
+  ctkPluginStorage* storage;
 
-      /**
-       * First framework init
-       */
-      bool firstInit;
+  /**
+   * First framework init
+   */
+  bool firstInit;
 
-      /**
-       * Framework id.
-       */
-      int id;
+  /**
+   * Framework id.
+   */
+  int id;
 
-      /**
-       * global lock.
-       */
-      static QMutex globalFwLock;
+  /**
+   * global lock.
+   */
+  static QMutex globalFwLock;
 
-      /**
-       * Id to use for next instance of plugin framework.
-       */
-      static int globalId;
+  /**
+   * Id to use for next instance of plugin framework.
+   */
+  static int globalId;
 
-      ctkProperties props;
+  ctkProperties props;
 
-      /**
-       * Contruct a framework context
-       *
-       */
-      ctkPluginFrameworkContext(const ctkProperties& initProps);
+  /**
+   * Contruct a framework context
+   *
+   */
+  ctkPluginFrameworkContext(const ctkProperties& initProps);
 
 
-      /**
-       * Initialize the framework
-       *
-       */
-      void init();
+  /**
+   * Initialize the framework
+   *
+   */
+  void init();
 
 
-      /**
-       * Undo as much as possible of what init() does.
-       *
-       */
-      void uninit();
+  /**
+   * Undo as much as possible of what init() does.
+   *
+   */
+  void uninit();
 
 
-      /**
-       *
-       */
-      int getId() const;
+  /**
+   *
+   */
+  int getId() const;
 
 
-      /**
-       * Check that the plugin belongs to this framework instance.
-       *
-       */
-      void checkOurPlugin(ctkPlugin* plugin) const;
+  /**
+   * Check that the plugin belongs to this framework instance.
+   *
+   */
+  void checkOurPlugin(ctkPlugin* plugin) const;
 
 
-      /**
-       * Check that the plugin specified can resolve all its
-       * Require-ctkPlugin constraints.
-       *
-       * @param plugin ctkPlugin to check, must be in INSTALLED state
-       *
-       * @throws ctkPluginException
-       */
-      void resolvePlugin(ctkPluginPrivate* plugin);
+  /**
+   * Check that the plugin specified can resolve all its
+   * Require-ctkPlugin constraints.
+   *
+   * @param plugin ctkPlugin to check, must be in INSTALLED state
+   *
+   * @throws ctkPluginException
+   */
+  void resolvePlugin(ctkPluginPrivate* plugin);
 
 
-      /**
-       * Log message for debugging framework
-       *
-       */
-      QDebug log() const;
+  /**
+   * Log message for debugging framework
+   *
+   */
+  QDebug log() const;
 
-  private:
+private:
 
-      QSet<ctkPluginPrivate*> tempResolved;
-
-      /**
-       * Delete framework directory if it exists.
-       *
-       */
-      void deleteFWDir();
+  QSet<ctkPluginPrivate*> tempResolved;
+
+  /**
+   * Delete framework directory if it exists.
+   *
+   */
+  void deleteFWDir();
 
-      void checkRequirePlugin(ctkPluginPrivate* plugin);
-  };
+  void checkRequirePlugin(ctkPluginPrivate* plugin);
+};
 
 
 #endif // CTKPLUGINFRAMEWORKCONTEXT_P_H

+ 11 - 11
Libs/PluginFramework/ctkPluginFrameworkPrivate_p.h

@@ -28,25 +28,25 @@
 #include <QMutex>
 
 
-  class ctkPluginFrameworkContext;
+class ctkPluginFrameworkContext;
 
-  class ctkPluginFrameworkPrivate : public ctkPluginPrivate
-  {
-  public:
+class ctkPluginFrameworkPrivate : public ctkPluginPrivate
+{
+public:
 
-    QMutex lock;
+  QMutex lock;
 
-    ctkPluginFrameworkPrivate(ctkPluginFramework& qq, ctkPluginFrameworkContext* fw);
+  ctkPluginFrameworkPrivate(ctkPluginFramework& qq, ctkPluginFrameworkContext* fw);
 
-    void init();
+  void init();
 
-    void initSystemPlugin();
+  void initSystemPlugin();
 
-    void uninitSystemPlugin();
+  void uninitSystemPlugin();
 
-    QHash<QString, QString> systemHeaders;
+  QHash<QString, QString> systemHeaders;
 
-  };
+};
 
 
 #endif // CTKPLUGINFRAMEWORKPRIVATE_P_H

+ 0 - 1
Libs/PluginFramework/ctkPluginPrivate_p.h

@@ -203,7 +203,6 @@ private:
    */
   void removePluginResources();
 
-
 };
 
 

+ 95 - 95
Libs/PluginFramework/ctkPluginStorage.cpp

@@ -33,121 +33,121 @@
 #include "ctkPluginDatabaseException.h"
 
 
-  ctkPluginStorage::ctkPluginStorage(ctkPluginFrameworkContext* framework)
-    : framework(framework), pluginDatabase(this)
-  {
-    // See if we have a storage database
-    QString path = ctkPluginFrameworkUtil::getFileStorage(framework, "").absoluteFilePath("plugins.db");
-
-    pluginDatabase.setDatabasePath(path);
-    pluginDatabase.open();
-    archives << pluginDatabase.getPluginArchives();
-  }
+ctkPluginStorage::ctkPluginStorage(ctkPluginFrameworkContext* framework)
+  : framework(framework), pluginDatabase(this)
+{
+  // See if we have a storage database
+  QString path = ctkPluginFrameworkUtil::getFileStorage(framework, "").absoluteFilePath("plugins.db");
+
+  pluginDatabase.setDatabasePath(path);
+  pluginDatabase.open();
+  archives << pluginDatabase.getPluginArchives();
+}
 
-  ctkPluginArchive* ctkPluginStorage::insertPlugin(const QUrl& location, const QString& localPath)
-  {
-    ctkPluginArchive* pa = pluginDatabase.insertPlugin(location, localPath);
-    archives.push_back(pa);
-    return pa;
-  }
+ctkPluginArchive* ctkPluginStorage::insertPlugin(const QUrl& location, const QString& localPath)
+{
+  ctkPluginArchive* pa = pluginDatabase.insertPlugin(location, localPath);
+  archives.push_back(pa);
+  return pa;
+}
 
-  ctkPluginArchive* ctkPluginStorage::updatePluginArchive(ctkPluginArchive* old, const QString& localPath)
-  {
-    Q_UNUSED(old)
-    Q_UNUSED(localPath)
-    //return new BundleArchiveImpl((BundleArchiveImpl)old, is);
-    return 0;
-  }
+ctkPluginArchive* ctkPluginStorage::updatePluginArchive(ctkPluginArchive* old, const QString& localPath)
+{
+  Q_UNUSED(old)
+  Q_UNUSED(localPath)
+  //return new BundleArchiveImpl((BundleArchiveImpl)old, is);
+  return 0;
+}
 
-  void ctkPluginStorage::replacePluginArchive(ctkPluginArchive* oldPA, ctkPluginArchive* newPA)
-  {
-    Q_UNUSED(oldPA)
-    Q_UNUSED(newPA)
-//    int pos;
-//    long id = oldBA.getBundleId();
-//    synchronized (archives) {
-//      pos = find(id);
-//      if (pos >= archives.size() || archives.get(pos) != oldBA) {
-//        throw new Exception("replaceBundleJar: Old bundle archive not found, pos=" + pos);
-//      }
-//      archives.set(pos, newBA);
-//    }
-  }
+void ctkPluginStorage::replacePluginArchive(ctkPluginArchive* oldPA, ctkPluginArchive* newPA)
+{
+  Q_UNUSED(oldPA)
+  Q_UNUSED(newPA)
+  //    int pos;
+  //    long id = oldBA.getBundleId();
+  //    synchronized (archives) {
+  //      pos = find(id);
+  //      if (pos >= archives.size() || archives.get(pos) != oldBA) {
+  //        throw new Exception("replaceBundleJar: Old bundle archive not found, pos=" + pos);
+  //      }
+  //      archives.set(pos, newBA);
+  //    }
+}
 
-  QList<ctkPluginArchive*> ctkPluginStorage::getAllPluginArchives() const
-  {
-    return archives;
-  }
+QList<ctkPluginArchive*> ctkPluginStorage::getAllPluginArchives() const
+{
+  return archives;
+}
 
-  QList<QString> ctkPluginStorage::getStartOnLaunchPlugins()
+QList<QString> ctkPluginStorage::getStartOnLaunchPlugins()
+{
+  QList<QString> res;
+  QListIterator<ctkPluginArchive*> i(archives);
+  while(i.hasNext())
   {
-    QList<QString> res;
-    QListIterator<ctkPluginArchive*> i(archives);
-    while(i.hasNext())
+    ctkPluginArchive* pa = i.next();
+    if (pa->getAutostartSetting() != -1)
     {
-      ctkPluginArchive* pa = i.next();
-      if (pa->getAutostartSetting() != -1)
-      {
-        res.push_back(pa->getPluginLocation().toString());
-      }
+      res.push_back(pa->getPluginLocation().toString());
     }
-    return res;
   }
+  return res;
+}
 
-  ctkPluginStorage::~ctkPluginStorage()
-  {
-    close();
-  }
+ctkPluginStorage::~ctkPluginStorage()
+{
+  close();
+}
+
+void ctkPluginStorage::close()
+{
+  pluginDatabase.close();
+  qDeleteAll(archives);
+}
 
-  void ctkPluginStorage::close()
+bool ctkPluginStorage::removeArchive(ctkPluginArchive* pa)
+{
+  QMutexLocker lock(&archivesLock);
+
+  bool removed = false;
+  try
   {
-    pluginDatabase.close();
-    qDeleteAll(archives);
+    pluginDatabase.removeArchive(pa);
+    removed = archives.removeAll(pa);
+    delete pa;
   }
-
-  bool ctkPluginStorage::removeArchive(ctkPluginArchive* pa)
+  catch (const ctkPluginDatabaseException& exc)
   {
-    QMutexLocker lock(&archivesLock);
+    qDebug() << "Removing plugin archive failed:" << exc;
+    removed = false;
+  }
 
-    bool removed = false;
-    try
-    {
-      pluginDatabase.removeArchive(pa);
-      removed = archives.removeAll(pa);
-      delete pa;
-    }
-    catch (const ctkPluginDatabaseException& exc)
-    {
-      qDebug() << "Removing plugin archive failed:" << exc;
-      removed = false;
-    }
+  return removed;
+}
 
-    return removed;
+QByteArray ctkPluginStorage::getPluginResource(long pluginId, const QString& res) const
+{
+  try
+  {
+    return pluginDatabase.getPluginResource(pluginId, res);
   }
-
-  QByteArray ctkPluginStorage::getPluginResource(long pluginId, const QString& res) const
+  catch (const ctkPluginDatabaseException& exc)
   {
-    try
-    {
-      return pluginDatabase.getPluginResource(pluginId, res);
-    }
-    catch (const ctkPluginDatabaseException& exc)
-    {
-      qDebug() << QString("Getting plugin resource %1 failed:").arg(res) << exc;
-      return QByteArray();
-    }
+    qDebug() << QString("Getting plugin resource %1 failed:").arg(res) << exc;
+    return QByteArray();
   }
+}
 
-  QStringList ctkPluginStorage::findResourcesPath(long pluginId, const QString& path) const
+QStringList ctkPluginStorage::findResourcesPath(long pluginId, const QString& path) const
+{
+  try
   {
-    try
-    {
-      return pluginDatabase.findResourcesPath(pluginId, path);
-    }
-    catch (const ctkPluginDatabaseException& exc)
-    {
-      qDebug() << QString("Getting plugin resource paths for %1 failed:").arg(path) << exc;
-      return QStringList();
-    }
+    return pluginDatabase.findResourcesPath(pluginId, path);
+  }
+  catch (const ctkPluginDatabaseException& exc)
+  {
+    qDebug() << QString("Getting plugin resource paths for %1 failed:").arg(path) << exc;
+    return QStringList();
+  }
 
 }

+ 237 - 227
Libs/PluginFramework/ctkPlugins.cpp

@@ -33,308 +33,318 @@
 #include <QUrl>
 
 
-  ctkPlugins::ctkPlugins(ctkPluginFrameworkContext* fw) {
-    fwCtx = fw;
-    plugins.insert(fw->systemPlugin.getLocation(), &fw->systemPlugin);
+ctkPlugins::ctkPlugins(ctkPluginFrameworkContext* fw)
+{
+  fwCtx = fw;
+  plugins.insert(fw->systemPlugin.getLocation(), &fw->systemPlugin);
+}
+
+void ctkPlugins::clear()
+{
+  QWriteLocker lock(&pluginsLock);
+  plugins.clear();
+  fwCtx = 0;
+}
+
+ctkPlugin* ctkPlugins::install(const QUrl& location, QIODevice* in)
+{
+  if (!fwCtx)
+  { // This ctkPlugins instance has been closed!
+    throw std::logic_error("ctkPlugins::install(location, inputStream) called on closed plugins object.");
   }
 
-  void ctkPlugins::clear()
   {
     QWriteLocker lock(&pluginsLock);
-    plugins.clear();
-    fwCtx = 0;
-  }
 
-  ctkPlugin* ctkPlugins::install(const QUrl& location, QIODevice* in)
-  {
-    if (!fwCtx)
-    { // This ctkPlugins instance has been closed!
-      throw std::logic_error("ctkPlugins::install(location, inputStream) called on closed plugins object.");
+    QHash<QString, ctkPlugin*>::const_iterator it = plugins.find(location.toString());
+    if (it != plugins.end())
+    {
+      return it.value();
     }
 
+    // install new plugin
+    ctkPluginArchive* pa = 0;
+    QString localPluginPath;
+    try
     {
-      QWriteLocker lock(&pluginsLock);
-
-      QHash<QString, ctkPlugin*>::const_iterator it = plugins.find(location.toString());
-      if (it != plugins.end()) {
-        return it.value();
-      }
-
-      // install new plugin
-      ctkPluginArchive* pa = 0;
-      QString localPluginPath;
-      try {
-        if (!in) {
-          // extract the input stream from the given location
-          
-
-//          //TODO Support for http proxy authentication
-//          //TODO put in update as well
-//          String auth = fwCtx.props.getProperty("http.proxyAuth");
-//          if (auth != null && !"".equals(auth)) {
-//            if ("http".equals(url.getProtocol()) ||
-//                "https".equals(url.getProtocol())) {
-//              String base64 = Util.base64Encode(auth);
-//              conn.setRequestProperty("Proxy-Authorization",
-//                                      "Basic " + base64);
-//            }
-//          }
-//          // Support for http basic authentication
-//          String basicAuth = fwCtx.props.getProperty("http.basicAuth");
-//          if (basicAuth != null && !"".equals(basicAuth)) {
-//            if ("http".equals(url.getProtocol()) ||
-//                "https".equals(url.getProtocol())) {
-//              String base64 = Util.base64Encode(basicAuth);
-//              conn.setRequestProperty("Authorization",
-//                                      "Basic " +base64);
-//            }
-//          }
-
-          if (location.scheme() != "file")
-          {
-            throw std::runtime_error(std::string("Unsupported url scheme: ") + qPrintable(location.scheme()));
-          }
-          else
-          {
-            qDebug() << QString("Trying to install file:") << location.path();
-            localPluginPath = location.toLocalFile();
-          }
-        } 
-        else 
+      if (!in)
+      {
+        // extract the input stream from the given location
+
+
+        //          //TODO Support for http proxy authentication
+        //          //TODO put in update as well
+        //          String auth = fwCtx.props.getProperty("http.proxyAuth");
+        //          if (auth != null && !"".equals(auth)) {
+        //            if ("http".equals(url.getProtocol()) ||
+        //                "https".equals(url.getProtocol())) {
+        //              String base64 = Util.base64Encode(auth);
+        //              conn.setRequestProperty("Proxy-Authorization",
+        //                                      "Basic " + base64);
+        //            }
+        //          }
+        //          // Support for http basic authentication
+        //          String basicAuth = fwCtx.props.getProperty("http.basicAuth");
+        //          if (basicAuth != null && !"".equals(basicAuth)) {
+        //            if ("http".equals(url.getProtocol()) ||
+        //                "https".equals(url.getProtocol())) {
+        //              String base64 = Util.base64Encode(basicAuth);
+        //              conn.setRequestProperty("Authorization",
+        //                                      "Basic " +base64);
+        //            }
+        //          }
+
+        if (location.scheme() != "file")
+        {
+          throw std::runtime_error(std::string("Unsupported url scheme: ") + qPrintable(location.scheme()));
+        }
+        else
         {
-          //TODO copy the QIODevice to a local cache
+          qDebug() << QString("Trying to install file:") << location.path();
+          localPluginPath = location.toLocalFile();
         }
+      }
+      else
+      {
+        //TODO copy the QIODevice to a local cache
+      }
 
-        pa = fwCtx->storage->insertPlugin(location, localPluginPath);
+      pa = fwCtx->storage->insertPlugin(location, localPluginPath);
 
-        ctkPlugin* res = new ctkPlugin(fwCtx, pa);
-        plugins.insert(location.toString(), res);
+      ctkPlugin* res = new ctkPlugin(fwCtx, pa);
+      plugins.insert(location.toString(), res);
 
-        fwCtx->listeners.emitPluginChanged(ctkPluginEvent(ctkPluginEvent::INSTALLED, res));
+      fwCtx->listeners.emitPluginChanged(ctkPluginEvent(ctkPluginEvent::INSTALLED, res));
 
-        return res;
-      }
-      catch (const std::exception& e)
+      return res;
+    }
+    catch (const std::exception& e)
+    {
+      if (pa)
       {
-        if (pa) {
-          pa->purge();
-        }
-  //      if (dynamic_cast<const SecurityException&>(e)) {
-  //        throw;
-  //      }
-  //      else
-  //      {
-        throw ctkPluginException(QString("Failed to install plugin: ") + QString(e.what()),
-                                ctkPluginException::UNSPECIFIED, &e);
-  //      }
+        pa->purge();
       }
+      //      if (dynamic_cast<const SecurityException&>(e)) {
+      //        throw;
+      //      }
+      //      else
+      //      {
+      throw ctkPluginException(QString("Failed to install plugin: ") + QString(e.what()),
+                               ctkPluginException::UNSPECIFIED, &e);
+      //      }
     }
-
   }
 
-  void ctkPlugins::remove(const QUrl& location)
-  {
-    QWriteLocker lock(&pluginsLock);
-    delete plugins.take(location.toString());
+}
+
+void ctkPlugins::remove(const QUrl& location)
+{
+  QWriteLocker lock(&pluginsLock);
+  delete plugins.take(location.toString());
+}
+
+ctkPlugin* ctkPlugins::getPlugin(int id) const
+{
+  if (!fwCtx)
+  { // This plugins instance has been closed!
+    throw std::logic_error("ctkPlugins::getPlugin(id) called on closed plugins object.");
   }
 
-  ctkPlugin* ctkPlugins::getPlugin(int id) const
   {
-    if (!fwCtx)
-    { // This plugins instance has been closed!
-      throw std::logic_error("ctkPlugins::getPlugin(id) called on closed plugins object.");
-    }
+    QReadLocker lock(&pluginsLock);
 
+    QHashIterator<QString, ctkPlugin*> it(plugins);
+    while (it.hasNext())
     {
-      QReadLocker lock(&pluginsLock);
-
-      QHashIterator<QString, ctkPlugin*> it(plugins);
-      while (it.hasNext())
+      ctkPlugin* plugin = it.next().value();
+      if (plugin->getPluginId() == id)
       {
-        ctkPlugin* plugin = it.next().value();
-        if (plugin->getPluginId() == id) {
-          return plugin;
-        }
+        return plugin;
       }
     }
-    return 0;
   }
+  return 0;
+}
 
-  ctkPlugin* ctkPlugins::getPlugin(const QString& location) const {
-    if (!fwCtx)
-    { // This plugins instance has been closed!
-      throw std::logic_error("ctkPlugins::getPlugin(location) called on closed plugins object.");
-    }
+ctkPlugin* ctkPlugins::getPlugin(const QString& location) const
+{
+  if (!fwCtx)
+  { // This plugins instance has been closed!
+    throw std::logic_error("ctkPlugins::getPlugin(location) called on closed plugins object.");
+  }
 
-    QReadLocker lock(&pluginsLock);
-    QHash<QString, ctkPlugin*>::const_iterator it = plugins.find(location);
-    if (it != plugins.end()) return it.value();
-    return 0;
+  QReadLocker lock(&pluginsLock);
+  QHash<QString, ctkPlugin*>::const_iterator it = plugins.find(location);
+  if (it != plugins.end()) return it.value();
+  return 0;
+}
+
+ctkPlugin* ctkPlugins::getPlugin(const QString& name, const ctkVersion& version) const
+{
+  if (!fwCtx)
+  { // This ctkPlugins instance has been closed!
+    throw std::logic_error("ctkPlugins::getPlugin(name, version) called on closed plugins object.");
   }
 
-  ctkPlugin* ctkPlugins::getPlugin(const QString& name, const ctkVersion& version) const
   {
-    if (!fwCtx)
-    { // This ctkPlugins instance has been closed!
-      throw std::logic_error("ctkPlugins::getPlugin(name, version) called on closed plugins object.");
-    }
+    QReadLocker lock(&pluginsLock);
 
+    QHashIterator<QString, ctkPlugin*> it(plugins);
+    while (it.hasNext())
     {
-      QReadLocker lock(&pluginsLock);
-
-      QHashIterator<QString, ctkPlugin*> it(plugins);
-      while (it.hasNext())
+      ctkPlugin* plugin = it.next().value();
+      if ((name == plugin->getSymbolicName()) && (version == plugin->getVersion()))
       {
-        ctkPlugin* plugin = it.next().value();
-        if ((name == plugin->getSymbolicName()) && (version == plugin->getVersion()))
-        {
-          return plugin;
-        }
+        return plugin;
       }
     }
-    return 0;
   }
+  return 0;
+}
 
-  QList<ctkPlugin*> ctkPlugins::getPlugins() const
-  {
-    if (!fwCtx)
-    { // This plugins instance has been closed!
-      throw std::logic_error("ctkPlugins::getPlugins() called on closed plugins object.");
-    }
-
-    {
-      QReadLocker lock(&pluginsLock);
-      return plugins.values();
-    }
+QList<ctkPlugin*> ctkPlugins::getPlugins() const
+{
+  if (!fwCtx)
+  { // This plugins instance has been closed!
+    throw std::logic_error("ctkPlugins::getPlugins() called on closed plugins object.");
   }
 
-  QList<ctkPlugin*> ctkPlugins::getPlugins(const QString& name) const
   {
-    QList<ctkPlugin*> res;
+    QReadLocker lock(&pluginsLock);
+    return plugins.values();
+  }
+}
 
+QList<ctkPlugin*> ctkPlugins::getPlugins(const QString& name) const
+{
+  QList<ctkPlugin*> res;
+
+  {
+    QReadLocker lock(&pluginsLock);
+    QHashIterator<QString, ctkPlugin*> it(plugins);
+    while (it.hasNext())
     {
-      QReadLocker lock(&pluginsLock);
-      QHashIterator<QString, ctkPlugin*> it(plugins);
-      while (it.hasNext())
+      ctkPlugin* plugin = it.next().value();
+      if (name == plugin->getSymbolicName())
       {
-        ctkPlugin* plugin = it.next().value();
-        if (name == plugin->getSymbolicName())
-        {
-          res.push_back(plugin);
-        }
+        res.push_back(plugin);
       }
     }
-
-    return res;
   }
 
-  QList<ctkPlugin*> ctkPlugins::getPlugins(const QString& name, const ctkVersionRange& range) const {
-    if (!fwCtx)
-    { // This plugins instance has been closed!
-      throw std::logic_error("ctkPlugins::getPlugins(name, versionRange) called on closed plugins object.");
-    }
+  return res;
+}
+
+QList<ctkPlugin*> ctkPlugins::getPlugins(const QString& name, const ctkVersionRange& range) const
+{
+  if (!fwCtx)
+  { // This plugins instance has been closed!
+    throw std::logic_error("ctkPlugins::getPlugins(name, versionRange) called on closed plugins object.");
+  }
 
-    QList<ctkPlugin*> pluginsWithName = getPlugins(name);
-    QList<ctkPlugin*> res;
+  QList<ctkPlugin*> pluginsWithName = getPlugins(name);
+  QList<ctkPlugin*> res;
 
-    QListIterator<ctkPlugin*> it(pluginsWithName);
-    while (it.hasNext()) {
-      ctkPlugin* plugin = it.next();
-      if (range.withinRange(plugin->getVersion()))
+  QListIterator<ctkPlugin*> it(pluginsWithName);
+  while (it.hasNext()) {
+    ctkPlugin* plugin = it.next();
+    if (range.withinRange(plugin->getVersion()))
+    {
+      int j = res.size();
+      while (--j >= 0)
       {
-        int j = res.size();
-        while (--j >= 0)
+        if (plugin->getVersion().compare(res.at(j)->getVersion()) <= 0)
         {
-          if (plugin->getVersion().compare(res.at(j)->getVersion()) <= 0)
-          {
-            break;
-          }
+          break;
         }
-        res.insert(j + 1, plugin);
       }
+      res.insert(j + 1, plugin);
     }
-
-    return res;
   }
 
-  QList<ctkPlugin*> ctkPlugins::getActivePlugins() const {
-    if (!fwCtx)
-    { // This plugins instance has been closed!
-      throw std::logic_error("ctkPlugins::getActivePlugins() called on closed plugins object.");
-    }
+  return res;
+}
 
-    QList<ctkPlugin*> slist;
+QList<ctkPlugin*> ctkPlugins::getActivePlugins() const
+{
+  if (!fwCtx)
+  { // This plugins instance has been closed!
+    throw std::logic_error("ctkPlugins::getActivePlugins() called on closed plugins object.");
+  }
+
+  QList<ctkPlugin*> slist;
+  {
+    QReadLocker lock(&pluginsLock);
+    QHashIterator<QString, ctkPlugin*> it(plugins);
+    while (it.hasNext())
     {
-      QReadLocker lock(&pluginsLock);
-      QHashIterator<QString, ctkPlugin*> it(plugins);
-      while (it.hasNext())
-      {
-        ctkPlugin* plugin = it.next().value();
-        ctkPlugin::State s = plugin->getState();
-        if (s == ctkPlugin::ACTIVE || s == ctkPlugin::STARTING) {
-          slist.push_back(plugin);
-        }
+      ctkPlugin* plugin = it.next().value();
+      ctkPlugin::State s = plugin->getState();
+      if (s == ctkPlugin::ACTIVE || s == ctkPlugin::STARTING) {
+        slist.push_back(plugin);
       }
     }
-    return slist;
   }
+  return slist;
+}
 
-  void ctkPlugins::load() {
-    QList<ctkPluginArchive*> pas = fwCtx->storage->getAllPluginArchives();
-    QListIterator<ctkPluginArchive*> it(pas);
+void ctkPlugins::load()
+{
+  QList<ctkPluginArchive*> pas = fwCtx->storage->getAllPluginArchives();
+  QListIterator<ctkPluginArchive*> it(pas);
 
+  {
+    QWriteLocker lock(&pluginsLock);
+    while (it.hasNext())
     {
-      QWriteLocker lock(&pluginsLock);
-      while (it.hasNext())
+      ctkPluginArchive* pa = it.next();
+      try
       {
-        ctkPluginArchive* pa = it.next();
-        try
-        {
-          ctkPlugin* plugin = new ctkPlugin(fwCtx, pa);
-          plugins.insert(pa->getPluginLocation().toString(), plugin);
-        }
-        catch (const std::exception& e)
-        {
-          pa->setAutostartSetting(-1); // Do not start on launch
-          pa->setStartLevel(-2); // Mark as uninstalled
-
-          std::cerr << "Error: Failed to load bundle "
-                    << pa->getPluginId()
-                    << " ("  << qPrintable(pa->getPluginLocation().toString())  << ")"
-                    << " uninstalled it!\n";
-          std::cerr << e.what();
-        }
+        ctkPlugin* plugin = new ctkPlugin(fwCtx, pa);
+        plugins.insert(pa->getPluginLocation().toString(), plugin);
+      }
+      catch (const std::exception& e)
+      {
+        pa->setAutostartSetting(-1); // Do not start on launch
+        pa->setStartLevel(-2); // Mark as uninstalled
+
+        std::cerr << "Error: Failed to load bundle "
+            << pa->getPluginId()
+            << " ("  << qPrintable(pa->getPluginLocation().toString())  << ")"
+            << " uninstalled it!\n";
+        std::cerr << e.what();
       }
     }
   }
+}
 
-  void ctkPlugins::startPlugins(const QList<ctkPlugin*>& slist) const {
-    // Sort in start order
-    // Resolve first to avoid dead lock
-    QListIterator<ctkPlugin*> it(slist);
-    while (it.hasNext())
-    {
-      ctkPlugin* plugin = it.next();
-      ctkPluginPrivate* pp = plugin->d_func();
-      pp->getUpdatedState();
-    }
+void ctkPlugins::startPlugins(const QList<ctkPlugin*>& slist) const
+{
+  // Sort in start order
+  // Resolve first to avoid dead lock
+  QListIterator<ctkPlugin*> it(slist);
+  while (it.hasNext())
+  {
+    ctkPlugin* plugin = it.next();
+    ctkPluginPrivate* pp = plugin->d_func();
+    pp->getUpdatedState();
+  }
 
-    it.toFront();
-    while (it.hasNext())
+  it.toFront();
+  while (it.hasNext())
+  {
+    ctkPlugin* plugin = it.next();
+    ctkPluginPrivate* pp = plugin->d_func();
+    if (pp->getUpdatedState() == ctkPlugin::RESOLVED)
     {
-      ctkPlugin* plugin = it.next();
-      ctkPluginPrivate* pp = plugin->d_func();
-      if (pp->getUpdatedState() == ctkPlugin::RESOLVED)
+      try
       {
-        try
-        {
-          plugin->start(0);
-        }
-        catch (const ctkPluginException& pe)
-        {
-          pp->fwCtx->listeners.frameworkError(plugin, pe);
-        }
+        plugin->start(0);
+      }
+      catch (const ctkPluginException& pe)
+      {
+        pp->fwCtx->listeners.frameworkError(plugin, pe);
       }
     }
-
+  }
 }

+ 152 - 152
Libs/PluginFramework/ctkServiceReference.h

@@ -29,168 +29,168 @@
 #include "ctkPluginFrameworkExport.h"
 
 
-  class ctkServiceRegistrationPrivate;
-  class ctkServiceReferencePrivate;
-  class ctkServiceEvent;
-  template<class Item, class Related> class ctkPluginAbstractTracked;
+class ctkServiceRegistrationPrivate;
+class ctkServiceReferencePrivate;
+class ctkServiceEvent;
+template<class Item, class Related> class ctkPluginAbstractTracked;
+
+/**
+ * A reference to a service.
+ *
+ * <p>
+ * The Framework returns <code>ctkServiceReference</code> objects from the
+ * <code>ctkPluginContext::getServiceReference</code> and
+ * <code>ctkPluginContext::getServiceReferences</code> methods.
+ * <p>
+ * A <code>ctkServiceReference</code> object may be shared between plugins and
+ * can be used to examine the properties of the service and to get the service
+ * object.
+ * <p>
+ * Every service registered in the Framework has a unique
+ * <code>ctkServiceRegistration</code> object and may have multiple, distinct
+ * <code>ctkServiceReference</code> objects referring to it.
+ * <code>ctkServiceReference</code> objects associated with a
+ * <code>ctkServiceRegistration</code> are considered equal
+ * (more specifically, their <code>operator==()</code>
+ * method will return <code>true</code> when compared).
+ * <p>
+ * If the same service object is registered multiple times,
+ * <code>ctkServiceReference</code> objects associated with different
+ * <code>ctkServiceRegistration</code> objects are not equal.
+ *
+ * @see ctkPluginContext::getServiceReference
+ * @see ctkPluginContext::getServiceReferences
+ * @see ctkPluginContext::getService
+ * @threadsafe
+ */
+class CTK_PLUGINFW_EXPORT ctkServiceReference {
+
+  Q_DECLARE_PRIVATE(ctkServiceReference)
+
+public:
+
+  ctkServiceReference(const ctkServiceReference& ref);
+
+  ~ctkServiceReference();
 
   /**
-   * A reference to a service.
+   * Returns the property value to which the specified property key is mapped
+   * in the properties <code>ServiceProperties</code> object of the service
+   * referenced by this <code>ctkServiceReference</code> object.
    *
    * <p>
-   * The Framework returns <code>ctkServiceReference</code> objects from the
-   * <code>ctkPluginContext::getServiceReference</code> and
-   * <code>ctkPluginContext::getServiceReferences</code> methods.
+   * Property keys are case-insensitive.
+   *
    * <p>
-   * A <code>ctkServiceReference</code> object may be shared between plugins and
-   * can be used to examine the properties of the service and to get the service
+   * This method must continue to return property values after the service has
+   * been unregistered. This is so references to unregistered services can
+   * still be interrogated.
+   *
+   * @param key The property key.
+   * @return The property value to which the key is mapped; an invalid QVariant
+   *         if there is no property named after the key.
+   */
+  QVariant getProperty(const QString& key) const;
+
+  /**
+   * Returns a list of the keys in the <code>ServiceProperties</code>
+   * object of the service referenced by this <code>ctkServiceReference</code>
    * object.
+   *
+   * <p>
+   * This method will continue to return the keys after the service has been
+   * unregistered. This is so references to unregistered services can
+   * still be interrogated.
+   *
    * <p>
-   * Every service registered in the Framework has a unique
-   * <code>ctkServiceRegistration</code> object and may have multiple, distinct
-   * <code>ctkServiceReference</code> objects referring to it.
-   * <code>ctkServiceReference</code> objects associated with a
-   * <code>ctkServiceRegistration</code> are considered equal
-   * (more specifically, their <code>operator==()</code>
-   * method will return <code>true</code> when compared).
+   * This method is not <i>case-preserving</i>; this means that every key in the
+   * returned array is in lower case, which may not be the case for the corresponding key in the
+   * properties <code>ServiceProperties</code> that was passed to the
+   * {@link ctkPluginContext::registerService(const QStringList&, QObject*, const ServiceProperties&)} or
+   * {@link ctkServiceRegistration::setProperties} methods.
+   *
+   * @return A list of property keys.
+   */
+  QStringList getPropertyKeys() const;
+
+  /**
+   * Returns the plugin that registered the service referenced by this
+   * <code>ctkServiceReference</code> object.
+   *
+   * <p>
+   * This method must return <code>0</code> when the service has been
+   * unregistered. This can be used to determine if the service has been
+   * unregistered.
+   *
+   * @return The plugin that registered the service referenced by this
+   *         <code>ctkServiceReference</code> object; <code>0</code> if that
+   *         service has already been unregistered.
+   * @see ctkPluginContext::registerService(const QStringList&, QObject* , const ServiceProperties&)
+   */
+  ctkPlugin* getPlugin() const;
+
+  /**
+   * Returns the plugins that are using the service referenced by this
+   * <code>ctkServiceReference</code> object. Specifically, this method returns
+   * the plugins whose usage count for that service is greater than zero.
+   *
+   * @return A list of plugins whose usage count for the service referenced
+   *         by this <code>ctkServiceReference</code> object is greater than
+   *         zero.
+   */
+  QList<ctkPlugin*> getUsingPlugins() const;
+
+  /**
+   * Compares this <code>ctkServiceReference</code> with the specified
+   * <code>ctkServiceReference</code> for order.
+   *
    * <p>
-   * If the same service object is registered multiple times,
-   * <code>ctkServiceReference</code> objects associated with different
-   * <code>ctkServiceRegistration</code> objects are not equal.
+   * If this <code>ctkServiceReference</code> and the specified
+   * <code>ctkServiceReference</code> have the same {@link ctkPluginConstants::SERVICE_ID
+   * service id} they are equal. This <code>ctkServiceReference</code> is less
+   * than the specified <code>ctkServiceReference</code> if it has a lower
+   * {@link ctkPluginConstants::SERVICE_RANKING service ranking} and greater if it has a
+   * higher service ranking. Otherwise, if this <code>ctkServiceReference</code>
+   * and the specified <code>ctkServiceReference</code> have the same
+   * {@link ctkPluginConstants::SERVICE_RANKING service ranking}, this
+   * <code>ctkServiceReference</code> is less than the specified
+   * <code>ctkServiceReference</code> if it has a higher
+   * {@link ctkPluginConstants::SERVICE_ID service id} and greater if it has a lower
+   * service id.
    *
-   * @see ctkPluginContext::getServiceReference
-   * @see ctkPluginContext::getServiceReferences
-   * @see ctkPluginContext::getService
-   * @threadsafe
+   * @param reference The <code>ctkServiceReference</code> to be compared.
+   * @return Returns a false or true if this
+   *         <code>ctkServiceReference</code> is less than or greater
+   *         than the specified <code>ctkServiceReference</code>.
+   * @throws std::invalid_argument If the specified
+   *         <code>ctkServiceReference</code> was not created by the same
+   *         framework instance as this <code>ctkServiceReference</code>.
    */
-  class CTK_PLUGINFW_EXPORT ctkServiceReference {
-
-    Q_DECLARE_PRIVATE(ctkServiceReference)
-
-  public:
-
-    ctkServiceReference(const ctkServiceReference& ref);
-
-    ~ctkServiceReference();
-
-    /**
-     * Returns the property value to which the specified property key is mapped
-     * in the properties <code>ServiceProperties</code> object of the service
-     * referenced by this <code>ctkServiceReference</code> object.
-     *
-     * <p>
-     * Property keys are case-insensitive.
-     *
-     * <p>
-     * This method must continue to return property values after the service has
-     * been unregistered. This is so references to unregistered services can
-     * still be interrogated.
-     *
-     * @param key The property key.
-     * @return The property value to which the key is mapped; an invalid QVariant
-     *         if there is no property named after the key.
-     */
-    QVariant getProperty(const QString& key) const;
-
-    /**
-     * Returns a list of the keys in the <code>ServiceProperties</code>
-     * object of the service referenced by this <code>ctkServiceReference</code>
-     * object.
-     *
-     * <p>
-     * This method will continue to return the keys after the service has been
-     * unregistered. This is so references to unregistered services can
-     * still be interrogated.
-     *
-     * <p>
-     * This method is not <i>case-preserving</i>; this means that every key in the
-     * returned array is in lower case, which may not be the case for the corresponding key in the
-     * properties <code>ServiceProperties</code> that was passed to the
-     * {@link ctkPluginContext::registerService(const QStringList&, QObject*, const ServiceProperties&)} or
-     * {@link ctkServiceRegistration::setProperties} methods.
-     *
-     * @return A list of property keys.
-     */
-    QStringList getPropertyKeys() const;
-
-    /**
-     * Returns the plugin that registered the service referenced by this
-     * <code>ctkServiceReference</code> object.
-     *
-     * <p>
-     * This method must return <code>0</code> when the service has been
-     * unregistered. This can be used to determine if the service has been
-     * unregistered.
-     *
-     * @return The plugin that registered the service referenced by this
-     *         <code>ctkServiceReference</code> object; <code>0</code> if that
-     *         service has already been unregistered.
-     * @see ctkPluginContext::registerService(const QStringList&, QObject* , const ServiceProperties&)
-     */
-    ctkPlugin* getPlugin() const;
-
-    /**
-     * Returns the plugins that are using the service referenced by this
-     * <code>ctkServiceReference</code> object. Specifically, this method returns
-     * the plugins whose usage count for that service is greater than zero.
-     *
-     * @return A list of plugins whose usage count for the service referenced
-     *         by this <code>ctkServiceReference</code> object is greater than
-     *         zero.
-     */
-    QList<ctkPlugin*> getUsingPlugins() const;
-
-    /**
-     * Compares this <code>ctkServiceReference</code> with the specified
-     * <code>ctkServiceReference</code> for order.
-     *
-     * <p>
-     * If this <code>ctkServiceReference</code> and the specified
-     * <code>ctkServiceReference</code> have the same {@link ctkPluginConstants::SERVICE_ID
-     * service id} they are equal. This <code>ctkServiceReference</code> is less
-     * than the specified <code>ctkServiceReference</code> if it has a lower
-     * {@link ctkPluginConstants::SERVICE_RANKING service ranking} and greater if it has a
-     * higher service ranking. Otherwise, if this <code>ctkServiceReference</code>
-     * and the specified <code>ctkServiceReference</code> have the same
-     * {@link ctkPluginConstants::SERVICE_RANKING service ranking}, this
-     * <code>ctkServiceReference</code> is less than the specified
-     * <code>ctkServiceReference</code> if it has a higher
-     * {@link ctkPluginConstants::SERVICE_ID service id} and greater if it has a lower
-     * service id.
-     *
-     * @param reference The <code>ctkServiceReference</code> to be compared.
-     * @return Returns a false or true if this
-     *         <code>ctkServiceReference</code> is less than or greater
-     *         than the specified <code>ctkServiceReference</code>.
-     * @throws std::invalid_argument If the specified
-     *         <code>ctkServiceReference</code> was not created by the same
-     *         framework instance as this <code>ctkServiceReference</code>.
-     */
-    bool operator<(const ctkServiceReference& reference) const;
-
-    bool operator==(const ctkServiceReference& reference) const;
-
-    ctkServiceReference& operator=(const ctkServiceReference& reference);
-
-
-  protected:
-
-    friend class ctkLDAPSearchFilter;
-    friend class ctkServiceRegistrationPrivate;
-    friend class ctkPluginContext;
-    friend class ctkPluginPrivate;
-    friend class ctkPluginFrameworkListeners;
-    friend class ctkServiceTrackerPrivate;
-    friend class ctkServiceTracker;
-    friend class ctkPluginAbstractTracked<ctkServiceReference, ctkServiceEvent>;
-
-    ctkServiceReference(ctkServiceRegistrationPrivate* reg);
-
-    bool isNull() const;
-
-    ctkServiceReferencePrivate * d_ptr;
-
-  };
+  bool operator<(const ctkServiceReference& reference) const;
+
+  bool operator==(const ctkServiceReference& reference) const;
+
+  ctkServiceReference& operator=(const ctkServiceReference& reference);
+
+
+protected:
+
+  friend class ctkLDAPSearchFilter;
+  friend class ctkServiceRegistrationPrivate;
+  friend class ctkPluginContext;
+  friend class ctkPluginPrivate;
+  friend class ctkPluginFrameworkListeners;
+  friend class ctkServiceTrackerPrivate;
+  friend class ctkServiceTracker;
+  friend class ctkPluginAbstractTracked<ctkServiceReference, ctkServiceEvent>;
+
+  ctkServiceReference(ctkServiceRegistrationPrivate* reg);
+
+  bool isNull() const;
+
+  ctkServiceReferencePrivate * d_ptr;
+
+};
 
 uint CTK_PLUGINFW_EXPORT qHash(const ctkServiceReference& serviceRef);
 QDebug CTK_PLUGINFW_EXPORT operator<<(QDebug dbg, const ctkServiceReference& serviceRef);