comparison m-toolbox/classes/@ao/md5.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 % MD5 computes an MD5 checksum from an analysis objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: MD5 computes an MD5 checksum from an analysis objects.
5 %
6 % CALL: h = md5(a)
7 %
8 % INPUTS: a - input analysis object
9 %
10 % OUTPUTS: h - md5 hash
11 %
12 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'md5')">Parameters Description</a>
13 %
14 % VERSION: $Id: md5.m,v 1.22 2011/04/08 08:56:14 hewitson Exp $
15 %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
18 function varargout = md5(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 % Collect input variable names
30 in_names = cell(size(varargin));
31 for ii = 1:nargin,in_names{ii} = inputname(ii);end
32
33 % Collect all AOs and plists
34 as = utils.helper.collect_objects(varargin(:), 'ao', in_names);
35
36 h = {};
37 for ii = 1:numel(as)
38
39 %%%%%%%%%%% Convert object to XML
40 % make pointer to xml document
41 xml = com.mathworks.xml.XMLUtils.createDocument('ltpda_object');
42 % extract parent node
43 parent = xml.getDocumentElement;
44 % write obj into xml
45 utils.xml.xmlwrite(as(ii), xml, parent, ''); % Save the XML document.
46
47 h = [h cellstr(utils.prog.hash(xmlwrite(xml), 'MD5'))];
48
49 end
50
51 % Set outputs
52 h = reshape(h, size(as));
53 if numel(h) == 1
54 varargout{1} = cell2mat(h);
55 else
56 varargout{1} = h;
57 end
58 end
59
60 %--------------------------------------------------------------------------
61 % Get Info Object
62 %--------------------------------------------------------------------------
63 function ii = getInfo(varargin)
64 if nargin == 1 && strcmpi(varargin{1}, 'None')
65 sets = {};
66 pl = [];
67 else
68 sets = {'Default'};
69 pl = getDefaultPlist;
70 end
71 % Build info object
72 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.internal, '$Id: md5.m,v 1.22 2011/04/08 08:56:14 hewitson Exp $', sets, pl);
73 ii.setModifier(false);
74 end
75
76 %--------------------------------------------------------------------------
77 % Get Default Plist
78 %--------------------------------------------------------------------------
79 function plout = getDefaultPlist()
80 persistent pl;
81 if exist('pl', 'var')==0 || isempty(pl)
82 pl = buildplist();
83 end
84 plout = pl;
85 end
86
87 function pl = buildplist()
88 pl = plist.EMPTY_PLIST;
89 end
90