Home > classes > @param > eq.m

eq

PURPOSE ^

EQ overloads the == operator for param objects.

SYNOPSIS ^

function result = eq(c1,c2, varargin)

DESCRIPTION ^

 EQ overloads the == operator for param objects.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: EQ overloads the == operator for param 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 param objects
              exc_list - exception list
                         List of properties which are not checked.

 OUTPUTS:     If the two param objects are considered equal, result == 1,
              otherwise, result == 0.

 VERSION:     $Id: eq.m,v 1.5 2007/12/11 17:27:09 ingo Exp $

 HISTORY:     29-08-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function result = eq(c1,c2, varargin)
0002 % EQ overloads the == operator for param objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: EQ overloads the == operator for param 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 param objects
0019 %              exc_list - exception list
0020 %                         List of properties which are not checked.
0021 %
0022 % OUTPUTS:     If the two param objects are considered equal, result == 1,
0023 %              otherwise, result == 0.
0024 %
0025 % VERSION:     $Id: eq.m,v 1.5 2007/12/11 17:27:09 ingo Exp $
0026 %
0027 % HISTORY:     29-08-2007 M Hewitson
0028 %                 Creation
0029 %
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 
0032 VERSION  = '$Id: eq.m,v 1.5 2007/12/11 17:27:09 ingo Exp $';
0033 
0034 % Check if this is a call for parameters
0035 if nargin == 2
0036   if isa(c1, 'param') && 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, ['param/' field]};
0062 
0063   % Is the field equal to value then add the name 'value'
0064   % to the exception list.
0065   if strcmp(field, 'val')
0066     ck_field{end+1} = 'value';
0067     ck_field{end+1} = 'param/value';
0068   end
0069 
0070   %% Check tag
0071   if ~(any(ismember(ck_field, varargin)))
0072 
0073     if isobject(c1.(field))
0074       if ~eq(c1.(field), c2.(field), varargin{:})
0075         result = 0;
0076         disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field));
0077         return
0078       end
0079     else
0080       if ~isequalwithequalnans(c1.(field), c2.(field))
0081         result = 0;
0082         disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field));
0083         return
0084       end
0085     end
0086 
0087   end
0088 end
0089

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003