Mercurial > hg > ltpda
comparison m-toolbox/classes/@ltpda_uoh/creator.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 % CREATOR Extract the creator(s) from the history. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Extract the creator(s) from the history. | |
5 % | |
6 % CALL: string = creator(obj) | |
7 % cell = creator(obj, 'ALL') | |
8 % cell = creator(obj, pl) | |
9 % | |
10 % OPTIONS: 'ALL': Return all persons which modified the object | |
11 % | |
12 % <a href="matlab:utils.helper.displayMethodInfo('ltpda_uoh', 'creator')">Parameters Description</a> | |
13 % | |
14 % VERSION: $Id: creator.m,v 1.10 2011/04/08 08:56:30 hewitson Exp $ | |
15 % | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 function varargout = creator(varargin) | |
19 | |
20 %%% Check if this is a call for parameters | |
21 if utils.helper.isinfocall(varargin{:}) | |
22 varargout{1} = getInfo(varargin{3}); | |
23 return | |
24 end | |
25 | |
26 import utils.const.* | |
27 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
28 | |
29 %%% Check number of inputs | |
30 if nargin > 2 | |
31 error('### Unknown number of inputs'); | |
32 end | |
33 | |
34 %%% Get the input object | |
35 if ~isa(varargin{1}, 'ltpda_uo') | |
36 error('### The first input must be a user object.') | |
37 else | |
38 objs = varargin{1}; | |
39 end | |
40 | |
41 %%% Get the option from the second input | |
42 option = ''; | |
43 if nargin == 2 | |
44 if isa(varargin{2}, 'plist') | |
45 option = find(varargin{2}, 'option'); | |
46 else | |
47 option = varargin{2}; | |
48 end | |
49 end | |
50 | |
51 %%% Check that the option works only for one object. | |
52 if numel(objs) > 1 && strcmpi(option, 'all') | |
53 error('### The option ''all'' works only for one object'); | |
54 end | |
55 | |
56 out = {}; | |
57 if isempty(option) | |
58 for ii = 1:numel(objs) | |
59 if ~isempty(objs(ii).hist) | |
60 out = [out objs(ii).hist.creator.creator]; | |
61 end | |
62 end | |
63 elseif strcmpi(option, 'all') | |
64 out = getCreator({}, objs.hist); | |
65 out = unique(out); | |
66 else | |
67 error('### Unknown option [%s]', option); | |
68 end | |
69 | |
70 %%% Set output | |
71 if numel(out) <= 1 | |
72 %%% if the output contains only one creator then return a string and | |
73 %%% not a cell array. | |
74 out = char(out); | |
75 end | |
76 varargout{1} = out; | |
77 end | |
78 | |
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
80 % Local Functions % | |
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
82 | |
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
84 % | |
85 % FUNCTION: getCreator | |
86 % | |
87 % DESCRIPTION: Get all creators from the history | |
88 % | |
89 % HISTORY: 10-12-2008 Diepholz | |
90 % Creation. | |
91 % | |
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
93 function creators = getCreator(creators, h) | |
94 for ii = 1:numel(h) | |
95 creators = getCreator([creators, h(ii).creator.creator], h(ii).inhists); | |
96 end | |
97 end | |
98 | |
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
100 % | |
101 % FUNCTION: getInfo | |
102 % | |
103 % DESCRIPTION: Get Info Object | |
104 % | |
105 % HISTORY: 10-12-2008 Diepholz | |
106 % Creation. | |
107 % | |
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
109 function ii = getInfo(varargin) | |
110 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
111 sets = {}; | |
112 pl = []; | |
113 else | |
114 sets = {'Default'}; | |
115 pl = getDefaultPlist; | |
116 end | |
117 % Build info object | |
118 ii = minfo(mfilename, 'ltpda_uoh', 'ltpda', utils.const.categories.helper, '$Id: creator.m,v 1.10 2011/04/08 08:56:30 hewitson Exp $', sets, pl); | |
119 ii.setModifier(false); | |
120 end | |
121 | |
122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
123 % | |
124 % FUNCTION: getDefaultPlist | |
125 % | |
126 % DESCRIPTION: Get Default Plist | |
127 % | |
128 % HISTORY: 10-12-2008 Diepholz | |
129 % Creation. | |
130 % | |
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
132 function plout = getDefaultPlist() | |
133 persistent pl; | |
134 if exist('pl', 'var')==0 || isempty(pl) | |
135 pl = buildplist(); | |
136 end | |
137 plout = pl; | |
138 end | |
139 | |
140 function pl = buildplist() | |
141 pl = plist('option', ''); | |
142 end | |
143 |