Skip to content

Commit e402402

Browse files
committed
[c++/m] Add Source referringDataArray method
Adds the referringDataArray method to the Source entity on c++ and matlab side and introduces a corresponding test.
1 parent 1d3c030 commit e402402

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

+nix/Source.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,10 @@
5353
retObj = nix.Utils.fetchObj('Source::parentSource', ...
5454
obj.nix_handle, @nix.Source);
5555
end
56+
57+
function retObj = referring_data_arrays(obj)
58+
retObj = nix.Utils.fetchObjList('Source::referringDataArrays', ...
59+
obj.nix_handle, @nix.DataArray);
60+
end
5661
end;
5762
end

nix_mx.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ void mexFunction(int nlhs,
244244
.reg("setDefinition", SETTER(const std::string&, nix::Source, definition))
245245
.reg("setNoneDefinition", SETTER(const boost::none_t, nix::Source, definition))
246246
.reg("parentSource", GETTER(nix::Source, nix::Source, parentSource))
247-
.reg("sourceCount", GETTER(nix::ndsize_t, nix::Source, sourceCount));
247+
.reg("sourceCount", GETTER(nix::ndsize_t, nix::Source, sourceCount))
248+
.reg("referringDataArrays", GETTER(std::vector<nix::DataArray>, nix::Source, referringDataArrays));
248249

249250
classdef<nix::Tag>("Tag", methods)
250251
.desc(&nixtag::describe)

tests/TestSource.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
funcs{end+1} = @test_parent_source;
2222
funcs{end+1} = @test_set_metadata;
2323
funcs{end+1} = @test_open_metadata;
24+
funcs{end+1} = @test_referring_data_arrays;
2425
end
2526

2627
%% Test: fetch sources
@@ -206,3 +207,22 @@
206207
assert(strcmp(s3.parent_source.name, sourceName2));
207208
assert(strcmp(s2.parent_source.name, sourceName1));
208209
end
210+
211+
%% Test: Referring data arrays
212+
function [] = test_referring_data_arrays( varargin )
213+
fileName = fullfile(pwd, 'tests', 'testRW.h5');
214+
f = nix.File(fileName, nix.FileMode.Overwrite);
215+
b = f.create_block('testBlock', 'nixBlock');
216+
s = b.create_source('testSource', 'nixSource');
217+
218+
assert(isempty(s.referring_data_arrays));
219+
220+
d1 = b.create_data_array('testDataArray1', 'nixDataArray', nix.DataType.Double, [1 2]);
221+
d1.add_source(s);
222+
assert(~isempty(s.referring_data_arrays));
223+
assert(strcmp(s.referring_data_arrays{1}.name, d1.name));
224+
225+
d2 = b.create_data_array('testDataArray2', 'nixDataArray', nix.DataType.Double, [1 2]);
226+
d2.add_source(s);
227+
assert(size(s.referring_data_arrays, 1) == 2);
228+
end

0 commit comments

Comments
 (0)