浏览代码

FIX: PluginFramework: fixed getPlugin() methods and corrected documentation

Sascha Zelzer 15 年之前
父节点
当前提交
f8fc730dab

+ 9 - 3
Libs/PluginFramework/ctkPluginContext.cxx

@@ -65,14 +65,20 @@ namespace ctk {
 
   PluginContext::~PluginContext()
   {
-	  Q_D(PluginContext);
-	  delete d;
+    Q_D(PluginContext);
+    delete d;
   }
 
-  Plugin* PluginContext::getPlugin(int id) const
+  Plugin* PluginContext::getPlugin() const
   {
     Q_D(const PluginContext);
     d->isPluginContextValid();
+    return d->plugin->q_func();
+  }
+
+  Plugin* PluginContext::getPlugin(long id) const
+  {
+    Q_D(const PluginContext);
     return d->plugin->fwCtx->plugins->getPlugin(id);
   }
 

+ 11 - 1
Libs/PluginFramework/ctkPluginContext.h

@@ -109,7 +109,17 @@ namespace ctk {
      * @throws std::logic_error If this PluginContext is no
      *         longer valid.
      */
-    Plugin* getPlugin(int id) const;
+    Plugin* getPlugin() const;
+
+    /**
+     * Returns the plugin with the specified identifier.
+     *
+     * @param id The identifier of the plugin to retrieve.
+     * @return A <code>Plugin</code> object or <code>0</code> if the
+     *         identifier does not match any installed plugin.
+     */
+    Plugin* getPlugin(long id) const;
+
 
     /**
      * Returns a list of all installed plugins.

+ 2 - 4
Libs/PluginFramework/ctkPluginPrivate_p.h

@@ -39,12 +39,12 @@ namespace ctk {
 
   protected:
 
-    Q_DECLARE_PUBLIC(Plugin)
-
     Plugin * const q_ptr;
 
   public:
 
+    Q_DECLARE_PUBLIC(Plugin)
+
     /**
      * Construct a new plugin based on a PluginArchive.
      *
@@ -179,8 +179,6 @@ namespace ctk {
 
   private:
 
-    friend class PluginFrameworkContext;
-
     /**
      * Check manifest and cache certain manifest headers as variables.
      */