@@ -172,6 +172,21 @@ void PropertyTreeHelpers::populate(std::vector<ConfigParamSpec> const& schema,
172172 }
173173}
174174
175+ template <typename T>
176+ auto replaceLabels (LabeledArray<T>& input, LabeledArray<T>&& spec)
177+ {
178+ if (!input.getLabelsCols ().empty () || !input.getLabelsRows ().empty ()) {
179+ return false ;
180+ }
181+ if (spec.getLabelsCols ().empty () == false ) {
182+ input.replaceLabelsCols (spec.getLabelsCols ());
183+ }
184+ if (spec.getLabelsRows ().empty () == false ) {
185+ input.replaceLabelsRows (spec.getLabelsRows ());
186+ }
187+ return true ;
188+ }
189+
175190void PropertyTreeHelpers::populate (std::vector<ConfigParamSpec> const & schema,
176191 boost::property_tree::ptree& pt,
177192 boost::property_tree::ptree const & in,
@@ -216,11 +231,32 @@ void PropertyTreeHelpers::populate(std::vector<ConfigParamSpec> const& schema,
216231 case VariantType::Array2DInt:
217232 case VariantType::Array2DFloat:
218233 case VariantType::Array2DDouble:
219- case VariantType::LabeledArrayInt:
220- case VariantType::LabeledArrayFloat:
221- case VariantType::LabeledArrayDouble:
222234 pt.put_child (key, *it);
223235 break ;
236+ case VariantType::LabeledArrayInt: {
237+ auto v = labeledArrayFromBranch<int >(it.value ());
238+ if (!replaceLabels (v, spec.defaultValue .get <LabeledArray<int >>())) {
239+ pt.put_child (key, *it);
240+ } else {
241+ pt.put_child (key, labeledArrayToBranch (std::move (v)));
242+ }
243+ }; break ;
244+ case VariantType::LabeledArrayFloat: {
245+ auto v = labeledArrayFromBranch<float >(it.value ());
246+ if (!replaceLabels (v, spec.defaultValue .get <LabeledArray<float >>())) {
247+ pt.put_child (key, *it);
248+ } else {
249+ pt.put_child (key, labeledArrayToBranch (std::move (v)));
250+ }
251+ }; break ;
252+ case VariantType::LabeledArrayDouble: {
253+ auto v = labeledArrayFromBranch<double >(it.value ());
254+ if (!replaceLabels (v, spec.defaultValue .get <LabeledArray<double >>())) {
255+ pt.put_child (key, *it);
256+ } else {
257+ pt.put_child (key, labeledArrayToBranch (std::move (v)));
258+ }
259+ }; break ;
224260 case VariantType::Unknown:
225261 case VariantType::Empty:
226262 default :
0 commit comments