瀏覽代碼

Added getProperty() method to ctkPluginContext()

Using this method it is possible to retrieve framework
properties which might have been set when the plugin
framework was initialized.
Sascha Zelzer 14 年之前
父節點
當前提交
5d2637afc3
共有 2 個文件被更改,包括 18 次插入0 次删除
  1. 7 0
      Libs/PluginFramework/ctkPluginContext.cpp
  2. 11 0
      Libs/PluginFramework/ctkPluginContext.h

+ 7 - 0
Libs/PluginFramework/ctkPluginContext.cpp

@@ -58,6 +58,13 @@ ctkPluginContext::~ctkPluginContext()
   delete d;
 }
 
+QVariant ctkPluginContext::getProperty(const QString& key) const
+{
+  Q_D(const ctkPluginContext);
+  d->isPluginContextValid();
+  return d->plugin->fwCtx->props.value(key);
+}
+
 ctkPlugin* ctkPluginContext::getPlugin() const
 {
   Q_D(const ctkPluginContext);

+ 11 - 0
Libs/PluginFramework/ctkPluginContext.h

@@ -100,6 +100,17 @@
     ~ctkPluginContext();
 
     /**
+     * Returns the value of the specified property. If the key is not found in
+     * the Framework properties, the system properties are then searched. The
+     * method returns an invalid QVariant if the property is not found.
+     *
+     * @param key The name of the requested property.
+     * @return The value of the requested property, or an invalid QVariant if
+     *         the property is undefined.
+     */
+    QVariant getProperty(const QString& key) const;
+
+    /**
      * Returns the <code>ctkPlugin</code> object associated with this
      * <code>ctkPluginContext</code>. This plugin is called the context plugin.
      *