Skip to content

Commit b4e0e45

Browse files
committed
Merge pull request #89 from mpsonntag/fixSecVal
enablePropertiesMap
2 parents 7d5be24 + 5bc00b2 commit b4e0e45

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

+nix/Section.m

Lines changed: 16 additions & 15 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
@@ -122,25 +122,26 @@
122122
end;
123123

124124
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+
125131
[obj.propsCache, props] = nix.Utils.fetchPropList(obj.updatedAt, ...
126132
'Section::properties', obj.nix_handle, obj.propsCache);
127133
end
128134

129-
%-- values has been removed from section.properties due to
130-
%-- stale entries in the section.properties cache when the acutal
131-
%-- properties values are updated. therefore the current mapping
132-
%-- function cannot be used at the moment.
133-
%-- could be refactored at a later moment in time
134-
%function p_map = get.allPropertiesMap(obj)
135-
% p_map = containers.Map();
136-
% props = obj.allProperties;
137-
138-
% for i=1:length(props)
139-
% p_map(props{i}.name) = cell2mat(props{i}.values);
140-
% end
141-
%end
135+
function p_map = get.allPropertiesMap(obj)
136+
p_map = containers.Map();
137+
props = obj.allProperties;
138+
139+
for i=1:length(props)
140+
p_map(props{i}.name) = cell2mat(props{i}.values);
141+
end
142+
end
142143

143144
end
144-
145+
145146
end
146147

src/nixsection.cc

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

3939
nix::Property pr = properties[i];
40+
std::vector<nix::Value> values = pr.values();
41+
42+
mxArray *mx_values = make_mx_array(values);
4043

4144
struct_builder sb({ 1 }, {
42-
"name", "id", "definition", "mapping", "unit"
45+
"name", "id", "definition", "mapping", "unit", "values"
4346
});
4447

4548
sb.set(pr.name());
4649
sb.set(pr.id());
4750
sb.set(pr.definition());
4851
sb.set(pr.mapping());
4952
sb.set(pr.unit());
53+
sb.set(mx_values);
5054

5155
mxSetCell(lst, i, sb.array());
5256
}

tests/TestSection.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@
158158

159159
tmp = s.create_property_with_value('doubleProperty1', [5, 6, 7, 8]);
160160
assert(strcmp(s.allProperties{end}.name, 'doubleProperty1'));
161+
assert(s.allProperties{end}.values{1} == 5);
162+
assert(size(s.allProperties{end}.values, 2) == 4);
161163
assert(s.open_property(s.allProperties{end}.id).values{1}.value == 5);
162164
assert(size(s.open_property(s.allProperties{end}.id).values, 1) == 4);
163165
assert(strcmpi(tmp.datatype,'double'));
@@ -176,12 +178,17 @@
176178

177179
tmp = s.create_property_with_value('stringProperty2', {'this', 'has', 'strings'});
178180
assert(strcmp(s.allProperties{end}.name, 'stringProperty2'));
181+
assert(strcmp(s.allProperties{end}.values{1}, 'this'));
182+
assert(size(s.allProperties{end}.values, 2) == 3);
179183
assert(strcmp(s.open_property(s.allProperties{end}.id).values{1}.value, 'this'));
180184
assert(size(s.open_property(s.allProperties{end}.id).values, 1) == 3);
181185
assert(strcmpi(tmp.datatype, 'char'));
182186

183187
tmp = s.create_property_with_value('booleanProperty1', [true, false, true]);
184188
assert(strcmp(s.allProperties{end}.name, 'booleanProperty1'));
189+
assert(s.allProperties{end}.values{1});
190+
assert(~s.allProperties{end}.values{2});
191+
assert(size(s.allProperties{end}.values, 2) == 3);
185192
assert(s.open_property(s.allProperties{end}.id).values{1}.value);
186193
assert(~s.open_property(s.allProperties{end}.id).values{2}.value);
187194
assert(size(s.open_property(s.allProperties{end}.id).values, 1) == 3);

0 commit comments

Comments
 (0)