Home > classes > @ao > isvalid.m

isvalid

PURPOSE ^

ISVALID tests if the given ao has all the correct fields of the correct type.

SYNOPSIS ^

function varargout = isvalid(varargin)

DESCRIPTION ^

 ISVALID tests if the given ao has all the correct fields of the correct type.

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

 DESCRIPTION: ISVALID tests if the given ao has all the correct fields of the
              correct type.

 CALL:        isvalid(a);

              Returns 1 is a is a valid AO; 0 otherwise.

              The following call returns a parameter list object that
              contains the default parameter values:
              >> pl = isvalid(ao, 'Params')

              The following call returns the cvs version number:
              >> ver = isvalid(ao, 'Version')

              The following call returns the category:
              >> ver = isvalid(ao, 'Category')

 VERSION:     $Id: isvalid.html,v 1.7 2008/03/31 10:27:33 hewitson Exp $

 HISTORY: 25-09-07 M Hewitson
              Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = isvalid(varargin)
0002 % ISVALID tests if the given ao has all the correct fields of the correct type.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: ISVALID tests if the given ao has all the correct fields of the
0007 %              correct type.
0008 %
0009 % CALL:        isvalid(a);
0010 %
0011 %              Returns 1 is a is a valid AO; 0 otherwise.
0012 %
0013 %              The following call returns a parameter list object that
0014 %              contains the default parameter values:
0015 %              >> pl = isvalid(ao, 'Params')
0016 %
0017 %              The following call returns the cvs version number:
0018 %              >> ver = isvalid(ao, 'Version')
0019 %
0020 %              The following call returns the category:
0021 %              >> ver = isvalid(ao, 'Category')
0022 %
0023 % VERSION:     $Id: isvalid.html,v 1.7 2008/03/31 10:27:33 hewitson Exp $
0024 %
0025 % HISTORY: 25-09-07 M Hewitson
0026 %              Creation
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 
0030 VERSION  = '$Id: isvalid.html,v 1.7 2008/03/31 10:27:33 hewitson Exp $';
0031 CATEGORY = 'Helper';
0032 
0033 % 'Params', 'Version', 'Category' Call
0034 
0035 if nargin == 2
0036   if isa(varargin{1}, 'ao') && strcmp(varargin{2}, 'Params')
0037     varargout{1} = plist();
0038     return
0039   elseif isa(varargin{1}, 'ao') && strcmp(varargin{2}, 'Version')
0040     varargout{1} = VERSION;
0041     return
0042   elseif isa(varargin{1}, 'ao') && strcmp(varargin{2}, 'Category')
0043     varargout{1} = CATEGORY;
0044     return
0045   end
0046 end
0047 
0048 as = [];
0049 for j=1:nargin
0050   if isa(varargin{j}, 'ao')
0051     as = [as varargin{j}];
0052   end
0053 end
0054 
0055 res = zeros(size(as));
0056 for j=1:numel(as)
0057   a = as(j);
0058   if ischar(a.name)                     && ...
0059        (isa(a.data, 'cdata')    || ...
0060         isa(a.data, 'fsdata')   || ...
0061         isa(a.data, 'tsdata')   || ...
0062         isa(a.data, 'xydata')   || ...
0063         isa(a.data, 'xyzdata')  || ...
0064         isempty(a.data))                && ...
0065      isa(a.hist, 'history')             && ...
0066      isa(a.provenance, 'provenance')    && ...
0067      ischar(a.description)              && ...
0068      ischar(a.mfile)                    && ...
0069      ischar(a.mfilename)                && ...
0070      ischar(a.mdlfile)                  && ...
0071      ischar(a.mdlfilename)              && ...
0072        (isa(a.plist, 'plist')   || ...
0073         isempty(a.plist))               && ...
0074      ischar(a.version)                  && ...
0075      isa(a.created, 'time')
0076 
0077     res(j) = 1;
0078   else
0079     res(j) = 0;
0080   end
0081 end
0082 
0083 varargout{1} = res;
0084

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003