Home > classes > @plist > eq.m

eq

PURPOSE ^

EQ overloads the == operator for plist objects.

SYNOPSIS ^

function result = eq(c1,c2, varargin)

DESCRIPTION ^

 EQ overloads the == operator for plist objects.

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

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

 OUTPUTS:     If the two plist objects are considered equal, result == 1,
              otherwise, result == 0.
 
 VERSION:     $Id$

 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 
0003 % EQ overloads the == operator for plist objects.
0004 %
0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0006 %
0007 % DESCRIPTION: EQ overloads the == operator for plist 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 plist objects
0020 %              exc_list - exception list
0021 %                         List of properties which are not checked.
0022 %
0023 % OUTPUTS:     If the two plist 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, ['plist/' field]};
0047   
0048   %% Check tag
0049   if ~(any(ismember(ck_field, varargin)))
0050 
0051     if isobject(c1.(field))
0052 
0053       if length(c1.(field)) ~= length(c2.(field))
0054         result = 0;
0055         return
0056       end
0057 
0058       for jj = 1:length(c1.(field))
0059         if ~eq(c1.(field)(jj), c2.(field)(jj), varargin{:})
0060           result = 0;
0061           disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field));
0062           return
0063         end
0064       end
0065     else
0066       if ~isequalwithequalnans(c1.(field), c2.(field))
0067         result = 0;
0068         disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field));
0069         return
0070       end
0071     end
0072 
0073   end
0074 end
0075 
0076 
0077 % function result = eq(p1,p2, varargin)
0078 %
0079 % % EQ overloads the == operator for plist objects.
0080 % %
0081 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0082 % %
0083 % % DESCRIPTION: EQ overloads the == operator for plist objects.
0084 % %
0085 % %              Each parameter is checked (order must be the same).
0086 % %
0087 % % CALL:        result = eq(p1,p2)
0088 % %
0089 % % INPUTS:      p1,p2 - input plist objects
0090 % %
0091 % % OUTPUTS:     If the two plist objects are considered equal, result == 1,
0092 % %              otherwise, result == 0.
0093 % %
0094 % % VERSION:     $Id: param.m,v 1.7 2007/08/17 11:22:11 ingo Exp $
0095 % %
0096 % % HISTORY:     29-08-2007 M Hewitson
0097 % %                 Creation
0098 % %
0099 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0100 %
0101 % % Assume equality to begin with
0102 % result = 1;
0103 %
0104 % %% check created
0105 % if ~ismember('created', varargin)
0106 %   if ~eq(p1.created, p2.created)
0107 %     result = 0;
0108 %     return
0109 %   end
0110 % end
0111 %
0112 % %% check name
0113 % if ~ismember('name', varargin)
0114 %   if ~strcmp(p1.name, p2.name)
0115 %     result = 0;
0116 %     retrun
0117 %   end
0118 % end
0119 %
0120 % %% check each param
0121 % if ~ismember('params', varargin)
0122 %   if length(p1.params) ~= length(p2.params)
0123 %     result = 0;
0124 %     return
0125 %   end
0126 %
0127 %   for j=1:length(p1.params)
0128 %
0129 %     if ~eq(p1.params(j), p2.params(j), varargin{:})
0130 %       result = 0;
0131 %       return
0132 %     end
0133 %
0134 %   end
0135 % end

Generated on Thu 01-Nov-2007 09:42:34 by m2html © 2003