Skip to content

Commit 28ceaee

Browse files
committed
Merge branch 'master' into fixDataTypeErrors
Conflicts: +nix/Block.m +nix/Section.m tests/TestBlock.m tests/TestMultiTag.m tests/TestTag.m
2 parents 5431c8b + b2e40be commit 28ceaee

22 files changed

+514
-365
lines changed

+nix/Block.m

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
handle = nix_mx('Block::createGroup', obj.nix_handle, ...
2828
name, nixtype);
2929
g = nix.Group(handle);
30-
obj.groupsCache.lastUpdate = 0;
3130
end;
3231

3332
function hasGroup = has_group(obj, id_or_name)
@@ -40,7 +39,7 @@
4039
end;
4140

4241
function delCheck = delete_group(obj, del)
43-
[delCheck, obj.groupsCache] = nix.Utils.delete_entity(obj, ...
42+
delCheck = nix.Utils.delete_entity(obj, ...
4443
del, 'nix.Group', 'Block::deleteGroup');
4544
end;
4645

@@ -65,7 +64,6 @@
6564
handle = nix_mx('Block::createDataArray', obj.nix_handle, ...
6665
name, nixtype, lower(datatype.char), shape);
6766
da = nix.DataArray(handle);
68-
obj.dataArraysCache.lastUpdate = 0;
6967
end;
7068
end
7169

@@ -93,26 +91,26 @@
9391
end;
9492

9593
function delCheck = delete_data_array(obj, del)
96-
[delCheck, obj.dataArraysCache] = nix.Utils.delete_entity(obj, ...
97-
del, 'nix.DataArray', 'Block::deleteDataArray', obj.dataArraysCache);
94+
delCheck = nix.Utils.delete_entity(obj, ...
95+
del, 'nix.DataArray', 'Block::deleteDataArray');
9896
end;
9997

10098
% -----------------
10199
% Sources methods
102100
% -----------------
103101

104102
function s = create_source(obj, name, type)
105-
s = nix.Source(nix_mx('Block::createSource', obj.nix_handle, name, type));
106-
obj.sourcesCache.lastUpdate = 0;
103+
s = nix.Source(nix_mx('Block::createSource', ...
104+
obj.nix_handle, name, type));
107105
end;
108106

109107
function hasSource = has_source(obj, id_or_name)
110108
hasSource = nix_mx('Block::hasSource', obj.nix_handle, id_or_name);
111109
end;
112110

113111
function delCheck = delete_source(obj, del)
114-
[delCheck, obj.sourcesCache] = nix.Utils.delete_entity(obj, ...
115-
del, 'nix.Source', 'Block::deleteSource', obj.sourcesCache);
112+
delCheck = nix.Utils.delete_entity(obj, ...
113+
del, 'nix.Source', 'Block::deleteSource');
116114
end;
117115

118116
function retObj = open_source(obj, id_or_name)
@@ -137,12 +135,11 @@
137135
th = nix_mx('Block::createTag', obj.nix_handle, ...
138136
name, type, position);
139137
tag = nix.Tag(th);
140-
obj.tagsCache.lastUpdate = 0;
141138
end;
142139

143140
function delCheck = delete_tag(obj, del)
144-
[delCheck, obj.tagsCache] = nix.Utils.delete_entity(obj, ...
145-
del, 'nix.Tag', 'Block::deleteTag', obj.tagsCache);
141+
delCheck = nix.Utils.delete_entity(obj, ...
142+
del, 'nix.Tag', 'Block::deleteTag');
146143
end;
147144

148145
% -----------------
@@ -168,12 +165,12 @@
168165

169166
multitag = nix.MultiTag(nix_mx('Block::createMultiTag', ...
170167
obj.nix_handle, name, type, addID));
171-
obj.multiTagsCache.lastUpdate = 0;
172168
end;
173169

174170
function delCheck = delete_multi_tag(obj, del)
175-
[delCheck, obj.multiTagsCache] = nix.Utils.delete_entity(obj, ...
176-
del, 'nix.MultiTag', 'Block::deleteMultiTag', obj.multiTagsCache);
171+
delCheck = nix.Utils.delete_entity(obj, ...
172+
del, 'nix.MultiTag', 'Block::deleteMultiTag');
177173
end;
174+
178175
end;
179176
end

+nix/CacheStruct.m

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

+nix/DataArray.m

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
properties (Hidden)
55
% namespace reference for nix-mx functions
66
alias = 'DataArray'
7-
dimsCache
8-
end
7+
end;
98

109
properties(Dependent)
1110
dimensions % should not be dynamic due to complex set operation
@@ -23,58 +22,47 @@
2322
nix.Dynamic.add_dyn_attr(obj, 'expansionOrigin', 'rw');
2423
nix.Dynamic.add_dyn_attr(obj, 'polynom_coefficients', 'rw');
2524
nix.Dynamic.add_dyn_attr(obj, 'shape', 'rw');
26-
27-
obj.dimsCache = nix.CacheStruct();
2825
end;
2926

3027
% -----------------
3128
% Dimensions
3229
% -----------------
3330

3431
function dimensions = get.dimensions(obj)
35-
if obj.dimsCache.lastUpdate ~= obj.updatedAt
36-
currList = nix_mx('DataArray::dimensions', obj.nix_handle);
37-
obj.dimsCache.data = cell(length(currList), 1);
38-
for i = 1:length(currList)
39-
40-
switch currList(i).dtype
41-
case 'set'
42-
obj.dimsCache.data{i} = nix.SetDimension(currList(i).dimension);
43-
case 'sample'
44-
obj.dimsCache.data{i} = nix.SampledDimension(currList(i).dimension);
45-
case 'range'
46-
obj.dimsCache.data{i} = nix.RangeDimension(currList(i).dimension);
47-
otherwise
48-
disp('some dimension type is unknown! skip')
49-
end
32+
dimensions = {};
33+
currList = nix_mx('DataArray::dimensions', obj.nix_handle);
34+
for i = 1:length(currList)
35+
switch currList(i).dtype
36+
case 'set'
37+
dimensions{i} = nix.SetDimension(currList(i).dimension);
38+
case 'sample'
39+
dimensions{i} = nix.SampledDimension(currList(i).dimension);
40+
case 'range'
41+
dimensions{i} = nix.RangeDimension(currList(i).dimension);
42+
otherwise
43+
disp('some dimension type is unknown! skip')
5044
end;
51-
obj.dimsCache.lastUpdate = obj.updatedAt;
5245
end;
53-
dimensions = obj.dimsCache.data;
5446
end;
5547

5648
function dim = append_set_dimension(obj)
5749
func_name = strcat(obj.alias, '::append_set_dimension');
5850
dim = nix.SetDimension(nix_mx(func_name, obj.nix_handle));
59-
obj.dimsCache.lastUpdate = 0;
6051
end
6152

6253
function dim = append_sampled_dimension(obj, interval)
6354
func_name = strcat(obj.alias, '::append_sampled_dimension');
6455
dim = nix.SampledDimension(nix_mx(func_name, obj.nix_handle, interval));
65-
obj.dimsCache.lastUpdate = 0;
6656
end
6757

6858
function dim = append_range_dimension(obj, ticks)
6959
func_name = strcat(obj.alias, '::append_range_dimension');
7060
dim = nix.RangeDimension(nix_mx(func_name, obj.nix_handle, ticks));
71-
obj.dimsCache.lastUpdate = 0;
7261
end
7362

7463
function delCheck = delete_dimension(obj, index)
7564
func_name = strcat(obj.alias, '::delete_dimension');
7665
delCheck = nix_mx(func_name, obj.nix_handle, index);
77-
obj.dimsCache.lastUpdate = 0;
7866
end;
7967

8068
% -----------------

+nix/Dynamic.m

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,32 @@ function set_method(obj, val)
2222
prop, class(obj)));
2323
throwAsCaller(ME);
2424
end
25-
25+
2626
if (isempty(val))
2727
nix_mx(strcat(obj.alias, '::set_none_', prop), obj.nix_handle, 0);
28+
elseif(strcmp(prop, 'units') && (~iscell(val)))
29+
%-- BUGFIX: Matlab crashes, if units in Tags and MultiTags
30+
%-- are set using anything else than a cell.
31+
ME = MException('MATLAB:class:SetProhibited', sprintf(...
32+
'Units can be only set by using cells.'));
33+
throwAsCaller(ME);
2834
else
2935
nix_mx(strcat(obj.alias, '::set_', prop), obj.nix_handle, val);
3036
end
3137
obj.info = nix_mx(strcat(obj.alias, '::describe'), obj.nix_handle);
3238
end
33-
39+
3440
function val = get_method(obj)
3541
val = obj.info.(prop);
3642
end
3743
end
3844

3945
function add_dyn_relation(obj, name, constructor)
40-
cacheAttr = strcat(name, 'Cache');
41-
cache = addprop(obj, cacheAttr);
42-
cache.Hidden = true;
43-
obj.(cacheAttr) = nix.CacheStruct();
44-
46+
dataAttr = strcat(name, 'Data');
47+
data = addprop(obj, dataAttr);
48+
data.Hidden = true;
49+
obj.(dataAttr) = {};
50+
4551
% adds a proxy property
4652
rel = addprop(obj, name);
4753
rel.GetMethod = @get_method;
@@ -52,9 +58,10 @@ function add_dyn_relation(obj, name, constructor)
5258
rel_map.Hidden = true;
5359

5460
function val = get_method(obj)
55-
[obj.(cacheAttr), val] = nix.Utils.fetchObjList(obj.updatedAt, ...
61+
obj.(dataAttr) = nix.Utils.fetchObjList(...
5662
strcat(obj.alias, '::', name), obj.nix_handle, ...
57-
obj.(cacheAttr), constructor);
63+
constructor);
64+
val = obj.(dataAttr);
5865
end
5966

6067
function val = get_as_map(obj)
@@ -67,4 +74,5 @@ function add_dyn_relation(obj, name, constructor)
6774
end
6875
end
6976
end
70-
end
77+
78+
end

+nix/File.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
function newBlock = createBlock(obj, name, type)
2929
newBlock = nix.Block(nix_mx('File::createBlock', obj.nix_handle, name, type));
30-
obj.blocksCache.lastUpdate = 0;
3130
end;
3231

3332
function hasBlock = hasBlock(obj, id_or_name)
@@ -40,8 +39,8 @@
4039
end
4140

4241
function delCheck = deleteBlock(obj, del)
43-
[delCheck, obj.blocksCache] = nix.Utils.delete_entity(obj, ...
44-
del, 'nix.Block', 'File::deleteBlock', obj.blocksCache);
42+
delCheck = nix.Utils.delete_entity(obj, ...
43+
del, 'nix.Block', 'File::deleteBlock');
4544
end;
4645

4746
% ----------------
@@ -50,7 +49,6 @@
5049

5150
function newSec = createSection(obj, name, type)
5251
newSec = nix.Section(nix_mx('File::createSection', obj.nix_handle, name, type));
53-
obj.sectionsCache.lastUpdate = 0;
5452
end;
5553

5654
function hasSec = hasSection(obj, id_or_name)
@@ -64,9 +62,7 @@
6462

6563
function delCheck = deleteSection(obj, del)
6664
delCheck = nix.Utils.delete_entity(obj, del, 'nix.Section', 'File::deleteSection');
67-
obj.sectionsCache.lastUpdate = 0;
6865
end;
69-
7066
end
71-
end
7267

68+
end

+nix/Group.m

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,22 @@
3131
end;
3232

3333
function [] = add_data_array(obj, add_this)
34-
obj.dataArraysCache = nix.Utils.add_entity(obj, ...
35-
add_this, 'nix.DataArray', 'Group::addDataArray', ...
36-
obj.dataArraysCache);
34+
nix.Utils.add_entity(obj, add_this, ...
35+
'nix.DataArray', 'Group::addDataArray');
3736
end;
3837

3938
function delCheck = remove_data_array(obj, del)
40-
[delCheck, obj.dataArraysCache] = nix.Utils.delete_entity(obj, ...
41-
del, 'nix.DataArray', 'Group::removeDataArray', ...
42-
obj.dataArraysCache);
39+
delCheck = nix.Utils.delete_entity(obj, del, ...
40+
'nix.DataArray', 'Group::removeDataArray');
4341
end;
4442

4543
% -----------------
4644
% Tags methods
4745
% -----------------
4846

4947
function [] = add_tag(obj, add_this)
50-
obj.tagsCache = nix.Utils.add_entity(obj, ...
51-
add_this, 'nix.Tag', 'Group::addTag', ...
52-
obj.tagsCache);
48+
nix.Utils.add_entity(obj, add_this, ...
49+
'nix.Tag', 'Group::addTag');
5350
end;
5451

5552
function hasTag = has_tag(obj, id_or_name)
@@ -62,19 +59,17 @@
6259
end;
6360

6461
function delCheck = remove_tag(obj, del)
65-
[delCheck, obj.tagsCache] = nix.Utils.delete_entity(obj, ...
66-
del, 'nix.Tag', 'Group::removeTag', ...
67-
obj.tagsCache);
62+
delCheck = nix.Utils.delete_entity(obj, del, ...
63+
'nix.Tag', 'Group::removeTag');
6864
end;
6965

7066
% -----------------
7167
% MultiTag methods
7268
% -----------------
7369

7470
function [] = add_multi_tag(obj, add_this)
75-
obj.multiTagsCache = nix.Utils.add_entity(obj, ...
76-
add_this, 'nix.MultiTag', 'Group::addMultiTag', ...
77-
obj.multiTagsCache);
71+
nix.Utils.add_entity(obj, add_this, ...
72+
'nix.MultiTag', 'Group::addMultiTag');
7873
end;
7974

8075
function hasMTag = has_multi_tag(obj, id_or_name)
@@ -88,10 +83,9 @@
8883
end;
8984

9085
function delCheck = remove_multi_tag(obj, del)
91-
[delCheck, obj.multiTagsCache] = nix.Utils.delete_entity(obj, ...
92-
del, 'nix.MultiTag', 'Group::removeMultiTag', ...
93-
obj.multiTagsCache);
86+
delCheck = nix.Utils.delete_entity(obj, del, ...
87+
'nix.MultiTag', 'Group::removeMultiTag');
9488
end;
95-
9689
end;
90+
9791
end

+nix/MetadataMixIn.m

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,22 @@
88
alias
99
end
1010

11-
properties(Hidden)
12-
metadataCache
13-
end;
14-
1511
methods
16-
function obj = MetadataMixIn()
17-
obj.metadataCache = nix.CacheStruct();
18-
end
19-
2012
function metadata = open_metadata(obj)
21-
[obj.metadataCache, metadata] = nix.Utils.fetchObj(...
22-
obj.updatedAt, ...
13+
metadata = nix.Utils.fetchObj(...
2314
strcat(obj.alias, '::openMetadataSection'), ...
24-
obj.nix_handle, obj.metadataCache, @nix.Section);
15+
obj.nix_handle, @nix.Section);
2516
end;
2617

2718
function set_metadata(obj, val)
2819
if (isempty(val))
29-
nix_mx(strcat(obj.alias, '::set_none_metadata'), obj.nix_handle, val);
20+
nix_mx(strcat(obj.alias, '::set_none_metadata'), ...
21+
obj.nix_handle, val);
3022
else
31-
obj.metadataCache = nix.Utils.add_entity(obj, val, 'nix.Section', ...
32-
strcat(obj.alias, '::set_metadata'), obj.metadataCache);
23+
nix.Utils.add_entity(obj, val, 'nix.Section', ...
24+
strcat(obj.alias, '::set_metadata'));
3325
end;
34-
obj.metadataCache.lastUpdate = 0;
3526
end;
3627
end;
3728

3829
end
39-

0 commit comments

Comments
 (0)