-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdp_node_io_append.m
executable file
·51 lines (35 loc) · 1.33 KB
/
dp_node_io_append.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
classdef dp_node_io_append < dp_node_io_rename
% Appends output with relabeld or computed fields
properties
do_overwrite_fields = 0;
end
methods
function obj = dp_node_io_append(translation_table, do_overwrite)
obj = obj@dp_node_io_rename(translation_table);
if (nargin > 1)
obj.do_overwrite_fields = do_overwrite;
end
end
function output = i2o(obj, input)
output = i2o@dp_node_io_rename(obj, input);
% do not write over fields, but apppend if they haven't been
% written already
f = fieldnames(input);
for c = 1:numel(f)
if (~isfield(output, f{c})) || (obj.do_overwrite_fields)
output.(f{c}) = input.(f{c});
elseif (~isfield(output, f{c}))
error('field already set, use do_overwrite_fields')
end
end
end
function obj = update(obj, varargin)
obj = update@dp_node_io_rename(obj, varargin{:});
% by now, there should be a previous node set - copy its
% output check
if (~isempty(obj.previous_node))
obj.output_test = obj.previous_node.output_test;
end
end
end
end