Skip to content

Commit 2d1bbb2

Browse files
committed
Merge pull request #86 from asobolev/master
nix2mx + extractors -> mknix refactoring + some fixes
2 parents 7168a37 + e14cd23 commit 2d1bbb2

20 files changed

+367
-448
lines changed

+nix/Property.m

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,29 @@
3030
end
3131

3232
function [] = set.values(obj, val)
33-
34-
%-- when an update occurs, check, if the datatype of the
35-
%-- data within a normal array is consistent with the
36-
%-- datatype of the property
37-
checkDType = obj.datatype;
38-
if(~iscell(val) && ~isstruct(val) && ~isempty(val))
39-
checkDType = strrep(strrep(class(val),'char','string'),'logical','bool');
40-
%-- convert any values to cell array
41-
val = num2cell(val);
42-
elseif (iscell(val) && ~isstruct(val{1}))
43-
checkDType = strrep(strrep(class(val{1}),'char','string'),'logical','bool');
44-
end;
45-
46-
if(isempty(find(strcmpi(checkDType, obj.datatype),1)))
47-
error('Values do not match property data type!');
48-
end;
49-
50-
nix_mx('Property::updateValues', obj.nix_handle, val);
33+
values = val;
34+
if (~iscell(values))
35+
values = num2cell(val);
36+
end
37+
38+
for i = 1:length(values)
39+
if (isstruct(values{i}))
40+
curr = values{i}.value;
41+
else
42+
curr = values{i};
43+
end
44+
45+
if (~strcmpi(class(curr), obj.datatype))
46+
error('Values do not match property data type!');
47+
end
48+
end
49+
50+
nix_mx('Property::updateValues', obj.nix_handle, values);
5151
obj.valuesCache.lastUpdate = 0;
5252

5353
dispStr = 'Note: nix only supports updating the actual value at the moment.';
5454
dispStr = [dispStr, char(10), 'Attributes like uncertainty or checksum cannot be set at the moment.'];
5555
disp(dispStr);
56-
57-
%-- TODO: clearing existing values using obj.values = '' works,
58-
%-- but is a hack. Refactor in good time.
5956
end
6057
end
6158

nix_mx.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "handle.h"
1010
#include "arguments.h"
1111
#include "struct.h"
12-
#include "nix2mx.h"
12+
#include "mknix.h"
1313

1414
#include "nixfile.h"
1515
#include "nixsection.h"

src/nixdataarray.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include "nixdataarray.h"
2-
#include "nixgen.h"
3-
2+
#include "mkarray.h"
43
#include "mex.h"
54

65
#include <nix.hpp>
76

87
#include "handle.h"
98
#include "arguments.h"
109
#include "struct.h"
11-
#include "nix2mx.h"
10+
#include "mknix.h"
1211

1312
namespace nixdataarray {
1413

@@ -43,8 +42,10 @@ namespace nixdataarray {
4342

4443
void read_all(const extractor &input, infusor &output)
4544
{
45+
//nix::DataArray da = input.entity<nix::DataArray>(1);
46+
4647
nix::DataArray da = input.entity<nix::DataArray>(1);
47-
mxArray *data = nixgen::dataset_read_all(da);
48+
mxArray *data = make_mx_array_from_ds(da);
4849
output.set(0, data);
4950
}
5051

src/nixdimensions.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
#include "nixtag.h"
2-
#include "nixgen.h"
3-
4-
#include "mex.h"
5-
61
#include <nix.hpp>
7-
8-
#include "handle.h"
2+
#include "mex.h"
93
#include "arguments.h"
104
#include "struct.h"
115

src/nixgen.cc

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/nixgen.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/nixmultitag.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "nixmultitag.h"
2-
#include "nixgen.h"
2+
#include "mkarray.h"
33

44
#include "mex.h"
55

@@ -49,7 +49,7 @@ namespace nixmultitag {
4949
double p_index = input.num<double>(2);
5050
double f_index = input.num<double>(3);
5151

52-
mxArray *data = nixgen::dataset_read_all(currObj.retrieveData(p_index, f_index));
52+
mxArray *data = make_mx_array_from_ds(currObj.retrieveData(p_index, f_index));
5353
output.set(0, data);
5454
}
5555

@@ -58,7 +58,7 @@ namespace nixmultitag {
5858
double p_index = input.num<double>(2);
5959
double f_index = input.num<double>(3);
6060

61-
mxArray *data = nixgen::dataset_read_all(currObj.retrieveFeatureData(p_index, f_index));
61+
mxArray *data = make_mx_array_from_ds(currObj.retrieveFeatureData(p_index, f_index));
6262
output.set(0, data);
6363
}
6464

src/nixproperty.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include "nixproperty.h"
2-
#include "nixgen.h"
3-
42
#include "mex.h"
5-
3+
#include "datatypes.h"
64
#include <nix.hpp>
75

86
#include "handle.h"
@@ -20,7 +18,7 @@ namespace nixproperty {
2018
sb.set(prop.definition());
2119
sb.set(prop.unit());
2220
sb.set(prop.mapping());
23-
sb.set(nix::data_type_to_string(prop.dataType()));
21+
sb.set(string_nix2mex(prop.dataType()));
2422

2523
return sb.array();
2624
}
@@ -57,7 +55,8 @@ namespace nixproperty {
5755
nix::Property prop = input.entity<nix::Property>(1);
5856
prop.deleteValues();
5957

60-
prop.values(nixgen::extract_property_values(input, 2));
58+
std::vector<nix::Value> getVals = input.vec(2);
59+
prop.values(getVals);
6160
}
6261

6362
} // namespace nixproperty

src/nixsection.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#include "nixsection.h"
2-
#include "nixgen.h"
3-
42
#include "mex.h"
53
#include <nix.hpp>
64

75
#include "handle.h"
86
#include "arguments.h"
97
#include "struct.h"
10-
#include "nix2mx.h"
8+
#include "mknix.h"
119

1210

1311
namespace nixsection {
@@ -70,7 +68,8 @@ void create_property_with_value(const extractor &input, infusor &output)
7068
{
7169
nix::Section currObj = input.entity<nix::Section>(1);
7270

73-
nix::Property p = currObj.createProperty(input.str(2), nixgen::extract_property_values(input, 3));
71+
std::vector<nix::Value> vals = input.vec(3);
72+
nix::Property p = currObj.createProperty(input.str(2), vals);
7473
output.set(0, handle(p));
7574
}
7675

src/nixtag.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "nixtag.h"
2-
#include "nixgen.h"
2+
#include "mkarray.h"
33

44
#include "mex.h"
55

@@ -50,15 +50,15 @@ namespace nixtag {
5050
nix::Tag currObj = input.entity<nix::Tag>(1);
5151
double index = input.num<double>(2);
5252

53-
mxArray *data = nixgen::dataset_read_all(currObj.retrieveData(index));
53+
mxArray *data = make_mx_array_from_ds(currObj.retrieveData(index));
5454
output.set(0, data);
5555
}
5656

5757
void retrieve_feature_data(const extractor &input, infusor &output) {
5858
nix::Tag currObj = input.entity<nix::Tag>(1);
5959
double index = input.num<double>(2);
6060

61-
mxArray *data = nixgen::dataset_read_all(currObj.retrieveFeatureData(index));
61+
mxArray *data = make_mx_array_from_ds(currObj.retrieveFeatureData(index));
6262
output.set(0, data);
6363
}
6464

0 commit comments

Comments
 (0)