diff m-toolbox/classes/@param/getProperty.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@param/getProperty.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,37 @@
+% GETPROPERTY get a property from a parameter.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: GETPROPERTY get a property from a parameter. If the property
+%              name exists then it returns the value otherwise an empty
+%              array ([]).
+%
+% CALL:        obj = obj.getProperty(propertyName);
+%
+% INPUTS:      propertyName: Property name of the paramValue object
+%
+% VERSION:     $Id: getProperty.m,v 1.2 2011/02/22 15:42:25 hewitson Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function val = getProperty(obj, propertyName)
+
+  if nargin ~= 2
+    error('### This method works only with two inputs.');
+  end
+  
+  if ~isa(obj.val, 'paramValue')
+    val = [];
+    return
+  end
+  
+  if ~isempty(obj.val)
+    if isfield(obj.val.property, propertyName)
+      val = obj.val.property.(propertyName);
+    else
+      val = [];
+    end
+  else
+    val = [];
+  end
+  
+end