We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6e57f03 commit acda83dCopy full SHA for acda83d
+nix/Section.m
@@ -34,15 +34,32 @@
34
section = nix.Section(handle);
35
end;
36
37
-
38
- function section = link(obj)
39
- handle = nix_mx('Section::link', obj.nix_handle);
+
+ % ----------------
+ % Link methods
40
41
42
+ function [] = set_link(obj, val)
43
+ if (isempty(val))
44
+ nix_mx('Section::set_none_link', obj.nix_handle);
45
+ else
46
+ if(strcmp(class(val), 'nix.Section'))
47
+ addID = val.id;
48
49
+ addID = val;
50
+ end;
51
+ nix_mx('Section::set_link', obj.nix_handle, addID);
52
53
54
55
+ function section = openLink(obj)
56
+ handle = nix_mx('Section::openLink', obj.nix_handle);
57
section = {};
58
if handle ~= 0
59
60
61
62
63
% ----------------
64
% Section methods
65
nix_mx.cc
@@ -212,7 +212,9 @@ void mexFunction(int nlhs,
212
.reg("openSection", GETBYSTR(nix::Section, nix::Section, getSection))
213
.reg("hasProperty", GETBYSTR(bool, nix::Section, hasProperty))
214
.reg("hasSection", GETBYSTR(bool, nix::Section, hasSection))
215
- .reg("link", GETCONTENT(nix::Section, nix::Section, link))
+ .reg("openLink", GETCONTENT(nix::Section, nix::Section, link))
216
+ .reg("set_link", SETTER(const std::string&, nix::Section, link))
217
+ .reg("set_none_link", SETTER(const boost::none_t, nix::Section, link))
218
.reg("parent", GETCONTENT(nix::Section, nix::Section, parent))
219
.reg("set_type", SETTER(const std::string&, nix::Section, type))
220
.reg("set_definition", SETTER(const std::string&, nix::Section, definition))
tests/TestSection.m
@@ -11,6 +11,7 @@
11
funcs{end+1} = @test_has_section;
12
funcs{end+1} = @test_attrs;
13
funcs{end+1} = @test_properties;
14
+ funcs{end+1} = @test_link;
15
end
16
17
%% Test: Create Section
@@ -133,3 +134,20 @@
133
134
135
assert(isempty(f.sections{3}.allProperties));
136
137
138
+%%Test: set, open and remove section link
139
+function [] = test_link( varargin )
140
+ f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
141
+ mainSec = f.createSection('mainSection', 'nixSection');
142
+ tmp = f.createSection('linkSection1', 'nixSection');
143
+ tmp = f.createSection('linkSection2', 'nixSection');
144
145
+ assert(isempty(mainSec.openLink));
146
+ mainSec.set_link(f.sections{3}.id);
147
+ assert(strcmp(mainSec.openLink.name, 'linkSection2'));
148
+ mainSec.set_link(f.sections{2});
149
+ assert(strcmp(mainSec.openLink.name, 'linkSection1'));
150
151
+ mainSec.set_link('');
152
153
+end
0 commit comments