0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 function objs = fromFile(obj, pli)
0018
0019 VERSION = '$Id: fromFile.m,v 1.2 2008/09/08 09:40:46 hewitson Exp $';
0020
0021
0022 if ischar(pli)
0023 pli = plist('filename', pli);
0024 end
0025
0026
0027 filename = find(pli, 'filename');
0028
0029
0030 [path, name, ext] = fileparts(filename);
0031
0032 switch ext
0033 case '.mat'
0034 ii = obj.getInfo(class(obj), 'From MAT File');
0035 ii.setMversion([VERSION '-->' ii.mversion]);
0036 objs = load(filename);
0037
0038 if isstruct(objs) && isfield(objs, 'objs')
0039 scl = utils.helper.classFromStruct(objs.objs);
0040 if isempty(scl)
0041 error('### The structure does not match any LTPDA object.');
0042 end
0043 if ~strcmp('plist', scl)
0044 error('### The structure does not match the chosen LTPDA object constructor. It seems to be a [%s] object.', scl)
0045 end
0046 objs = plist(objs.objs);
0047 elseif ismember('a', fieldnames(objs))
0048 objs = objs.a;
0049 elseif ismember('objs', fieldnames(objs))
0050 objs = objs.objs;
0051 else
0052 error('### MAT file contents can not be interpreted.');
0053 end
0054
0055 case '.xml'
0056 root_node = xmlread(filename);
0057 objs = utils.helper.xmlread(root_node, class(obj));
0058
0059 otherwise
0060 error('### Unknown file type [%s].', ext(2:end));
0061 end
0062
0063 end
0064