comparison m-toolbox/classes/@collection/fromInput.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 % Construct a collection object from ltpda_uoh objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % FUNCTION: fromInput
5 %
6 % DESCRIPTION: Construct a collection object from ltpda_uoh objects.
7 %
8 % CALL: collection = collection.fromInput(inobjs)
9 %
10 % VERSION: $Id: fromInput.m,v 1.7 2010/06/11 19:19:11 ingo Exp $
11 %
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 function obj = fromInput(obj, pl)
14
15 import utils.const.*
16 utils.helper.msg(msg.OPROC1, 'Construct from inputs');
17
18 plConfig = collection.getDefaultPlist('From Input');
19
20 % Get the collection objects out of the configuration PLIST.
21 inobjs = pl.find('objs');
22
23 % Convert inobjs to an cell-array
24 if ~iscell(inobjs)
25 inobjs = num2cell(reshape(inobjs, 1, []));
26 end
27
28 % Identify the objects which should go into the collection.
29 [inobjs, plConfig] = collection.identifyInsideObjs(inobjs);
30
31 % Set the inside objects
32 obj.objs = inobjs;
33
34 inhists = [];
35 inplists = [];
36 if ~isempty(inobjs)
37 % Loop over the 'inobjs' because it is possible that a plist which
38 % doesn't have a history is in 'inobjs'
39 for ll = 1:numel(inobjs)
40 if isa(inobjs{ll}, 'ltpda_uoh')
41 inhists = [inhists inobjs{ll}.hist];
42 else
43 inplists = [inplists inobjs{ll}];
44 end
45 end
46 end
47
48 % Add the input plists again as a value to the history-plist because the
49 % plists doesn't have history-steps which we can add to the collection
50 % object.
51 if ~isempty(inplists)
52 plHist = plConfig.combine(plist('objs', {inplists}));
53 else
54 plHist = plConfig;
55 end
56
57 obj.addHistory(collection.getInfo('collection', 'None'), plHist, [], inhists);
58
59 warning('off', utils.const.warnings.METHOD_NOT_FOUND);
60 obj.setProperties(plConfig);
61 warning('on', utils.const.warnings.METHOD_NOT_FOUND);
62 end