rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
DummyMerger.m
1 classdef DummyMerger < DataTree.CreatorDefault
2  % a test implementation of an DataTree.ICreator that actually merges two
3  % trees together and creates new leaf elements out of the leafs of the two
4  % base trees.
5 
6  properties
7  % restriction to special IDs of the trees.
8  idsearch = {'id1','id2'};
9  end
10 
11  properties(Transient)
12  % transient boolean specifying whether we are in the first (left) tree.
13  in_left_tree = true;
14 
15  % a handle of type DataTreeINode holding the right tree.
16  right_tree = [];
17 
18  % last travelled node of type DataTreeLeafNode in the left tree.
19  leftnode = [];
20  end
21 
22  methods
23 
24  function dmtc = DummyMerger(idsearch)
25  % function dmtc = DummyMerger(idsearch)
26  % constructor of this dummy test example class merging two trees.
27  %
28  % Paramters:
29  % idsearch: a cell array of IDs to restrict the created trees to these
30  % IDs.
31  if nargin == 1
32  dmtc.idsearch = idsearch;
33  end
34  end
35 
36  function tree = merge(this, left_tree, right_tree)
37  % function tree = merge(this, left_tree, right_tree)
38  % main entry function. This merges a left and a right tree and returns
39  % the merged one.
40  %
41  % Parameters:
42  % left_tree: left tree of type DataTree.INode
43  % right_tree: right tree of type DataTree.INode
44  %
45  % Return values:
46  % tree: merged tree of type DataTree.INode
47  this.in_left_tree = true;
48  this.right_tree = right_tree;
49  tree = create_tree(left_tree, this, [], [], [], []);
50  end
51 
52  function node = create_leaf_node(this, arg_node, basepath, mu_cube, tslice)
53  % function node = create_leaf_node(this, arg_node, basepath, mu_cube, tslice)
54  % merges the leaf nodes
55  %
56  % This method expects leafs storing strings and creates new strings with
57  % content '[left_string, '''' + '''', right_string]' out of it.
58  %
59  % @copydetails DataTreeICreatorcreate_leaf_node()
60  if this.in_left_tree
61  this.leftnode = arg_node;
62  this.in_left_tree = false;
63  node = create_tree(this.right_tree,...
64  this, ...
65  this.idsearch, mu_cube, tslice,...
66  []);
67  this.in_left_tree = true;
68 
69  else
70  newval = [num2str(this.leftnode.value), '+', num2str(arg_node.value)];
71  node = DataTree.DummyLeafNode(newval);
72  end
73  end
74  end
75 end
a test implementation of an DataTree.ICreator that actually merges two trees together and creates ne...
Definition: DummyMerger.m:18
Dummy implementation for a DataTree.ILeafNode that stores a single data.
Definition: DummyLeafNode.m:18
interface for a class used to create a new (sub-)tree from an old one with the DataTree.INode.creat...
Definition: ICreator.m:18
Interface for a node in a DataTree.
Definition: INode.m:18
Definition: leaf.m:17
default implementation of the DataTree.ICreator interface