rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
DefaultNode.m
1 classdef DefaultNode < DataTree.INode
2  % Default implementation for a DataTree.INode
3  %
4  % This class implements the methods get(), get_index(), set() and
5  % length().
6 
7  properties
8  % cell array of DataTree.INode elements, holding the childrens of this
9  % DataTree.INode.
10  values = [];
11  end
12 
13  methods
14  function data = get(this, index)
15  % function data = get(this, index)
16  % @copybrief DataTree.INode.get()
17  %
18  % @copydetails DataTree.INode.get()
19  if length(index) > 1
20  data = get(this.values{index(1)}, index(2:end));
21  elseif length(index) == 1
22  data = this.values{index};
23  else
24  data = [];
25  end
26  end
27 
28  function path = get_index(this, id, mu, nt)
29  % function path = get_index(this, id, mu, nt)
30  % @copybrief DataTree.INode.get_index()
31  %
32  % @copydetails DataTree.INode.get_index()
33  path = get_index(this, id, mu, nt);
34  if ~isempty(path)
35  path = [path, get_path_index(this.values{path}, id, mu, nt)];
36  end
37  end
38 
39  function children = length(this)
40  % function children = length(this)
41  % @copybrief DataTree.INode.length()
42  %
43  % @copydetails DataTree.INode.length()
44  children = length(this.values);
45  end
46 
47  function this = set(this, index, value)
48  % function this = set(this, index, value)
49  % @copybrief DataTreeINodeset()
50  %
51  % @copydetails DataTreeINodeset()
52  if length(index) > 1
53  set(this.values{index(1)}, index(2:end), value);
54  elseif length(index) == 1
55  this.values{index} = value;
56  end
57  end
58  end
59 end
Interface for a node in a DataTree.
Definition: INode.m:18
virtual function index = get_index(id, mu, nt)
Obtains the leaf index vector that best fits the child description given by the three arguments...
virtual function INode data = get(index)
Access to a child of the current node.
virtual function children = length()
Returns the number of children of the node.