Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
5d2637afc3

+ 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.
      *