Skip to content

Commit 3a99829

Browse files
committed
fix stale properties value cache
1 parent 20dc256 commit 3a99829

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

+nix/Property.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
end
3131

3232
function [] = set.values(obj, val)
33-
% TODO: the properties cache in the parent nix.Section
34-
% cannot be easily invalidated and will therefore show stale
35-
% values at the moment.
3633
nix_mx('Property::updateValues', obj.nix_handle, val);
3734
obj.valuesCache.lastUpdate = 0;
3835

+nix/Section.m

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
properties(Dependent)
1212
allProperties
13-
allPropertiesMap
13+
%allPropertiesMap
1414
end;
1515

1616
methods
@@ -123,14 +123,19 @@
123123
'Section::properties', obj.nix_handle, obj.propsCache);
124124
end
125125

126-
function p_map = get.allPropertiesMap(obj)
127-
p_map = containers.Map();
128-
props = obj.allProperties;
126+
%-- values has been removed from section.properties due to
127+
%-- stale entries in the section.properties cache when the acutal
128+
%-- properties values are updated. therefore the current mapping
129+
%-- function cannot be used at the moment.
130+
%-- could be refactored at a later moment in time
131+
%function p_map = get.allPropertiesMap(obj)
132+
% p_map = containers.Map();
133+
% props = obj.allProperties;
129134

130-
for i=1:length(props)
131-
p_map(props{i}.name) = cell2mat(props{i}.values);
132-
end
133-
end
135+
% for i=1:length(props)
136+
% p_map(props{i}.name) = cell2mat(props{i}.values);
137+
% end
138+
%end
134139

135140
end
136141

src/nixsection.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,16 @@ void properties(const extractor &input, infusor &output)
3838
for (size_t i = 0; i < properties.size(); i++) {
3939

4040
nix::Property pr = properties[i];
41-
std::vector<nix::Value> values = pr.values();
42-
43-
mxArray *mx_values = make_mx_array(values);
4441

4542
struct_builder sb({ 1 }, {
46-
"name", "id", "definition", "mapping", "unit", "values"
43+
"name", "id", "definition", "mapping", "unit"
4744
});
4845

4946
sb.set(pr.name());
5047
sb.set(pr.id());
5148
sb.set(pr.definition());
5249
sb.set(pr.mapping());
5350
sb.set(pr.unit());
54-
sb.set(mx_values);
5551

5652
mxSetCell(lst, i, sb.array());
5753
}

tests/TestSection.m

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@
130130

131131
p1 = trial.allProperties{1};
132132
assert(strcmp(p1.name, 'ExperimentalCondition'));
133-
assert(p1.values{1} == 1);
134-
135-
assert(trial.allPropertiesMap('ExperimentalCondition') == p1.values{1});
136133

137134
disp(f.sections{3}.allProperties);
138135

@@ -161,21 +158,21 @@
161158

162159
tmp = s.create_property_with_value('doubleProperty', {5, 6, 7, 8});
163160
assert(strcmp(s.allProperties{1}.name, 'doubleProperty'));
164-
assert(s.allProperties{1}.values{1} == 5);
165-
assert(size(s.allProperties{1}.values, 2) == 4);
161+
assert(s.open_property(s.allProperties{1}.id).values{1}.value == 5);
162+
assert(size(s.open_property(s.allProperties{1}.id).values, 1) == 4);
166163
assert(strcmpi(tmp.datatype,'double'));
167164

168165
tmp = s.create_property_with_value('stringProperty', {'this', 'has', 'strings'});
169166
assert(strcmp(s.allProperties{2}.name, 'stringProperty'));
170-
assert(strcmp(s.allProperties{2}.values{1}, 'this'));
171-
assert(size(s.allProperties{2}.values, 2) == 3);
167+
assert(strcmp(s.open_property(s.allProperties{2}.id).values{1}.value, 'this'));
168+
assert(size(s.open_property(s.allProperties{2}.id).values, 1) == 3);
172169
assert(strcmpi(tmp.datatype, 'string'));
173170

174171
tmp = s.create_property_with_value('booleanProperty', {true, false, true});
175172
assert(strcmp(s.allProperties{3}.name, 'booleanProperty'));
176-
assert(s.allProperties{3}.values{1});
177-
assert(~s.allProperties{3}.values{2});
178-
assert(size(s.allProperties{3}.values, 2) == 3);
173+
assert(s.open_property(s.allProperties{3}.id).values{1}.value);
174+
assert(~s.open_property(s.allProperties{3}.id).values{2}.value);
175+
assert(size(s.open_property(s.allProperties{3}.id).values, 1) == 3);
179176
assert(strcmpi(tmp.datatype, 'bool'));
180177
end
181178

0 commit comments

Comments
 (0)