Skip to content

Commit 7844a50

Browse files
committed
[c++/m] Refactor Section.properties usage
- In C++ rename 'Section.properties' to 'Section.propertiesMap'. - In C++ add 'Section.properties' function via GETTER template. - In Matlab rename 'Section.properties' call to 'Seciton.propertiesMap'. - In Matlab add 'Section.properties' as dynamic property.
1 parent dbe7399 commit 7844a50

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

+nix/Section.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
% assign relations
3232
nix.Dynamic.add_dyn_relation(obj, 'sections', @nix.Section);
33+
nix.Dynamic.add_dyn_relation(obj, 'properties', @nix.Property);
3334
end;
3435

3536
function section = parent(obj)
@@ -170,7 +171,7 @@
170171
end;
171172

172173
function props = get.allProperties(obj)
173-
props = nix_mx('Section::properties', obj.nix_handle);
174+
props = nix_mx('Section::propertiesMap', obj.nix_handle);
174175
end;
175176

176177
function p_map = get.allPropertiesMap(obj)

nix_mx.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ void mexFunction(int nlhs,
381381
classdef<nix::Section>("Section", methods)
382382
.desc(&nixsection::describe)
383383
.reg("sections", &nix::Section::sections)
384+
.reg("properties", &nix::Section::properties)
384385
.reg("openSection", GETBYSTR(nix::Section, nix::Section, getSection))
385386
.reg("hasProperty", GETBYSTR(bool, nix::Section, hasProperty))
386387
.reg("hasSection", GETBYSTR(bool, nix::Section, hasSection))
@@ -407,7 +408,7 @@ void mexFunction(int nlhs,
407408
.reg("referringMultiTags", GETTER(std::vector<nix::MultiTag>, nix::Section, referringMultiTags))
408409
.reg("referringSources", GETTER(std::vector<nix::Source>, nix::Section, referringSources))
409410
.reg("referringBlocks", GETTER(std::vector<nix::Block>, nix::Section, referringBlocks));
410-
methods->add("Section::properties", nixsection::properties);
411+
methods->add("Section::propertiesMap", nixsection::propertiesMap);
411412
methods->add("Section::createProperty", nixsection::createProperty);
412413
methods->add("Section::createPropertyWithValue", nixsection::createPropertyWithValue);
413414
methods->add("Section::referringBlockSources", nixsection::referringBlockSources);

src/nixsection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace nixsection {
3434
return sb.array();
3535
}
3636

37-
void properties(const extractor &input, infusor &output) {
37+
void propertiesMap(const extractor &input, infusor &output) {
3838
nix::Section section = input.entity<nix::Section>(1);
3939
std::vector<nix::Property> properties = section.properties();
4040

src/nixsection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace nixsection {
1515

1616
mxArray *describe(const nix::Section &section);
1717

18-
void properties(const extractor &input, infusor &output);
18+
void propertiesMap(const extractor &input, infusor &output);
1919

2020
void createProperty(const extractor &input, infusor &output);
2121

tests/TestSection.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,21 @@
183183
%% Test: Properties
184184
f = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly);
185185
trial = f.sections{2}.sections{2}.sections{1};
186-
186+
187187
assert(~isempty(trial.allProperties));
188+
assert(~isempty(trial.properties));
188189

189190
p1 = trial.allProperties{1};
190191
assert(strcmp(p1.name, 'ExperimentalCondition'));
191-
192+
193+
p1 = trial.properties{1};
194+
assert(strcmp(p1.name, 'ExperimentalCondition'));
195+
192196
disp(f.sections{3}.allProperties);
197+
disp(f.sections{3}.properties);
193198

194199
assert(isempty(f.sections{3}.allProperties));
200+
assert(isempty(f.sections{3}.properties));
195201
end
196202

197203
%% Test: Create property by data type

0 commit comments

Comments
 (0)