Skip to content

Commit ad54241

Browse files
committed
Merge pull request #100 from mpsonntag/completify
Completely bindings LGTM
2 parents 9bbcc56 + 5479080 commit ad54241

17 files changed

+421
-73
lines changed

+nix/Block.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
da.write_all(data);
7171
end
7272

73+
function hasDA = has_data_array(obj, id_or_name)
74+
hasDA = nix_mx('Block::hasDataArray', obj.nix_handle, id_or_name);
75+
end;
76+
7377
function delCheck = delete_data_array(obj, del)
7478
[delCheck, obj.dataArraysCache] = nix.Utils.delete_entity(obj, ...
7579
del, 'nix.DataArray', 'Block::deleteDataArray', obj.dataArraysCache);
@@ -84,6 +88,10 @@
8488
obj.sourcesCache.lastUpdate = 0;
8589
end;
8690

91+
function hasSource = has_source(obj, id_or_name)
92+
hasSource = nix_mx('Block::hasSource', obj.nix_handle, id_or_name);
93+
end;
94+
8795
function delCheck = delete_source(obj, del)
8896
[delCheck, obj.sourcesCache] = nix.Utils.delete_entity(obj, ...
8997
del, 'nix.Source', 'Block::deleteSource', obj.sourcesCache);

+nix/Feature.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,23 @@
2121
end;
2222

2323
function linkType = get.linkType(obj)
24-
linkType = obj.info.linkType;
24+
linkType = nix_mx('Feature::getLinkType', obj.nix_handle);
25+
end;
26+
27+
function [] = set.linkType(obj, linkType)
28+
nix_mx('Feature::setLinkType', obj.nix_handle, linkType);
2529
end;
2630

2731
function dataArray = open_data(obj)
2832
dataArray = nix.DataArray(nix_mx('Feature::openData', obj.nix_handle));
2933
end;
34+
35+
function [] = set_data(obj, setData)
36+
if(strcmp(class(setData), 'nix.DataArray'))
37+
setData = setData.id;
38+
end;
39+
nix_mx('Feature::setData', obj.nix_handle, setData);
40+
end;
3041
end;
3142

32-
end
43+
end

+nix/File.m

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@
2424
% ----------------
2525
% Block methods
2626
% ----------------
27-
28-
function retObj = openBlock(obj, id_or_name)
29-
retObj = nix.Utils.open_entity(obj, ...
30-
'File::openBlock', id_or_name, @nix.Block);
31-
end
32-
27+
3328
function newBlock = createBlock(obj, name, type)
3429
newBlock = nix.Block(nix_mx('File::createBlock', obj.nix_handle, name, type));
3530
obj.blocksCache.lastUpdate = 0;
3631
end;
3732

33+
function hasBlock = hasBlock(obj, id_or_name)
34+
hasBlock = nix_mx('File::hasBlock', obj.nix_handle, id_or_name);
35+
end;
36+
37+
function retObj = openBlock(obj, id_or_name)
38+
retObj = nix.Utils.open_entity(obj, ...
39+
'File::openBlock', id_or_name, @nix.Block);
40+
end
41+
3842
function delCheck = deleteBlock(obj, del)
3943
[delCheck, obj.blocksCache] = nix.Utils.delete_entity(obj, ...
4044
del, 'nix.Block', 'File::deleteBlock', obj.blocksCache);
@@ -43,17 +47,21 @@
4347
% ----------------
4448
% Section methods
4549
% ----------------
46-
47-
function retObj = openSection(obj, id_or_name)
48-
retObj = nix.Utils.open_entity(obj, ...
49-
'File::openSection', id_or_name, @nix.Section);
50-
end
5150

5251
function newSec = createSection(obj, name, type)
5352
newSec = nix.Section(nix_mx('File::createSection', obj.nix_handle, name, type));
5453
obj.sectionsCache.lastUpdate = 0;
5554
end;
5655

56+
function hasSec = hasSection(obj, id_or_name)
57+
hasSec = nix_mx('File::hasSection', obj.nix_handle, id_or_name);
58+
end;
59+
60+
function retObj = openSection(obj, id_or_name)
61+
retObj = nix.Utils.open_entity(obj, ...
62+
'File::openSection', id_or_name, @nix.Section);
63+
end
64+
5765
function delCheck = deleteSection(obj, del)
5866
delCheck = nix.Utils.delete_entity(obj, del, 'nix.Section', 'File::deleteSection');
5967
obj.sectionsCache.lastUpdate = 0;

+nix/MultiTag.m

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
add_this, 'nix.DataArray', 'MultiTag::addReference', obj.referencesCache);
3030
end;
3131

32+
function hasRef = has_reference(obj, id_or_name)
33+
hasRef = nix_mx('MultiTag::hasReference', obj.nix_handle, id_or_name);
34+
end;
35+
3236
function delCheck = remove_reference(obj, del)
3337
[delCheck, obj.referencesCache] = nix.Utils.delete_entity(obj, ...
3438
del, 'nix.DataArray', 'MultiTag::removeReference', obj.referencesCache);
@@ -65,6 +69,10 @@
6569
obj.featuresCache.lastUpdate = 0;
6670
end;
6771

72+
function hasFeature = has_feature(obj, id_or_name)
73+
hasFeature = nix_mx('MultiTag::hasFeature', obj.nix_handle, id_or_name);
74+
end;
75+
6876
function delCheck = remove_feature(obj, del)
6977
[delCheck, obj.featuresCache] = nix.Utils.delete_entity(obj, ...
7078
del, 'nix.Feature', 'MultiTag::deleteFeature', obj.featuresCache);
@@ -124,14 +132,18 @@
124132
end;
125133
end;
126134

127-
function [] = add_extents(obj, add_this)
128-
if(strcmp(class(add_this), 'nix.DataArray'))
129-
addID = add_this.id;
135+
function [] = set_extents(obj, add_this)
136+
if(isempty(add_this))
137+
nix_mx('MultiTag::set_none_extents', obj.nix_handle, 0);
130138
else
131-
addID = add_this;
139+
if(strcmp(class(add_this), 'nix.DataArray'))
140+
addID = add_this.id;
141+
else
142+
addID = add_this;
143+
end;
144+
nix_mx('MultiTag::set_extents', obj.nix_handle, addID);
132145
end;
133-
nix_mx('MultiTag::addExtents', obj.nix_handle, addID);
134146
end;
135147

136148
end;
137-
end
149+
end

+nix/Source.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
obj.sourcesCache.lastUpdate = 0;
2525
end;
2626

27+
function hasSource = has_source(obj, id_or_name)
28+
hasSource = nix_mx('Source::hasSource', obj.nix_handle, id_or_name);
29+
end;
30+
2731
function delCheck = delete_source(obj, del)
2832
[delCheck, obj.sourcesCache] = nix.Utils.delete_entity(obj, ...
2933
del, 'nix.Source', 'Source::deleteSource', obj.sourcesCache);

+nix/Tag.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
add_this, 'nix.DataArray', 'Tag::addReference', obj.referencesCache);
3232
end;
3333

34+
function hasRef = has_reference(obj, id_or_name)
35+
hasRef = nix_mx('Tag::hasReference', obj.nix_handle, id_or_name);
36+
end;
37+
3438
function delCheck = remove_reference(obj, del)
3539
[delCheck, obj.referencesCache] = nix.Utils.delete_entity(obj, ...
3640
del, 'nix.DataArray', 'Tag::removeReference', obj.referencesCache);
@@ -65,6 +69,10 @@
6569
obj.featuresCache.lastUpdate = 0;
6670
end;
6771

72+
function hasFeature = has_feature(obj, id_or_name)
73+
hasFeature = nix_mx('Tag::hasFeature', obj.nix_handle, id_or_name);
74+
end;
75+
6876
function delCheck = remove_feature(obj, del)
6977
[delCheck, obj.featuresCache] = nix.Utils.delete_entity(obj, ...
7078
del, 'nix.Feature', 'Tag::deleteFeature', obj.featuresCache);
@@ -86,4 +94,4 @@
8694
end;
8795

8896
end;
89-
end
97+
end

nix_mx.cc

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ void mexFunction(int nlhs,
9898
.add("open", nixfile::open)
9999
.reg("blocks", GETTER(std::vector<nix::Block>, nix::File, blocks))
100100
.reg("sections", GETTER(std::vector<nix::Section>, nix::File, sections))
101+
.reg("hasBlock", GETBYSTR(bool, nix::File, hasBlock))
102+
.reg("hasSection", GETBYSTR(bool, nix::File, hasSection))
101103
.reg("deleteBlock", REMOVER(nix::Block, nix::File, deleteBlock))
102104
.reg("deleteSection", REMOVER(nix::Section, nix::File, deleteSection))
103105
.reg("openBlock", GETBYSTR(nix::Block, nix::File, getBlock))
@@ -113,6 +115,8 @@ void mexFunction(int nlhs,
113115
.reg("sources", &nix::Block::sources)
114116
.reg("tags", &nix::Block::tags)
115117
.reg("multiTags", &nix::Block::multiTags)
118+
.reg("hasDataArray", GETBYSTR(bool, nix::Block, hasDataArray))
119+
.reg("hasSource", GETBYSTR(bool, nix::Block, hasSource))
116120
.reg("groups", &nix::Block::groups)
117121
.reg("hasTag", GETBYSTR(bool, nix::Block, hasTag))
118122
.reg("hasMultiTag", GETBYSTR(bool, nix::Block, hasMultiTag))
@@ -190,6 +194,7 @@ void mexFunction(int nlhs,
190194
.reg("createSource", &nix::Source::createSource)
191195
.reg("deleteSource", REMOVER(nix::Source, nix::Source, deleteSource))
192196
.reg("sources", &nix::Source::sources)
197+
.reg("hasSource", GETBYSTR(bool, nix::Source, hasSource))
193198
.reg("openSource", GETBYSTR(nix::Source, nix::Source, getSource))
194199
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::Source, metadata))
195200
.reg("set_metadata", SETTER(const std::string&, nix::Source, metadata))
@@ -203,6 +208,8 @@ void mexFunction(int nlhs,
203208
.reg("references", GETTER(std::vector<nix::DataArray>, nix::Tag, references))
204209
.reg("features", &nix::Tag::features)
205210
.reg("sources", FILTER(std::vector<nix::Source>, nix::Tag, std::function<bool(const nix::Source &)>, sources))
211+
.reg("hasReference", GETBYSTR(bool, nix::Tag, hasReference))
212+
.reg("hasFeature", GETBYSTR(bool, nix::Tag, hasFeature))
206213
.reg("openReferenceDataArray", GETBYSTR(nix::DataArray, nix::Tag, getReference))
207214
.reg("openFeature", GETBYSTR(nix::Feature, nix::Tag, getFeature))
208215
.reg("openSource", GETBYSTR(nix::Source, nix::Tag, getSource))
@@ -214,6 +221,9 @@ void mexFunction(int nlhs,
214221
.reg("set_type", SETTER(const std::string&, nix::Tag, type))
215222
.reg("set_definition", SETTER(const std::string&, nix::Tag, definition))
216223
.reg("set_none_definition", SETTER(const boost::none_t, nix::Tag, definition))
224+
.reg("set_position", SETTER(const std::vector<double>&, nix::Tag, position))
225+
.reg("set_extent", SETTER(const std::vector<double>&, nix::Tag, extent))
226+
.reg("set_none_extent", SETTER(const boost::none_t, nix::Tag, extent))
217227
.reg("removeReference", REMOVER(nix::DataArray, nix::Tag, removeReference))
218228
.reg("removeSource", REMOVER(nix::Source, nix::Tag, removeSource))
219229
.reg("deleteFeature", REMOVER(nix::Feature, nix::Tag, deleteFeature));
@@ -229,12 +239,18 @@ void mexFunction(int nlhs,
229239
.reg("features", &nix::MultiTag::features)
230240
.reg("sources", FILTER(std::vector<nix::Source>, nix::MultiTag, std::function<bool(const nix::Source &)>, sources))
231241
.reg("hasPositions", GETCONTENT(bool, nix::MultiTag, hasPositions))
242+
.reg("hasReference", GETBYSTR(bool, nix::MultiTag, hasReference))
243+
.reg("hasFeature", GETBYSTR(bool, nix::MultiTag, hasFeature))
232244
.reg("openPositions", GETCONTENT(nix::DataArray, nix::MultiTag, positions))
233245
.reg("openExtents", GETCONTENT(nix::DataArray, nix::MultiTag, extents))
234246
.reg("openReferences", GETBYSTR(nix::DataArray, nix::MultiTag, getReference))
235247
.reg("openFeature", GETBYSTR(nix::Feature, nix::MultiTag, getFeature))
236248
.reg("openSource", GETBYSTR(nix::Source, nix::MultiTag, getSource))
237249
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::MultiTag, metadata))
250+
.reg("set_units", SETTER(const std::vector<std::string>&, nix::MultiTag, units))
251+
.reg("set_none_units", SETTER(const boost::none_t, nix::MultiTag, units))
252+
.reg("set_extents", SETTER(const std::string&, nix::MultiTag, extents))
253+
.reg("set_none_extents", SETTER(const boost::none_t, nix::MultiTag, extents))
238254
.reg("set_metadata", SETTER(const std::string&, nix::MultiTag, metadata))
239255
.reg("set_none_metadata", SETTER(const boost::none_t, nix::MultiTag, metadata))
240256
.reg("removeReference", REMOVER(nix::DataArray, nix::MultiTag, removeReference))
@@ -246,7 +262,6 @@ void mexFunction(int nlhs,
246262
methods->add("MultiTag::addSource", nixmultitag::add_source);
247263
methods->add("MultiTag::createFeature", nixmultitag::create_feature);
248264
methods->add("MultiTag::addPositions", nixmultitag::add_positions);
249-
methods->add("MultiTag::addExtents", nixmultitag::add_extents);
250265

251266
classdef<nix::Section>("Section", methods)
252267
.desc(&nixsection::describe)
@@ -275,7 +290,10 @@ void mexFunction(int nlhs,
275290

276291
classdef<nix::Feature>("Feature", methods)
277292
.desc(&nixfeature::describe)
278-
.reg("openData", GETCONTENT(nix::DataArray, nix::Feature, data));
293+
.reg("openData", GETCONTENT(nix::DataArray, nix::Feature, data))
294+
.reg("setData", SETTER(const std::string&, nix::Feature, data))
295+
.reg("getLinkType", GETCONTENT(nix::LinkType, nix::Feature, linkType));
296+
methods->add("Feature::setLinkType", nixfeature::set_link_type);
279297

280298
classdef<nix::Property>("Property", methods)
281299
.desc(&nixproperty::describe)
@@ -346,4 +364,3 @@ void mexFunction(int nlhs,
346364
mexErrMsgIdAndTxt("nix:arg:dispatch", "Unkown command");
347365
}
348366
}
349-

src/nixfeature.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,11 @@ namespace nixfeature {
1818
return sb.array();
1919
}
2020

21-
} // namespace nixfeature
21+
void set_link_type(const extractor &input, infusor &output)
22+
{
23+
nix::Feature feat = input.entity<nix::Feature>(1);
24+
25+
feat.linkType(input.ltype(2));
26+
}
27+
28+
} // namespace nixfeature

src/nixfeature.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace nixfeature {
77

88
mxArray *describe(const nix::Feature &feat);
99

10+
void set_link_type(const extractor &input, infusor &output);
11+
1012
} // namespace nixfeature
1113

12-
#endif
14+
#endif

src/nixmultitag.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,4 @@ namespace nixmultitag {
6868
currObj.positions(input.str(2));
6969
}
7070

71-
void add_extents(const extractor &input, infusor &output)
72-
{
73-
nix::MultiTag currObj = input.entity<nix::MultiTag>(1);
74-
currObj.extents(input.str(2));
75-
}
76-
77-
void remove_extents(const extractor &input, infusor &output);
78-
7971
} // namespace nixmultitag

0 commit comments

Comments
 (0)