Skip to content

Commit d13356a

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

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
@@ -58,5 +58,10 @@
5858
retObj = nix.Utils.fetchObjList('Source::referringDataArrays', ...
5959
obj.nix_handle, @nix.DataArray);
6060
end
61+
62+
function retObj = referring_tags(obj)
63+
retObj = nix.Utils.fetchObjList('Source::referringTags', ...
64+
obj.nix_handle, @nix.Tag);
65+
end
6166
end;
6267
end

nix_mx.cc

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

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

tests/TestSource.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
funcs{end+1} = @test_set_metadata;
2323
funcs{end+1} = @test_open_metadata;
2424
funcs{end+1} = @test_referring_data_arrays;
25+
funcs{end+1} = @test_referring_tags;
2526
end
2627

2728
%% Test: fetch sources
@@ -226,3 +227,22 @@
226227
d2.add_source(s);
227228
assert(size(s.referring_data_arrays, 1) == 2);
228229
end
230+
231+
%% Test: Referring tags
232+
function [] = test_referring_tags( varargin )
233+
fileName = fullfile(pwd, 'tests', 'testRW.h5');
234+
f = nix.File(fileName, nix.FileMode.Overwrite);
235+
b = f.create_block('testBlock', 'nixBlock');
236+
s = b.create_source('testSource', 'nixSource');
237+
238+
assert(isempty(s.referring_tags));
239+
240+
t1 = b.create_tag('testTag1', 'nixTag', [1, 2]);
241+
t1.add_source(s);
242+
assert(~isempty(s.referring_tags));
243+
assert(strcmp(s.referring_tags{1}.name, t1.name));
244+
245+
t2 = b.create_tag('testTag2', 'nixTag', [1, 2]);
246+
t2.add_source(s);
247+
assert(size(s.referring_tags, 1) == 2);
248+
end

0 commit comments

Comments
 (0)