Skip to content

Commit 3dc8eed

Browse files
committed
[c++/m] Add Property delete values function
Adds both delete values functions to the Property entity on both c++ and matlab side and introduces a corresponding test.
1 parent 1741ba7 commit 3dc8eed

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

+nix/Property.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
function c = value_count(obj)
6262
c = nix_mx('Property::valueCount', obj.nix_handle);
6363
end
64+
65+
function [] = values_delete(obj)
66+
nix_mx('Property::deleteValues', obj.nix_handle);
67+
end
6468
end
6569

6670
end

nix_mx.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,11 @@ void mexFunction(int nlhs,
362362
.reg("setNoneUnit", SETTER(const boost::none_t, nix::Property, unit))
363363
.reg("setMapping", SETTER(const std::string&, nix::Property, mapping))
364364
.reg("setNoneMapping", SETTER(const boost::none_t, nix::Property, mapping))
365-
.reg("valueCount", GETTER(nix::ndsize_t, nix::Property, valueCount));
365+
.reg("valueCount", GETTER(nix::ndsize_t, nix::Property, valueCount))
366+
.reg("setNoneValue", SETTER(const boost::none_t, nix::Property, values));
366367
methods->add("Property::values", nixproperty::values);
367368
methods->add("Property::updateValues", nixproperty::updateValues);
369+
methods->add("Property::deleteValues", nixproperty::deleteValues);
368370

369371
classdef<nix::SetDimension>("SetDimension", methods)
370372
.desc(&nixdimensions::describe)

src/nixproperty.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,9 @@ namespace nixproperty {
6464
prop.values(getVals);
6565
}
6666

67+
void deleteValues(const extractor &input, infusor &output) {
68+
nix::Property prop = input.entity<nix::Property>(1);
69+
prop.deleteValues();
70+
}
71+
6772
} // namespace nixproperty

src/nixproperty.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ namespace nixproperty {
1919

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

22+
void deleteValues(const extractor &input, infusor &output);
23+
2224
} // namespace nixproperty
2325

2426
#endif

tests/TestProperty.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
funcs{end+1} = @test_update_values;
1616
funcs{end+1} = @test_values;
1717
funcs{end+1} = @test_value_count;
18+
funcs{end+1} = @test_values_delete;
1819
end
1920

2021
%% Test: Access Attributes
@@ -128,3 +129,19 @@
128129
pid = f.sections{1}.allProperties{1}.id;
129130
assert(f.sections{1}.open_property(pid).value_count() == 1);
130131
end
132+
133+
%% Test: Delete values
134+
function [] = test_values_delete( varargin )
135+
testFile = fullfile(pwd,'tests','testRW.h5');
136+
f = nix.File(testFile, nix.FileMode.Overwrite);
137+
s = f.create_section('testSection', 'nixSection');
138+
139+
p = s.create_property_with_value('property1', {true, false, true});
140+
assert(~isempty(p.values));
141+
p.values_delete();
142+
assert(isempty(p.values));
143+
144+
clear p s f;
145+
f = nix.File(testFile, nix.FileMode.ReadOnly);
146+
assert(isempty(f.sections{1}.allProperties{1}.values));
147+
end

0 commit comments

Comments
 (0)