comparison m-toolbox/classes/@pest/genericSet.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 % GENERICSET sets values to a pest property.
2 %
3 % CALL:
4 % out = genericSet(args, paramName, in_names, callerIsMethod);
5 %
6 % $Id: genericSet.m,v 1.6 2011/08/16 05:16:16 hewitson Exp $
7 %
8 function out = genericSet(varargin)
9
10 pName = varargin{end-2};
11 in_names = varargin{end-1};
12 callerIsMethod = varargin{end};
13 args = varargin(1:end-3);
14
15 if callerIsMethod
16 objs = varargin{1};
17 values = varargin(2:end-3);
18 else
19
20 % Collect all Objects
21 [objs, objs_invars, rest] = utils.helper.collect_objects(args(:), '', in_names);
22 [pls, invars, values] = utils.helper.collect_objects(rest(:), 'plist');
23
24 %%% If pls contains only one plist with the single property-key then set
25 %%% the property with a plist.
26 if length(pls) == 1 && isa(pls, 'plist') && nparams(pls) == 1 && isparam(pls, pName)
27 values{1} = find(pls, pName);
28 end
29
30 % Get minfo-object
31 mi = objs.getInfo(sprintf('set%s%s', upper(pName(1)), pName(2:end)));
32 dpl = mi.plists;
33
34 % Combine input plists and default PLIST
35 pls = combine(pls, dpl);
36
37 end % callerIsMethod
38
39 % Decide on a deep copy or a modify
40 objs = copy(objs, nargout);
41
42 % Loop over AOs
43 for j=1:numel(objs)
44 objs(j).(pName) = values(:);
45 if ~callerIsMethod
46 plh = pls.pset(pName, objs(j).(pName));
47 objs(j).addHistory(objs.getInfo(sprintf('set%s%s', upper(pName(1)), pName(2:end)), 'None'), plh, objs_invars(j), objs(j).hist);
48 end
49 end
50 out = objs;
51
52 end
53