Skip to content

Commit 008defb

Browse files
committed
removeCache: refactor Section and Property
1 parent df1c974 commit 008defb

File tree

3 files changed

+9
-38
lines changed

3 files changed

+9
-38
lines changed

+nix/Property.m

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
properties(Hidden)
66
% namespace reference for nix-mx functions
77
alias = 'Property'
8-
valuesCache
98
end;
109

1110
properties(Dependent)
@@ -20,13 +19,10 @@
2019
nix.Dynamic.add_dyn_attr(obj, 'unit', 'rw');
2120
nix.Dynamic.add_dyn_attr(obj, 'mapping', 'rw');
2221
nix.Dynamic.add_dyn_attr(obj, 'datatype', 'r');
23-
24-
obj.valuesCache = nix.CacheStruct();
2522
end;
2623

2724
function retVals = get.values(obj)
28-
[obj.valuesCache, retVals] = nix.Utils.fetchPropList(obj.updatedAt, ...
29-
'Property::values', obj.nix_handle, obj.valuesCache);
25+
retVals = nix_mx('Property::values', obj.nix_handle);
3026
end
3127

3228
function [] = set.values(obj, val)
@@ -48,13 +44,11 @@
4844
end
4945

5046
nix_mx('Property::updateValues', obj.nix_handle, values);
51-
obj.valuesCache.lastUpdate = 0;
5247

5348
dispStr = 'Note: nix only supports updating the actual value at the moment.';
5449
dispStr = [dispStr, char(10), 'Attributes like uncertainty or checksum cannot be set at the moment.'];
5550
disp(dispStr);
5651
end
5752
end
58-
59-
end
6053

54+
end

+nix/Section.m

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
properties(Hidden)
66
% namespace reference for nix-mx functions
77
alias = 'Section'
8-
propsCache
98
end;
109

1110
properties(Dependent)
@@ -23,8 +22,6 @@
2322

2423
% assign relations
2524
nix.Dynamic.add_dyn_relation(obj, 'sections', @nix.Section);
26-
27-
obj.propsCache = nix.CacheStruct();
2825
end;
2926

3027
function section = parent(obj)
@@ -65,13 +62,13 @@
6562
% ----------------
6663

6764
function newSec = createSection(obj, name, type)
68-
newSec = nix.Section(nix_mx('Section::createSection', obj.nix_handle, name, type));
69-
obj.sectionsCache.lastUpdate = 0;
65+
newSec = nix.Section(nix_mx('Section::createSection', ...
66+
obj.nix_handle, name, type));
7067
end;
7168

7269
function delCheck = deleteSection(obj, del)
73-
delCheck = nix.Utils.delete_entity(obj, del, 'nix.Section', 'Section::deleteSection');
74-
obj.sectionsCache.lastUpdate = 0;
70+
delCheck = nix.Utils.delete_entity_(obj, del, ...
71+
'nix.Section', 'Section::deleteSection');
7572
end;
7673

7774
function retObj = open_section(obj, id_or_name)
@@ -92,7 +89,6 @@
9289
function p = create_property(obj, name, datatype)
9390
p = nix.Property(nix_mx('Section::createProperty', ...
9491
obj.nix_handle, name, datatype));
95-
obj.propsCache.lastUpdate = 0;
9692
end;
9793

9894
function p = create_property_with_value(obj, name, val)
@@ -101,7 +97,6 @@
10197
end;
10298
p = nix.Property(nix_mx('Section::createPropertyWithValue', ...
10399
obj.nix_handle, name, val));
104-
obj.propsCache.lastUpdate = 0;
105100
end;
106101

107102
function delCheck = delete_property(obj, del)
@@ -113,7 +108,6 @@
113108
delID = del;
114109
end;
115110
delCheck = nix_mx('Section::deleteProperty', obj.nix_handle, delID);
116-
obj.propsCache.lastUpdate = 0;
117111
end;
118112

119113
function retObj = open_property(obj, id_or_name)
@@ -122,15 +116,8 @@
122116
end;
123117

124118
function props = get.allProperties(obj)
125-
%-- if a value in a property is updated, this will not
126-
%-- update the lastUpdate of the propertyCache of
127-
%-- a loaded section. Therefore caching of the properties
128-
%-- of a section is disabled by always resetting the lastUpdate
129-
obj.propsCache.lastUpdate = 0;
130-
131-
[obj.propsCache, props] = nix.Utils.fetchPropList(obj.updatedAt, ...
132-
'Section::properties', obj.nix_handle, obj.propsCache);
133-
end
119+
props = nix_mx('Section::properties', obj.nix_handle);
120+
end;
134121

135122
function p_map = get.allPropertiesMap(obj)
136123
p_map = containers.Map();
@@ -139,9 +126,7 @@
139126
for i=1:length(props)
140127
p_map(props{i}.name) = cell2mat(props{i}.values);
141128
end
142-
end
129+
end;
143130

144131
end
145-
146132
end
147-

+nix/Utils.m

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99
end;
1010
end;
1111

12-
function [currCache, retCell] = fetchPropList(currUpdatedAt, nixMxFunc, handle, currCache)
13-
if currCache.lastUpdate ~= currUpdatedAt
14-
currCache.data = nix_mx(nixMxFunc, handle);
15-
currCache.lastUpdate = currUpdatedAt;
16-
end;
17-
retCell = currCache.data;
18-
end;
19-
2012
function [currCache, retCell] = fetchObj(currUpdatedAt, nixMxFunc, handle, currCache, objConstructor)
2113
if currCache.lastUpdate ~= currUpdatedAt
2214
sh = nix_mx(nixMxFunc, handle);

0 commit comments

Comments
 (0)