


EQ overloads the == operator for provenance objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: EQ overloads the == operator for provenance objects.
All fields are checked.
CALL: result = eq(c1,c2)
result = eq(c1,c2, exc_list)
result = eq(c1,c2, 'property1', 'property2')
result = eq(c1,c2, 'class/property', 'class/property')
EXAMPLES: result = eq(c1,c2, 'name', 'created')
result = eq(c1,c2, 'ao/name')
INPUTS: c1,c2 - input provenance objects
exc_list - exception list
List of properties which are not checked.
OUTPUTS: If the two provenance objects are considered equal, result == 1,
otherwise, result == 0.
VERSION: $Id: eq.m,v 1.4 2008/01/07 10:21:53 ingo Exp $
HISTORY: 29-08-2007 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0001 function result = eq(c1,c2, varargin) 0002 % EQ overloads the == operator for provenance objects. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: EQ overloads the == operator for provenance objects. 0007 % 0008 % All fields are checked. 0009 % 0010 % CALL: result = eq(c1,c2) 0011 % result = eq(c1,c2, exc_list) 0012 % result = eq(c1,c2, 'property1', 'property2') 0013 % result = eq(c1,c2, 'class/property', 'class/property') 0014 % 0015 % EXAMPLES: result = eq(c1,c2, 'name', 'created') 0016 % result = eq(c1,c2, 'ao/name') 0017 % 0018 % INPUTS: c1,c2 - input provenance objects 0019 % exc_list - exception list 0020 % List of properties which are not checked. 0021 % 0022 % OUTPUTS: If the two provenance objects are considered equal, result == 1, 0023 % otherwise, result == 0. 0024 % 0025 % VERSION: $Id: eq.m,v 1.4 2008/01/07 10:21:53 ingo Exp $ 0026 % 0027 % HISTORY: 29-08-2007 M Hewitson 0028 % Creation 0029 % 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 0032 VERSION = '$Id: eq.m,v 1.4 2008/01/07 10:21:53 ingo Exp $'; 0033 0034 % Check if this is a call for parameters 0035 if nargin == 2 0036 if isa(c1, 'provenance') && ischar(c2) 0037 in = char(c2); 0038 if strcmp(in, 'Params') 0039 result = plist; 0040 return 0041 elseif strcmp(in, 'Version') 0042 result = VERSION; 0043 return 0044 end 0045 end 0046 end 0047 0048 result = 1; 0049 0050 %% Check class 0051 if ~strcmp(class(c1), class(c2)) 0052 result = 0; 0053 return 0054 end 0055 0056 fields = fieldnames(c1); 0057 0058 for ii = 1:length(fields) 0059 field = fields{ii}; 0060 0061 ck_field = {field, ['provenance/' field]}; 0062 0063 %% Check tag 0064 if ~(any(ismember(ck_field, varargin))) 0065 0066 if isobject(c1.(field)) 0067 if ~eq(c1.(field), c2.(field), varargin{:}) 0068 result = 0; 0069 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0070 return 0071 end 0072 else 0073 if ~isequalwithequalnans(c1.(field), c2.(field)) 0074 result = 0; 0075 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0076 return 0077 end 0078 end 0079 0080 end 0081 end 0082 0083 0084 % function result = eq(p1,p2, varargin) 0085 % 0086 % % EQ overloads the == operator for provenance objects. 0087 % % 0088 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0089 % % 0090 % % DESCRIPTION: EQ overloads the == operator for provenance objects. 0091 % % 0092 % % All fields are checked. 0093 % % 0094 % % CALL: result = eq(w1,w2) 0095 % % 0096 % % INPUTS: w1,w2 - input specwin objects 0097 % % 0098 % % OUTPUTS: If the two specwin objects are considered equal, result == 1, 0099 % % otherwise, result == 0. 0100 % % 0101 % % VERSION: $Id: eq.m,v 1.4 2008/01/07 10:21:53 ingo Exp $ 0102 % % 0103 % % HISTORY: 29-08-2007 M Hewitson 0104 % % Creation 0105 % % 0106 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0107 % 0108 % result = 1; 0109 % 0110 % % s1 = struct(p1); 0111 % % s2 = struct(p2); 0112 % 0113 % fn1 = fieldnames(p1); 0114 % 0115 % for j=1:length(fn1) 0116 % field = fn1{j}; 0117 % if ~ismember(field, varargin) 0118 % try 0119 % if p1.(field) ~= p2.(field) 0120 % result = 0; 0121 % return; 0122 % end 0123 % catch 0124 % result = 0; 0125 % return 0126 % end 0127 % end 0128 % end 0129 % 0130 % % result = isequal(s1, struct(p2)); 0131 %