Home > classes > @plist > fromFile.m

fromFile

PURPOSE ^

Construct a ltpda_ob from a file

SYNOPSIS ^

function objs = fromFile(obj, pli)

DESCRIPTION ^

 Construct a ltpda_ob from a file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    fromFile

 DESCRIPTION: Construct a ltpda_ob from a file

 CALL:        obj = obj.fromFile(filename)
              obj = obj.fromFile(pl)

 VERSION:     $Id: fromFile.m,v 1.2 2008/09/08 09:40:46 hewitson Exp $

 HISTORY:     21-08-2008 Diepholz
              Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Construct a ltpda_ob from a file
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % FUNCTION:    fromFile
0005 %
0006 % DESCRIPTION: Construct a ltpda_ob from a file
0007 %
0008 % CALL:        obj = obj.fromFile(filename)
0009 %              obj = obj.fromFile(pl)
0010 %
0011 % VERSION:     $Id: fromFile.m,v 1.2 2008/09/08 09:40:46 hewitson Exp $
0012 %
0013 % HISTORY:     21-08-2008 Diepholz
0014 %              Creation
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   % Which file type are we dealing with?
0022   if ischar(pli)
0023     pli = plist('filename', pli);
0024   end
0025 
0026   % get filename
0027   filename = find(pli, 'filename');
0028 
0029   % Get the correct parameter set
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')             % check the class and the struct match
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

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003