comparison m-toolbox/classes/@plist/processSetterValues.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 % PROCESSSETTERVALUES
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: PROCESSSETTERVALUES
5 %
6 % CALL: [objs, vals] = processSetterValues(objs, rest, pName)
7 %
8 % IMPUTS: objs: Array of objects
9 % rest: Cell-array with possible values
10 % pName: Property name of objs
11 %
12 % OUTPUTS: objs: It is necessary to pass objs back because it is
13 % possible that one of the input PLISTs was a
14 % configuration PLIST.
15 % vals: A cell-array with the value we want to set.
16 %
17 % VERSION: $Id: processSetterValues.m,v 1.2 2011/09/16 04:59:54 hewitson Exp $
18 %
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20
21 function [objs, values] = processSetterValues(objs, pls, rest, pName)
22
23 for kk = 1:numel(objs)
24 pls = objs(kk);
25 % If pls contains only one plist with the single key of the property
26 % name then set the property with a plist.
27 if length(pls) == 1 && isa(pls, 'plist') && nparams(pls) == 1 && isparam(pls, pName)
28 rest{1} = find(pls, pName);
29 objs(kk) = [];
30 break;
31 end
32 end
33
34 % Check if the user uses a cell-array for the different values
35 if numel(rest)==1 && iscell(rest{1})
36 rest = rest{1};
37 end
38
39 % Check the number of value
40 if numel(rest) > 1 && numel(rest) ~= numel(objs)
41 error('### Please specify one %s [n=%d] for each %s [n=%d], either in a plist or direct.', pName, numel(rest), upper(class(objs)), numel(objs));
42 end
43
44 % Replicate the values in 'rest' to the number of AOs
45 if numel(rest) == 1 && numel(objs) ~= 1
46 u = rest{1};
47 rest = cell(size(objs));
48 if isa(u, 'ltpda_obj')
49 rest = cellfun(@(x){copy(u, 1)}, rest);
50 else
51 rest(:) = {u};
52 end
53 end
54
55 values = rest;
56
57 end