EQ overloads the == operator for history objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: EQ overloads the == operator for history 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 history objects exc_list - exception list List of properties which are not checked. OUTPUTS: If the two history objects are considered equal, result == 1, otherwise, result == 0. VERSION: $Id$ HISTORY: 29-08-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function result = eq(c1,c2, varargin) 0002 0003 % EQ overloads the == operator for history objects. 0004 % 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % DESCRIPTION: EQ overloads the == operator for history objects. 0008 % 0009 % All fields are checked. 0010 % 0011 % CALL: result = eq(c1,c2) 0012 % result = eq(c1,c2, exc_list) 0013 % result = eq(c1,c2, 'property1', 'property2') 0014 % result = eq(c1,c2, 'class/property', 'class/property') 0015 % 0016 % EXAMPLES: result = eq(c1,c2, 'name', 'created') 0017 % result = eq(c1,c2, 'ao/name') 0018 % 0019 % INPUTS: c1,c2 - input history objects 0020 % exc_list - exception list 0021 % List of properties which are not checked. 0022 % 0023 % OUTPUTS: If the two history objects are considered equal, result == 1, 0024 % otherwise, result == 0. 0025 % 0026 % VERSION: $Id$ 0027 % 0028 % HISTORY: 29-08-2007 M Hewitson 0029 % Creation 0030 % 0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 0033 result = 1; 0034 0035 %% Check class 0036 if ~strcmp(class(c1), class(c2)) 0037 result = 0; 0038 return 0039 end 0040 0041 fields = fieldnames(c1); 0042 0043 for ii = 1:length(fields) 0044 field = fields{ii}; 0045 0046 ck_field = {field, ['history/' field]}; 0047 0048 % Is the field equal to history then add the name 'history' 0049 % to the exception list. 0050 if strcmp(field, 'inhists') 0051 ck_field{end+1} = 'history'; 0052 ck_field{end+1} = 'history/history'; 0053 end 0054 0055 %% Check tag 0056 if ~(any(ismember(ck_field, varargin))) 0057 0058 if isobject(c1.(field)) 0059 0060 if length(c1.(field)) ~= length(c2.(field)) 0061 result = 0; 0062 return 0063 end 0064 0065 for jj = 1:length(c1.(field)) 0066 if ~eq(c1.(field)(jj), c2.(field)(jj), varargin{:}) 0067 result = 0; 0068 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0069 return 0070 end 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(w1,w2, varargin) 0085 % 0086 % % EQ overloads the == operator for history objects. 0087 % % 0088 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0089 % % 0090 % % DESCRIPTION: EQ overloads the == operator for history objects. 0091 % % 0092 % % The 'name', 'version', 'plist', 'inhists', 'invars', 'created', 0093 % % fields are checked. 0094 % % 0095 % % CALL: result = eq(h1,h2) 0096 % % 0097 % % INPUTS: h1,h2 - input specwin objects 0098 % % 0099 % % OUTPUTS: If the two history objects are considered equal, result == 1, 0100 % % otherwise, result == 0. 0101 % % 0102 % % VERSION: $Id: param.m,v 1.7 2007/08/17 11:22:11 ingo Exp $ 0103 % % 0104 % % HISTORY: 29-08-2007 M Hewitson 0105 % % Creation 0106 % % 0107 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0108 % 0109 % % Assume equality to begin with 0110 % result = 1; 0111 % 0112 % %% Check name 0113 % if ~ismember('name', varargin) 0114 % if ~strcmp(w1.name, w2.name) 0115 % result = 0; 0116 % return 0117 % end 0118 % end 0119 % 0120 % %% Check version 0121 % if ~ismember('version', varargin) 0122 % if ~strcmp(w1.version, w2.version) 0123 % result = 0; 0124 % return 0125 % end 0126 % end 0127 % 0128 % %% Check plist 0129 % if ~ismember('plist', varargin) 0130 % if xor(isempty(w1.plist), isempty(w2.plist)) 0131 % result = 0; 0132 % end 0133 % if ~eq(w1.plist, w2.plist, varargin{:}) 0134 % result = 0; 0135 % return; 0136 % end 0137 % end 0138 % 0139 % %% check inhists 0140 % 0141 % if ~ismember('inhists', varargin) 0142 % if length(w1.inhists) ~= length(w2.inhists) 0143 % result = 0; 0144 % return 0145 % end 0146 % 0147 % for j=1:length(w1.inhists) 0148 % if ~eq(w1.inhists(j), w2.inhists(j), varargin{:}) 0149 % result = 0; 0150 % return 0151 % end 0152 % end 0153 % end 0154 % 0155 % %% check invars 0156 % if ~ismember('invars', varargin) 0157 % if length(w1.invars) ~= length(w2.invars) 0158 % result = 0; 0159 % return 0160 % end 0161 % 0162 % for j=1:length(w1.invars) 0163 % if ~strcmp(w1.invars{j}, w2.invars{j}) 0164 % result = 0; 0165 % return 0166 % end 0167 % end 0168 % end 0169 % 0170 % %% check created 0171 % if ~ismember('created', varargin) 0172 % if w1.created ~= w2.created 0173 % result = 0; 0174 % return 0175 % end 0176 % end