Skip to content

Commit 4e4e4d4

Browse files
committed
[c++/m] Add Section referringMultiTags(Block)
1 parent 9d9ac38 commit 4e4e4d4

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

+nix/Section.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,8 @@
164164
ret = obj.referring_util(@nix.Tag, 'Tags', varargin{:});
165165
end
166166

167-
function ret = referring_multi_tags(obj)
168-
ret = nix.Utils.fetchObjList('Section::referringMultiTags', ...
169-
obj.nix_handle, @nix.MultiTag);
167+
function ret = referring_multi_tags(obj, varargin)
168+
ret = obj.referring_util(@nix.MultiTag, 'MultiTags', varargin{:});
170169
end
171170

172171
function ret = referring_sources(obj, varargin)

nix_mx.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ void mexFunction(int nlhs,
358358
methods->add("Section::createPropertyWithValue", nixsection::createPropertyWithValue);
359359
methods->add("Section::referringBlockSources", nixsection::referringBlockSources);
360360
methods->add("Section::referringBlockTags", nixsection::referringBlockTags);
361+
methods->add("Section::referringBlockMultiTags", nixsection::referringBlockMultiTags);
361362

362363
classdef<nix::Feature>("Feature", methods)
363364
.desc(&nixfeature::describe)

src/nixsection.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,10 @@ namespace nixsection {
9393
output.set(0, currSec.referringTags(currBlock));
9494
}
9595

96+
void referringBlockMultiTags(const extractor &input, infusor &output) {
97+
nix::Section currSec = input.entity<nix::Section>(1);
98+
nix::Block currBlock = input.entity<nix::Block>(2);
99+
output.set(0, currSec.referringMultiTags(currBlock));
100+
}
101+
96102
} // namespace nixsection

src/nixsection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ namespace nixsection {
2525

2626
void referringBlockTags(const extractor &input, infusor &output);
2727

28+
void referringBlockMultiTags(const extractor &input, infusor &output);
29+
2830
} // namespace nixsection
2931

3032
#endif

tests/TestSection.m

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
funcs{end+1} = @test_referring_tags;
3232
funcs{end+1} = @test_referring_block_tags;
3333
funcs{end+1} = @test_referring_multi_tags;
34+
funcs{end+1} = @test_referring_block_multi_tags;
3435
funcs{end+1} = @test_referring_sources;
3536
funcs{end+1} = @test_referring_block_sources;
3637
funcs{end+1} = @test_referring_blocks;
@@ -407,7 +408,6 @@
407408
assert(strcmp(testTag{1}.name, testName));
408409
end
409410

410-
411411
%% Test: referring multi tags
412412
function [] = test_referring_multi_tags( varargin )
413413
f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
@@ -432,6 +432,43 @@
432432
assert(isempty(s.referring_multi_tags));
433433
end
434434

435+
%% Test: referring block multi tags
436+
function [] = test_referring_block_multi_tags( varargin )
437+
err = 'Provide either empty arguments or a single Block entity';
438+
testName = 'testMultiTag1';
439+
440+
f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
441+
b1 = f.create_block('testBlock1', 'nixBlock');
442+
d = b1.create_data_array('testDataArray1', 'nixDataArray', nix.DataType.Double, [1 2]);
443+
t1 = b1.create_multi_tag(testName, 'nixMultiTag', d);
444+
b2 = f.create_block('testBlock2', 'nixBlock');
445+
d = b2.create_data_array('testDataArray2', 'nixDataArray', nix.DataType.Double, [1 2]);
446+
t2 = b2.create_multi_tag('testMultiTag2', 'nixMultiTag', d);
447+
s = f.create_section('testSection', 'nixSection');
448+
449+
t1.set_metadata(s);
450+
t2.set_metadata(s);
451+
452+
% test multiple arguments fail
453+
try
454+
s.referring_multi_tags('a', 'b');
455+
catch ME
456+
assert(strcmp(ME.message, err));
457+
end
458+
459+
% test non block entity argument fail
460+
try
461+
s.referring_multi_tags(s);
462+
catch ME
463+
assert(strcmp(ME.message, err));
464+
end
465+
466+
% test return only tags from block 1
467+
testTag = s.referring_multi_tags(b1);
468+
assert(size(testTag, 2) == 1);
469+
assert(strcmp(testTag{1}.name, testName));
470+
end
471+
435472
%% Test: referring sources
436473
function [] = test_referring_sources( varargin )
437474
f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);

0 commit comments

Comments
 (0)