Skip to content

Commit 3fc3d35

Browse files
committed
setters for source
1 parent 610bd5b commit 3fc3d35

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

nix_mx.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ void mexFunction(int nlhs,
141141
.reg("deleteSource", REMOVER(nix::Source, nix::Source, deleteSource))
142142
.reg("sources", &nix::Source::sources)
143143
.reg("openSource", GETBYSTR(nix::Source, nix::Source, getSource))
144-
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::Source, metadata));
144+
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::Source, metadata))
145+
.reg("set_type", SETTER(const std::string&, nix::Source, type))
146+
.reg("set_definition", SETTER(const std::string&, nix::Source, definition))
147+
.reg("set_none_definition", SETTER(const boost::none_t, nix::Source, definition));
145148

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

tests/TestSource.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
funcs = {};
66
funcs{end+1} = @test_create_source;
77
funcs{end+1} = @test_delete_source;
8+
funcs{end+1} = @test_attrs;
89
funcs{end+1} = @test_fetch_sources;
910
funcs{end+1} = @test_open_source;
1011
funcs{end+1} = @test_open_metadata;
@@ -83,3 +84,24 @@
8384
assert(~getSource.delete_source('I do not exist'));
8485
assert(isempty(getSource.sources));
8586
end
87+
88+
function [] = test_attrs( varargin )
89+
%% Test: Access Attributes
90+
f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
91+
b = f.createBlock('tagtest', 'test nixBlock');
92+
s = b.create_source('sourcetest', 'test nixSource');
93+
94+
assert(~isempty(s.id));
95+
assert(strcmp(s.name, 'sourcetest'));
96+
assert(strcmp(s.type, 'test nixSource'));
97+
98+
s.type = 'nixSource';
99+
assert(strcmp(s.type, 'nixSource'));
100+
101+
assert(isempty(s.definition));
102+
s.definition = 'source definition';
103+
assert(strcmp(s.definition, 'source definition'));
104+
105+
s.definition = '';
106+
assert(isempty(s.definition));
107+
end

0 commit comments

Comments
 (0)