diff m-toolbox/classes/@smodel/generateConstructorPlist.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@smodel/generateConstructorPlist.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,137 @@
+% GENERATECONSTRUCTORPLIST generates a PLIST from the properties which can rebuild the object.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: GENERATECONSTRUCTORPLIST generates a PLIST from the
+%              properties which can rebuild the object.
+%
+% CALL:        pl = obj.generateConstructorPlist();
+%
+% <a href="matlab:utils.helper.displayMethodInfo('smodel', 'generateConstructorPlist')">Parameters Description</a>
+%
+% VERSION:     $Id: generateConstructorPlist.m,v 1.5 2011/04/08 08:56:27 hewitson Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function pl = generateConstructorPlist(varargin)
+  
+  % Check if this is a call for parameters
+  if utils.helper.isinfocall(varargin{:})
+    pl = getInfo(varargin{3});
+    return
+  end
+  
+  obj = varargin{1};
+  pl = plist();
+  
+  % Add procinfo
+  appendProperty(pl, obj, 'procinfo');
+  
+  % Add plotinfo
+  appendProperty(pl, obj, 'plotinfo');
+  
+  % Add name
+  appendProperty(pl, obj, 'name', false);
+  
+  % Add description
+  appendProperty(pl, obj, 'description');
+  
+  % Add expression
+  pl.append('expression', obj.expr);
+  
+  % Add params
+  appendProperty(pl, obj, 'params');
+  
+  % Add values
+  appendProperty(pl, obj, 'values');
+  
+  % Add trans
+  appendProperty(pl, obj, 'trans');
+  
+  % Add xvar
+  appendProperty(pl, obj, 'xvar');
+  
+  % Add xvals
+  appendProperty(pl, obj, 'xvals');
+  
+  % Add xunits
+  appendProperty(pl, obj, 'xunits');
+  
+  % Add yunits
+  appendProperty(pl, obj, 'yunits');
+  
+  
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                               Local Functions                               %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% FUNCTION:    appendProperty
+%
+% CALL:        appendProperty(pl, obj, propName)
+%              appendProperty(pl, obj, propName, isemptyCheck)
+%
+% DESCRIPTION: Get Info Object
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function appendProperty(pl, obj, propName, isemptyCheck)
+  
+  if nargin <= 3
+    isemptyCheck = true;
+  end
+  
+  if isemptyCheck
+    if ~isempty(obj.(propName))
+      pl.append(propName, obj.(propName));
+    else
+      % Don't append the property to the PLIST
+    end
+  else
+    pl.append(propName, obj.(propName));
+  end
+  
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% FUNCTION:    getInfo
+%
+% DESCRIPTION: Get Info Object
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function ii = getInfo(varargin)
+  if nargin == 1 && strcmpi(varargin{1}, 'None')
+    sets = {};
+    pl   = [];
+  else
+    sets = {'Default'};
+    pl   = getDefaultPlist;
+  end
+  % Build info object
+  ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.internal, '$Id: generateConstructorPlist.m,v 1.5 2011/04/08 08:56:27 hewitson Exp $', sets, pl);
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% FUNCTION:    getDefaultPlist
+%
+% DESCRIPTION: Get Default Plist
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function plout = getDefaultPlist()
+  persistent pl;  
+  if exist('pl', 'var')==0 || isempty(pl)
+    pl = buildplist();
+  end
+  plout = pl;  
+end
+
+function pl = buildplist()
+  pl = plist.EMPTY_PLIST;
+end
+