comparison m-toolbox/classes/@param/setProperty.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % SETPROPERTY set a property to a parameter.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SETPROPERTY set a property to a parameter. If the property
5 % name exists then replace the value otherwise add this
6 % property.
7 %
8 % CALL: obj = obj.setProperty(propertyName, val);
9 %
10 % INPUTS: propertyName: Property name of the paramValue object
11 % value: Value of the property
12 %
13 % VERSION: $Id: setProperty.m,v 1.2 2011/02/22 15:53:12 hewitson Exp $
14 %
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
17 function obj = setProperty(obj, propertyName, value)
18
19 if nargin ~= 3
20 error('### This method works only with three inputs.');
21 end
22
23 if ~isempty(obj.val)
24 obj = copy(obj, nargout);
25
26 % if the value is not a paramValue, we need to promote it before
27 % setting the property.
28 if ~isa(obj.val, 'paramValue')
29 obj.val = paramValue(1, {obj.val});
30 end
31
32 obj.val.setProperty(propertyName, value);
33 else
34 error('### There is no value set! Therefore it is not possible to set for this value a property.')
35 end
36
37 end