|
1 | | -classdef Group |
| 1 | +classdef Group < file.interface.HasProps |
2 | 2 | properties |
3 | 3 | doc; |
4 | 4 | name; |
|
139 | 139 | isempty(obj.attributes); |
140 | 140 | end |
141 | 141 |
|
142 | | - function Prop_Map = getProps(obj) |
143 | | - Prop_Map = containers.Map; |
| 142 | + %% HasProps |
| 143 | + function PropertyMap = getProps(obj) |
| 144 | + PropertyMap = containers.Map; |
144 | 145 | %typed + constrained |
145 | 146 | %should never happen |
146 | 147 |
|
|
161 | 162 | attr_names = strcat(SubData.name, '_', attr_names); |
162 | 163 | Sub_Attribute_Map =... |
163 | 164 | containers.Map(attr_names, num2cell(SubData.attributes)); |
164 | | - Prop_Map = [Prop_Map; Sub_Attribute_Map]; |
| 165 | + PropertyMap = [PropertyMap; Sub_Attribute_Map]; |
165 | 166 | end |
166 | | - Prop_Map(SubData.name) = SubData; |
| 167 | + PropertyMap(SubData.name) = SubData; |
167 | 168 | else |
168 | 169 | if isempty(SubData.name) |
169 | | - Prop_Map(lower(SubData.type)) = SubData; |
| 170 | + PropertyMap(lower(SubData.type)) = SubData; |
170 | 171 | else |
171 | | - Prop_Map(SubData.name) = SubData; |
| 172 | + PropertyMap(SubData.name) = SubData; |
172 | 173 | end |
173 | 174 | end |
174 | 175 | end |
175 | 176 |
|
176 | 177 | %attributes |
177 | 178 | if ~isempty(obj.attributes) |
178 | | - Prop_Map = [Prop_Map;... |
| 179 | + PropertyMap = [PropertyMap;... |
179 | 180 | containers.Map({obj.attributes.name}, num2cell(obj.attributes))]; |
180 | 181 | end |
181 | 182 |
|
182 | 183 | %links |
183 | 184 | if ~isempty(obj.links) |
184 | | - Prop_Map = [Prop_Map;... |
| 185 | + PropertyMap = [PropertyMap;... |
185 | 186 | containers.Map({obj.links.name}, num2cell(obj.links))]; |
186 | 187 | end |
187 | 188 |
|
|
200 | 201 | %if untyped, check if elided |
201 | 202 | % if elided, add to prefix and check all subgroups, attributes and datasets. |
202 | 203 | % otherwise, call getprops and assign to its name. |
203 | | - Sub_Group = obj.subgroups(i); |
204 | | - groupName = Sub_Group.name; |
205 | | - groupType = Sub_Group.type; |
| 204 | + SubGroup = obj.subgroups(i); |
| 205 | + groupName = SubGroup.name; |
| 206 | + groupType = SubGroup.type; |
206 | 207 | if ~isempty(groupType) |
207 | 208 | if isempty(groupName) |
208 | | - Prop_Map(lower(groupType)) = Sub_Group; |
| 209 | + PropertyMap(lower(groupType)) = SubGroup; |
209 | 210 | else |
210 | | - Prop_Map(groupName) = Sub_Group; |
| 211 | + PropertyMap(groupName) = SubGroup; |
211 | 212 | end |
212 | 213 | continue; |
213 | 214 | end |
214 | 215 |
|
215 | | - if ~Sub_Group.elide |
216 | | - Prop_Map(groupName) = Sub_Group; |
| 216 | + if ~SubGroup.elide |
| 217 | + PropertyMap(groupName) = SubGroup; |
217 | 218 | continue; |
218 | 219 | end |
219 | | - |
220 | | - Descendant_Map = Sub_Group.getProps; |
221 | | - descendant_names = keys(Descendant_Map); |
222 | | - for iSubGroup = 1:length(descendant_names) |
223 | | - descendantName = descendant_names{iSubGroup}; |
224 | | - Descendant = Descendant_Map(descendantName); |
| 220 | + |
| 221 | + DescendantMap = SubGroup.getProps(); |
| 222 | + descendantNames = keys(DescendantMap); |
| 223 | + for iSubGroup = 1:length(descendantNames) |
| 224 | + descendantName = descendantNames{iSubGroup}; |
| 225 | + Descendant = DescendantMap(descendantName); |
225 | 226 | % hoist constrained sets to the current |
226 | 227 | % subname. |
227 | 228 | isPossiblyConstrained =... |
228 | 229 | isa(Descendant, 'file.Group')... |
229 | 230 | || isa(Descendant, 'file.Dataset'); |
230 | 231 | isConstrained = isPossiblyConstrained... |
231 | | - && strcmpi(descendantName, Descendant.type)... |
232 | | - && Descendant.isConstrainedSet; |
| 232 | + && all(strcmpi(descendantName, {Descendant.type}))... |
| 233 | + && all(Descendant.isConstrainedSet); |
233 | 234 | if isConstrained |
234 | | - propName = groupName; |
| 235 | + if isKey(PropertyMap, groupName) |
| 236 | + SetType = PropertyMap(groupName); |
| 237 | + else |
| 238 | + SetType = []; |
| 239 | + end |
| 240 | + PropertyMap(groupName) = [SetType, Descendant]; |
235 | 241 | else |
236 | | - propName = [groupName '_' descendantName]; |
237 | | - end |
238 | | - |
239 | | - if isKey(Prop_Map, propName) && ~isConstrained |
240 | | - warning(['Generic group `%s` is currently unsupported '... |
241 | | - 'in MatNwb and is ignored.'], propName); |
242 | | - continue; |
| 242 | + PropertyMap([groupName, '_', descendantName]) = Descendant; |
243 | 243 | end |
244 | | - |
245 | | - Prop_Map(propName) = Descendant_Map(descendantName); |
246 | 244 | end |
247 | 245 | end |
248 | 246 | end |
|
0 commit comments