rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
ScalarCreator.m
1 classdef ScalarCreator < DataTree.CreatorDefault
2  % Simple DataTree.ICreator copying the original tree and applying a custom function to
3  % its leafs returning a scalar value.
4  %
5  % This creator is used by the INode.create_scalar_tree() method.
6 
7 
8  properties
9 
10  % function_handle to a custom function applied to all leaf elements
11  %
12  % The function synopsis is: 'ret = funcptr(arg_node)'
13  funcptr;
14  end
15 
16  methods
17  function sc = ScalarCreator(funcptr)
18  % function sc = ScalarCreator(funcptr)
19  % constructor of this creator
20  %
21  % Parameters:
22  % funcptr: function handle to a custom function applied to all leaf elements
23  sc.funcptr = funcptr;
24  end
25 
26  function node = create_leaf_node(this, arg_node, basepath, mu_cube, tslice)
27  % function node = create_leaf_node(this, arg_node, basepath, mu_cube, tslice)
28  % @copybrief DataTree::ICreatorcreate_leaf_node()
29  %
30  % @copydetails DataTree::ICreatorcreate_leaf_node()
31  svalue = this.funcptr(arg_node);
32  node = DataTree.DummyLeafNode(svalue);
33  end
34  end
35 end