Mercurial > hg > ltpda
comparison m-toolbox/classes/@plist/processForHistory.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 % PROCESSFORHISTORY process the plist ready for adding to the history tree. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: PROCESSFORHISTORY process the plist ready for adding to the history tree. | |
5 % | |
6 % | |
7 % CALL: plout = processForHistory(pl, Nobjs, idx, keys) | |
8 % | |
9 % PARAMETERS: pl: the input plist | |
10 % Nobjs: the number of objects that this plist is being used to process | |
11 % idx: the index of the object currently being processed | |
12 % keys: a list of keys which support multiple values and which | |
13 % may be modified by this method. | |
14 % | |
15 % NOTE: The point is to handle the keys which support multiple values and | |
16 % to ensure that a particular object gets the correct history plist. This | |
17 % needs to be used in the case where we are adding history to a single | |
18 % object (in a loop). Using it in any other case will likely cause | |
19 % problems. | |
20 % | |
21 % VERSION: $Id: processForHistory.m,v 1.1 2011/08/12 11:44:31 hewitson Exp $ | |
22 % | |
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
24 function varargout = processForHistory(varargin) | |
25 | |
26 pl = varargin{1}; | |
27 nobjs = varargin{2}; | |
28 idx = varargin{3}; | |
29 keys = varargin{4}; | |
30 | |
31 plout = copy(pl, 1); | |
32 | |
33 for kk=1:numel(keys) | |
34 key = keys{kk}; | |
35 if pl.isparam(key) | |
36 val = pl.find(key); | |
37 if iscell(val) | |
38 if numel(val) == 1 | |
39 plout.pset(key, val{1}); | |
40 else | |
41 if numel(val) ~= nobjs | |
42 error('The number of values for key %s does not match the number of objects', key); | |
43 end | |
44 plout.pset(key, val{idx}); | |
45 end | |
46 end | |
47 end | |
48 end | |
49 | |
50 varargout{1} = plout; | |
51 end |