Mercurial > hg > ltpda
diff m-toolbox/classes/+utils/@helper/class2plist.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/+utils/@helper/class2plist.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,38 @@ +% CLASS2PLIST create a plist from the class properties. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: CLASS2PLIST create a plist from the class properties. +% +% CALL: pl = class2plist('class_name'); +% pl = class2plist(obj); +% +% VERSION: $Id: class2plist.m,v 1.2 2008/08/05 16:27:28 ingo Exp $ +% +% HISTORY: 15-04-2008 M Hewitson +% Creation +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function pl = class2plist(varargin) + + props = properties(varargin{1}); + + if isobject(varargin{1}) + obj = varargin{1}; + elseif ischar(varargin{1}) + obj = feval(varargin{1}); + else + error('### Unknown input.'); + end + + pl = plist(); + + % Loop over properties + for jj=1:length(props) + % get property + p = props{jj}; + pl.append(p, obj.(p)); + end + +end +