diff m-toolbox/classes/@param/fromDom.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/@param/fromDom.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,54 @@
+
+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