Home > atmlab > datasets > dsmagic.m

dsmagic

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

dsmagic.m

SOURCE CODE ^

0001 classdef dsmagic < dynamicprops
0002     % imitate a structure that gets automagically updated
0003     methods
0004         function varargout = subsref(~, S)
0005             if ~isequal(S(1).type, '.')
0006                 error(['atmlab:' mfilename ':invalid'], ...
0007                     'Only structure-type access is defined');
0008             end
0009             D = datasets('*');
0010             [varargout{1:nargout}] = subsref(D, S);
0011         end
0012         
0013         function A = subsasgn(self, S, B)
0014             D = datasets('*');
0015             [~] = subsasgn(D, S, B);
0016             A = self;
0017         end
0018         
0019         function disp(~)
0020             disp(datasets('*'));
0021         end
0022         
0023         function display(~)
0024             disp(datasets('*'));
0025         end
0026         
0027         function update_dynamic_props(self)
0028             fields = fieldnames(datasets('*'));
0029             current_properties = properties(self);
0030             new_properties = setdiff(fields, current_properties);
0031             gone_properties = setdiff(current_properties, fields);
0032             for field = vec2row(new_properties)
0033                 addprop(self, field{1});
0034             end
0035             if ~isempty(gone_properties)
0036                 logtext(atmlab('ERR'), ...
0037                     'Warning: due to Gerrits laziness, tab completion on datasets will henceforth contain false politives');
0038             end
0039         end
0040 
0041         function tf = isfield(self, f)
0042             D = datasets('*');
0043             tf = isfield(D, f);
0044         end
0045 
0046     end
0047 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005