Mercurial > hg > ltpda
view m-toolbox/classes/@param/fromDom.m @ 44:409a22968d5e default
Add unit tests
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Tue, 06 Dec 2011 18:42:11 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
function obj = fromDom(obj, node, inhists) % Get shape objShape = utils.xml.getShape(node); type = utils.xml.mchar(node.getAttribute('type')); if any(objShape==0) && isempty(type) obj = param.initObjectWithSize(objShape(1), objShape(2)); else %%%%%%%%%% Call super-class fromDom@ltpda_nuo(obj, node, inhists); %%%%%%%%%% Get properties from the node attributes % Get key obj.key = utils.xml.mchar(node.getAttribute('key')); % Get desc obj.desc = utils.xml.mchar(node.getAttribute('desc')); % Get value if node.hasAttribute('type') % till LTPDA version 2.3.1 obj.setVal(utils.xml.getFromType(node, inhists)); else %%%%%%%%%% Get properties from the child nodes % since LTPDA version 2.3.2 % Get val childNode = utils.xml.getChildByName(node, 'val'); if ~isempty(childNode) obj.setVal(utils.xml.getFromType(childNode, inhists)); end % Get properties childNode = utils.xml.getChildByName(node, 'properties'); if ~isempty(childNode) prop = utils.xml.getStruct(childNode, inhists); fn = fieldnames(prop); for pp = 1:numel(fn) obj.setProperty(fn{pp}, prop.(fn{pp})); end end end end end