comparison m-toolbox/classes/@collection/setObjs.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 % SETOBJS sets the 'objs' property of a collection object.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SETOBJS sets the 'objs' property of a collection object.
5 %
6 % CALL: obj = setObjs(obj, val)
7 % obj = obj.setObjs(plist('objs', ltpda_uoh-objects);
8 %
9 % <a href="matlab:utils.helper.displayMethodInfo('collection', 'setObjs')">Parameters Description</a>
10 %
11 % VERSION: $Id: setObjs.m,v 1.11 2011/04/08 08:56:22 hewitson Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = setObjs(varargin)
16
17 %%% Check if this is a call for parameters
18 if utils.helper.isinfocall(varargin{:})
19 varargout{1} = getInfo(varargin{3});
20 return
21 end
22
23 % Check if this is a call from a class method
24 if utils.helper.callerIsMethod
25
26 % Internal call: Only one object + don't look for a plist
27 varargin{1} = copy(varargin{1}, nargout);
28
29 for ii = 1:numel(varargin{1})
30 varargin{1}(ii).objs = varargin{2};
31 end
32 varargout{1} = varargin{1};
33 return
34 end
35
36 import utils.const.*
37 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
38
39 % Collect input variable names
40 in_names = cell(size(varargin));
41 for ii = 1:nargin,in_names{ii} = inputname(ii);end
42
43 % Collect all collection objects
44 [colls, colls_invars, rest] = utils.helper.collect_objects(varargin(:), 'collection', in_names);
45
46 % Identify the objects which should go into the collection.
47 [inobjs, plConfig] = collection.identifyInsideObjs(rest{:});
48
49 % Decide on a deep copy or a modify
50 colls = copy(colls, nargout);
51
52 % Loop over all objects objects
53 for jj=1:numel(colls)
54
55 histories = [];
56 inplists = [];
57 colls(jj).objs = inobjs;
58
59 % The history of the objects with history will go into the history of
60 % the collection and the inside PLISTs must go into the plistUsed
61 % because they doesn't have history.
62 for rr=1:numel(inobjs)
63 if isa(inobjs{rr}, 'ltpda_uoh')
64 histories = [histories inobjs{rr}.hist];
65 else
66 inplists = [inplists inobjs{rr}];
67 end
68 end
69
70 if ~isempty(inplists)
71 plh = plConfig.combine(plist('objs', {inplists}));
72 else
73 plh = plConfig;
74 end
75
76 % Set some properties
77 warning('off', utils.const.warnings.METHOD_NOT_FOUND);
78 colls(jj).setProperties(plConfig);
79 warning('on', utils.const.warnings.METHOD_NOT_FOUND);
80
81 % Add history from the collection and all the input variables
82 colls(jj).addHistory(getInfo('None'), plh, colls_invars(jj), [colls(jj).hist histories]);
83 end
84
85 % Set output
86 if nargout == numel(colls)
87 % List of outputs
88 for ii = 1:numel(colls)
89 varargout{ii} = colls(ii);
90 end
91 else
92 % Single output
93 varargout{1} = colls;
94 end
95 end
96
97 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98 % Local Functions %
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 %--------------------------------------------------------------------------
101 % Get Info Object
102 %--------------------------------------------------------------------------
103 function ii = getInfo(varargin)
104
105 if nargin == 1 && strcmpi(varargin{1}, 'None')
106 sets = {};
107 pl = [];
108 else
109 sets = {'Default'};
110 pl = getDefaultPlist;
111 end
112 % Build info object
113 ii = minfo(mfilename, 'collection', 'ltpda', utils.const.categories.helper, '$Id: setObjs.m,v 1.11 2011/04/08 08:56:22 hewitson Exp $', sets, pl);
114 end
115
116 %--------------------------------------------------------------------------
117 % Get Default Plist
118 %--------------------------------------------------------------------------
119 function plout = getDefaultPlist()
120 persistent pl;
121 if exist('pl', 'var')==0 || isempty(pl)
122 pl = buildplist();
123 end
124 plout = pl;
125 end
126
127 function pl = buildplist()
128 pl = plist({'objs', 'The inner objects to set.'}, paramValue.EMPTY_DOUBLE);
129 end
130