comparison m-toolbox/classes/@matrix/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 matrix object.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SETOBJS sets the 'objs' property of a matrix 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('matrix', 'setObjs')">Parameters Description</a>
10 %
11 % VERSION: $Id: setObjs.m,v 1.9 2011/04/08 08:56:31 hewitson Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = setObjs(varargin)
16
17 % Check if this is a call from a class method
18 callerIsMethod = utils.helper.callerIsMethod;
19
20 if callerIsMethod
21 objs = varargin{1};
22 rest = varargin(2:end);
23
24 else
25 %%% Check if this is a call for parameters
26 if utils.helper.isinfocall(varargin{:})
27 varargout{1} = getInfo(varargin{3});
28 return
29 end
30
31 import utils.const.*
32 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
33
34 % Collect input variable names
35 in_names = cell(size(varargin));
36 for ii = 1:nargin,in_names{ii} = inputname(ii);end
37
38 % Collect all ltpdauoh objects
39 [objs, objs_invars, rest] = utils.helper.collect_objects(varargin(:), '', in_names);
40 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist');
41
42 %%% If pls contains only one plist with the single key 'objs' then set the
43 %%% property with a plist.
44 if length(pls) == 1 && isa(pls, 'plist') && isparam(pls, 'objs')
45 rest{1} = find(pls, 'objs');
46 if isparam(pls, 'shape')
47 rest{1} = reshape(rest{1}, pls.find('shape'));
48 end
49 end
50
51 if numel(rest) ~= 1
52 error('### Please specify a value for the inner objects, either in a plist or directly.');
53 end
54
55 %%% Combine plists
56 pls = combine(pls, getDefaultPlist());
57
58 end % callerIsMethod
59
60 % Decide on a deep copy or a modify
61 objs = copy(objs, nargout);
62
63 % Loop over all objects objects
64 for j=1:numel(objs)
65 objs(j).objs = rest{1};
66 if ~callerIsMethod
67 pls.pset('objs', rest{1});
68 pls.pset('shape', size(rest{1}));
69 objs(j).addHistory(getInfo('None'), pls, objs_invars(j), objs(j).hist);
70 end
71 end
72
73 % Set output
74 if nargout == numel(objs)
75 % List of outputs
76 for ii = 1:numel(objs)
77 varargout{ii} = objs(ii);
78 end
79 else
80 % Single output
81 varargout{1} = objs;
82 end
83 end
84
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 % Local Functions %
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 %--------------------------------------------------------------------------
89 % Get Info Object
90 %--------------------------------------------------------------------------
91 function ii = getInfo(varargin)
92
93 if nargin == 1 && strcmpi(varargin{1}, 'None')
94 sets = {};
95 pl = [];
96 else
97 sets = {'Default'};
98 pl = getDefaultPlist;
99 end
100 % Build info object
101 ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.helper, '$Id: setObjs.m,v 1.9 2011/04/08 08:56:31 hewitson Exp $', sets, pl);
102 end
103
104 %--------------------------------------------------------------------------
105 % Get Default Plist
106 %--------------------------------------------------------------------------
107 function plout = getDefaultPlist()
108 persistent pl;
109 if exist('pl', 'var')==0 || isempty(pl)
110 pl = buildplist();
111 end
112 plout = pl;
113 end
114
115 function pl = buildplist()
116 pl = plist({'objs', 'The inner objects to set.'}, paramValue.EMPTY_DOUBLE);
117 end
118