Skip to content

Commit 64ebc27

Browse files
committed
Merge pull request #63 from mpsonntag/createDelete
Various create / delete methods ifor Block and Multitag entities
2 parents f9c2e2c + b2cd92f commit 64ebc27

File tree

10 files changed

+489
-197
lines changed

10 files changed

+489
-197
lines changed

+nix/Block.m

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@
4646
da = obj.create_data_array(name, nixtype, dtype, shape);
4747
da.write_all(data);
4848
end
49-
49+
50+
function delCheck = delete_data_array(obj, del)
51+
[delCheck, obj.dataArraysCache] = nix.Utils.delete_entity(obj, ...
52+
del, 'nix.DataArray', 'Block::deleteDataArray', obj.dataArraysCache);
53+
end;
54+
5055
% -----------------
5156
% Sources methods
5257
% -----------------
@@ -85,7 +90,12 @@
8590
tag = nix.Tag(th);
8691
obj.tagsCache.lastUpdate = 0;
8792
end;
88-
93+
94+
function delCheck = delete_tag(obj, del)
95+
[delCheck, obj.tagsCache] = nix.Utils.delete_entity(obj, ...
96+
del, 'nix.Tag', 'Block::deleteTag', obj.tagsCache);
97+
end;
98+
8999
% -----------------
90100
% MultiTag methods
91101
% -----------------
@@ -98,7 +108,25 @@
98108
retObj = nix.Utils.open_entity(obj, ...
99109
'Block::openMultiTag', id_or_name, @nix.MultiTag);
100110
end;
111+
112+
%-- creating a multitag requires an already existing data array
113+
function multitag = create_multi_tag(obj, name, type, add_data_array)
114+
if(strcmp(class(add_data_array), 'nix.DataArray'))
115+
addID = add_data_array.id;
116+
else
117+
addID = add_data_array;
118+
end;
119+
120+
multitag = nix.MultiTag(nix_mx('Block::createMultiTag', ...
121+
obj.nix_handle, name, type, addID));
122+
obj.multiTagsCache.lastUpdate = 0;
123+
end;
101124

125+
function delCheck = delete_multi_tag(obj, del)
126+
[delCheck, obj.multiTagsCache] = nix.Utils.delete_entity(obj, ...
127+
del, 'nix.MultiTag', 'Block::deleteMultiTag', obj.multiTagsCache);
128+
end;
129+
102130
% -----------------
103131
% Metadata methods
104132
% -----------------

+nix/MultiTag.m

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,17 @@
7474
% ------------------
7575
% References methods
7676
% ------------------
77-
77+
78+
function [] = add_reference(obj, add_this)
79+
obj.referencesCache = nix.Utils.add_entity(obj, ...
80+
add_this, 'nix.DataArray', 'MultiTag::addReference', obj.referencesCache);
81+
end;
82+
83+
function delCheck = remove_reference(obj, del)
84+
[delCheck, obj.referencesCache] = nix.Utils.delete_entity(obj, ...
85+
del, 'nix.DataArray', 'MultiTag::removeReference', obj.referencesCache);
86+
end;
87+
7888
function retObj = open_reference(obj, id_or_name)
7989
retObj = nix.Utils.open_entity(obj, ...
8090
'MultiTag::openReferences', id_or_name, @nix.DataArray);
@@ -127,6 +137,16 @@
127137
% Sources methods
128138
% ------------------
129139

140+
function [] = add_source(obj, add_this)
141+
obj.sourcesCache = nix.Utils.add_entity(obj, ...
142+
add_this, 'nix.Source', 'MultiTag::addSource', obj.sourcesCache);
143+
end;
144+
145+
function delCheck = remove_source(obj, del)
146+
[delCheck, obj.sourcesCache] = nix.Utils.delete_entity(obj, ...
147+
del, 'nix.Source', 'MultiTag::removeSource', obj.sourcesCache);
148+
end;
149+
130150
function retObj = open_source(obj, id_or_name)
131151
retObj = nix.Utils.open_entity(obj, ...
132152
'MultiTag::openSource', id_or_name, @nix.Source);

nix_mx.cc

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ void mexFunction(int nlhs,
101101

102102
classdef<nix::Block>("Block", methods)
103103
.desc(&nixblock::describe)
104-
.reg("dataArrays", &nix::Block::dataArrays)
105-
.reg("createSource", &nix::Block::createSource)
106-
.reg("deleteSource", REMOVER(nix::Source, nix::Block, deleteSource))
107104
//.reg("createDataArray", static_cast<nix::DataArray(nix::Block::*)(const std::string &, const std::string &, nix::DataType, const nix::NDSize &)>(&nix::Block::createDataArray))
105+
.reg("createSource", &nix::Block::createSource)
108106
.reg("createTag", &nix::Block::createTag)
109-
.reg("createMultiTag", &nix::Block::createMultiTag)
107+
.reg("dataArrays", &nix::Block::dataArrays)
110108
.reg("sources", &nix::Block::sources)
111109
.reg("tags", &nix::Block::tags)
112110
.reg("multiTags", &nix::Block::multiTags)
@@ -116,8 +114,13 @@ void mexFunction(int nlhs,
116114
.reg("openSource", GETBYSTR(nix::Source, nix::Block, getSource))
117115
.reg("openTag", GETBYSTR(nix::Tag, nix::Block, getTag))
118116
.reg("openMultiTag", GETBYSTR(nix::MultiTag, nix::Block, getMultiTag))
119-
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::Block, metadata));
117+
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::Block, metadata))
118+
.reg("deleteDataArray", REMOVER(nix::DataArray, nix::Block, deleteDataArray))
119+
.reg("deleteSource", REMOVER(nix::Source, nix::Block, deleteSource))
120+
.reg("deleteTag", REMOVER(nix::Tag, nix::Block, deleteTag))
121+
.reg("deleteMultiTag", REMOVER(nix::MultiTag, nix::Block, deleteMultiTag));
120122
methods->add("Block::createDataArray", nixblock::create_data_array);
123+
methods->add("Block::createMultiTag", nixblock::create_multi_tag);
121124

122125
classdef<nix::DataArray>("DataArray", methods)
123126
.desc(&nixdataarray::describe)
@@ -161,9 +164,13 @@ void mexFunction(int nlhs,
161164
.reg("openReferences", GETBYSTR(nix::DataArray, nix::MultiTag, getReference))
162165
.reg("openFeature", GETBYSTR(nix::Feature, nix::MultiTag, getFeature))
163166
.reg("openSource", GETBYSTR(nix::Source, nix::MultiTag, getSource))
164-
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::MultiTag, metadata));
167+
.reg("openMetadataSection", GETCONTENT(nix::Section, nix::MultiTag, metadata))
168+
.reg("removeReference", REMOVER(nix::DataArray, nix::MultiTag, removeReference))
169+
.reg("removeSource", REMOVER(nix::Source, nix::MultiTag, removeSource));
165170
methods->add("MultiTag::retrieveData", nixmultitag::retrieve_data);
166171
methods->add("MultiTag::featureRetrieveData", nixmultitag::retrieve_feature_data);
172+
methods->add("MultiTag::addReference", nixmultitag::add_reference);
173+
methods->add("MultiTag::addSource", nixmultitag::add_source);
167174

168175
classdef<nix::Section>("Section", methods)
169176
.desc(&nixsection::describe)

src/nixblock.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,15 @@ namespace nixblock {
3535
output.set(0, dt);
3636
}
3737

38+
void create_multi_tag(const extractor &input, infusor &output)
39+
{
40+
nix::Block block = input.entity<nix::Block>(1);
41+
std::string name = input.str(2);
42+
std::string type = input.str(3);
43+
nix::DataArray positions = block.getDataArray(input.str(4));
44+
45+
nix::MultiTag mTag = block.createMultiTag(name, type, positions);
46+
output.set(0, mTag);
47+
}
48+
3849
} // namespace nixblock

src/nixblock.h

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

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

12+
void create_multi_tag(const extractor &input, infusor &output);
13+
1214
} // namespace nixblock
1315

1416
#endif

src/nixmultitag.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ namespace nixmultitag {
2424
return sb.array();
2525
}
2626

27+
void add_reference(const extractor &input, infusor &output)
28+
{
29+
nix::MultiTag currObj = input.entity<nix::MultiTag>(1);
30+
currObj.addReference(input.str(2));
31+
}
32+
33+
void add_source(const extractor &input, infusor &output)
34+
{
35+
nix::MultiTag currObj = input.entity<nix::MultiTag>(1);
36+
currObj.addSource(input.str(2));
37+
}
38+
2739
void retrieve_data(const extractor &input, infusor &output) {
2840
nix::MultiTag currObj = input.entity<nix::MultiTag>(1);
2941
double p_index = input.num<double>(2);

src/nixmultitag.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ namespace nixmultitag {
77

88
mxArray *describe(const nix::MultiTag &multitag);
99

10+
void add_reference(const extractor &input, infusor &output);
11+
12+
void add_source(const extractor &input, infusor &output);
13+
1014
void retrieve_data(const extractor &input, infusor &output);
1115

1216
void retrieve_feature_data(const extractor &input, infusor &output);

0 commit comments

Comments
 (0)