Skip to content

Commit 653a65a

Browse files
committed
Merge pull request #56 from mpsonntag/dev
migrate to glue: Feature entity, openMetadata
2 parents c908413 + 94d1c6b commit 653a65a

15 files changed

+15
-98
lines changed

nix_mx.cc

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,16 @@ const std::vector<fendpoint> funcs = {
7070
{ "Block::listSources", nixblock::list_sources },
7171
{ "Block::listTags", nixblock::list_tags },
7272
{ "Block::listMultiTags", nixblock::list_multi_tags },
73-
{ "Block::openMetadataSection", nixblock::open_metadata_section },
7473

7574
// Data Array
7675
{ "DataArray::describe", nixdataarray::describe },
7776
{ "DataArray::readAll", nixdataarray::read_all },
78-
{ "DataArray::openMetadataSection", nixdataarray::open_metadata_section },
7977

8078
// Tag
8179
{ "Tag::describe", nixtag::describe },
8280
{ "Tag::listReferences", nixtag::list_references_array },
8381
{ "Tag::listFeatures", nixtag::list_features },
8482
{ "Tag::listSources", nixtag::list_sources },
85-
{ "Tag::openMetadataSection", nixtag::open_metadata_section },
8683
{ "Tag::retrieveData", nixtag::retrieve_data },
8784
{ "Tag::featureRetrieveData", nixtag::retrieve_feature_data },
8885

@@ -91,19 +88,16 @@ const std::vector<fendpoint> funcs = {
9188
{ "MultiTag::listReferences", nixmultitag::list_references_array },
9289
{ "MultiTag::listFeatures", nixmultitag::list_features },
9390
{ "MultiTag::listSources", nixmultitag::list_sources },
94-
{ "MultiTag::openMetadataSection", nixmultitag::open_metadata_section },
9591
{ "MultiTag::retrieveData", nixmultitag::retrieve_data },
9692
{ "MultiTag::featureRetrieveData", nixmultitag::retrieve_feature_data },
9793

9894
// Source
9995
{ "Source::describe", nixsource::describe },
10096
{ "Source::listSources", nixsource::list_sources },
101-
{ "Source::openMetadataSection", nixsource::open_metadata_section },
10297

10398
// Feature
10499
{ "Feature::describe", nixfeature::describe },
105100
{ "Feature::linkType", nixfeature::link_type },
106-
{ "Feature::openData", nixfeature::open_data },
107101

108102
// Section
109103
{ "Section::describe", nixsection::describe },
@@ -127,6 +121,8 @@ static void on_exit() {
127121
#define GETBYSTR(type, class, name) static_cast<type(class::*)(const std::string &)const>(&class::name)
128122
#define GETCONTENT(type, class, name) static_cast<type(class::*)()const>(&class::name)
129123
#define GETSOURCES(base__) static_cast<std::vector<nix::Source>(nix::base::EntityWithSources<nix::base::base__>::*)(std::function<bool(const nix::Source &)>)const>(&nix::base::EntityWithSources<nix::base::base__>::sources)
124+
//required to open nix::Section from DataArray, normal GETCONTENT leads to a compiler error with Visual Studio 12
125+
#define GETMETADATA(base__) static_cast<nix::Section(nix::base::EntityWithMetadata<nix::base::base__>::*)()const>(&nix::base::EntityWithMetadata<nix::base::base__>::metadata)
130126
#define REMOVER(type, class, name) static_cast<bool(class::*)(const std::string&)>(&class::name)
131127

132128
// main entry point
@@ -170,22 +166,26 @@ void mexFunction(int nlhs,
170166
.reg("openDataArray", GETBYSTR(nix::DataArray, nix::Block, getDataArray))
171167
.reg("openSource", GETBYSTR(nix::Source, nix::Block, getSource))
172168
.reg("openTag", GETBYSTR(nix::Tag, nix::Block, getTag))
173-
.reg("openMultiTag", GETBYSTR(nix::MultiTag, nix::Block, getMultiTag));
169+
.reg("openMultiTag", GETBYSTR(nix::MultiTag, nix::Block, getMultiTag))
170+
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::Block, metadata));
174171

175172
classdef<nix::DataArray>("DataArray", methods)
176-
.reg("sources", GETSOURCES(IDataArray));
173+
.reg("sources", GETSOURCES(IDataArray))
174+
.reg("openMetadataSection", GETMETADATA(IDataArray));
177175

178176
classdef<nix::Source>("Source", methods)
179177
.reg("sources", &nix::Source::sources)
180-
.reg("openSource", GETBYSTR(nix::Source, nix::Source, getSource));
178+
.reg("openSource", GETBYSTR(nix::Source, nix::Source, getSource))
179+
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::Source, metadata));
181180

182181
classdef<nix::Tag>("Tag", methods)
183182
.reg("references", GETTER(std::vector<nix::DataArray>, nix::Tag, references))
184183
.reg("features", &nix::Tag::features)
185184
.reg("sources", GETSOURCES(ITag))
186185
.reg("openReferenceDataArray", GETBYSTR(nix::DataArray, nix::Tag, getReference))
187186
.reg("openFeature", GETBYSTR(nix::Feature, nix::Tag, getFeature))
188-
.reg("openSource", GETBYSTR(nix::Source, nix::Tag, getSource));
187+
.reg("openSource", GETBYSTR(nix::Source, nix::Tag, getSource))
188+
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::Tag, metadata));
189189

190190
classdef<nix::MultiTag>("MultiTag", methods)
191191
.reg("references", GETTER(std::vector<nix::DataArray>, nix::MultiTag, references))
@@ -196,7 +196,8 @@ void mexFunction(int nlhs,
196196
.reg("openExtents", GETCONTENT(nix::DataArray, nix::MultiTag, extents))
197197
.reg("openReferences", GETBYSTR(nix::DataArray, nix::MultiTag, getReference))
198198
.reg("openFeature", GETBYSTR(nix::Feature, nix::MultiTag, getFeature))
199-
.reg("openSource", GETBYSTR(nix::Source, nix::MultiTag, getSource));
199+
.reg("openSource", GETBYSTR(nix::Source, nix::MultiTag, getSource))
200+
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::MultiTag, metadata));
200201

201202
classdef<nix::Section>("Section", methods)
202203
.reg("sections", &nix::Section::sections)
@@ -206,6 +207,9 @@ void mexFunction(int nlhs,
206207
.reg("link", GETCONTENT(nix::Section, nix::Section, link))
207208
.reg("parent", GETCONTENT(nix::Section, nix::Section, parent));
208209

210+
classdef<nix::Feature>("Feature", methods)
211+
.reg("openData", GETCONTENT(nix::DataArray, nix::Feature, data));
212+
209213
mexAtExit(on_exit);
210214
});
211215

src/nixblock.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,4 @@ namespace nixblock {
7777
output.set(0, sb.array());
7878
}
7979

80-
void open_metadata_section(const extractor &input, infusor &output)
81-
{
82-
nix::Block currObj = input.entity<nix::Block>(1);
83-
output.set(0, nixgen::get_handle_or_none(currObj.metadata()));
84-
}
85-
8680
} // namespace nixblock

src/nixblock.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ namespace nixblock {
1515

1616
void list_multi_tags(const extractor &input, infusor &output);
1717

18-
void open_metadata_section(const extractor &input, infusor &output);
19-
2018
} // namespace nixblock
2119

2220
#endif

src/nixdataarray.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,4 @@ namespace nixdataarray {
6363
output.set(0, data);
6464
}
6565

66-
void open_metadata_section(const extractor &input, infusor &output)
67-
{
68-
nix::DataArray currObj = input.entity<nix::DataArray>(1);
69-
output.set(0, nixgen::get_handle_or_none(currObj.metadata()));
70-
}
71-
7266
} // namespace nixdataarray

src/nixdataarray.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ namespace nixdataarray {
99

1010
void read_all(const extractor &input, infusor &output);
1111

12-
void open_metadata_section(const extractor &input, infusor &output);
13-
1412
} // namespace nixdataarray
1513

1614
#endif

src/nixfeature.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ namespace nixfeature {
1919
output.set(0, sb.array());
2020
}
2121

22-
void open_data(const extractor &input, infusor &output)
23-
{
24-
nix::Feature currFeat = input.entity < nix::Feature >(1);
25-
output.set(0, nixgen::open_data_array(currFeat.data()));
26-
}
27-
2822
void link_type(const extractor &input, infusor &output)
2923
{
3024
nix::Feature currFeat = input.entity<nix::Feature>(1);

src/nixfeature.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ namespace nixfeature {
77

88
void describe(const extractor &input, infusor &output);
99

10-
void open_data(const extractor &input, infusor &output);
11-
1210
void link_type(const extractor &input, infusor &output);
1311

1412
} // namespace nixfeature

src/nixgen.cc

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010

1111
namespace nixgen {
1212

13-
handle open_data_array(nix::DataArray inDa)
14-
{
15-
nix::DataArray da = inDa;
16-
handle h = handle(da);
17-
return h;
18-
}
19-
2013
mxArray* list_data_arrays(std::vector<nix::DataArray> daIn)
2114
{
2215
std::vector<nix::DataArray> arr = daIn;
@@ -58,21 +51,6 @@ namespace nixgen {
5851
return sb.array();
5952
}
6053

61-
handle open_source(nix::Source sourceIn)
62-
{
63-
nix::Source currSource = sourceIn;
64-
handle currSourceHandle = handle(currSource);
65-
return currSourceHandle;
66-
}
67-
68-
handle open_feature(nix::Feature featIn)
69-
{
70-
nix::Feature currFeat = featIn;
71-
handle currTagFeatHandle = handle(currFeat);
72-
return currTagFeatHandle;
73-
}
74-
75-
7654
mxArray *dataset_read_all(const nix::DataSet &da) {
7755
nix::NDSize size = da.dataExtent();
7856
const size_t len = size.size();

src/nixgen.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,12 @@
66

77
namespace nixgen {
88

9-
handle open_data_array(nix::DataArray inDa);
10-
119
mxArray* list_data_arrays(std::vector<nix::DataArray> daIn);
1210

1311
mxArray* list_features(std::vector<nix::Feature> featIn);
1412

1513
mxArray* list_sources(std::vector<nix::Source> sourceIn);
1614

17-
handle open_source(nix::Source sourceIn);
18-
19-
handle open_feature(nix::Feature featIn);
20-
21-
template<typename T>
22-
uint64_t get_handle_or_none(T &&obj) {
23-
if (obj) {
24-
return handle(std::forward<T>(obj)).address();
25-
}
26-
else
27-
{
28-
return uint64_t(0);
29-
}
30-
}
31-
3215
mxArray *dataset_read_all(const nix::DataSet &da);
3316

3417
} // namespace nixgen

src/nixmultitag.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ namespace nixmultitag {
4343
output.set(0, nixgen::list_sources(currObj.sources()));
4444
}
4545

46-
void open_metadata_section(const extractor &input, infusor &output)
47-
{
48-
nix::MultiTag currObj = input.entity<nix::MultiTag>(1);
49-
output.set(0, nixgen::get_handle_or_none(currObj.metadata()));
50-
}
51-
5246
void retrieve_data(const extractor &input, infusor &output) {
5347
nix::MultiTag currObj = input.entity<nix::MultiTag>(1);
5448
double p_index = input.num<double>(2);

0 commit comments

Comments
 (0)