-
Notifications
You must be signed in to change notification settings - Fork 53
Description
The implementation of scientific default attribute values (i.e. those prescribed as mandatory by the openPMD-standard) is currently relatively ad-hoc, and while it works ok so far, it is neither really flexible nor extensible.
Current situation: Default attributes are set in the constructors of objects. They are set to values that often don't really make sense (e.g., for a 3D grid, setting the axisLabels to {"x"} by default makes no sense). Having these defaults set in the constructor makes the class inflexible to reuse and causes issues in the backends because of duplicate attribute definitions (first the default value, then the user-specified one).
Suggested redesign:
- Separate logic that specifies default values from object model. I imagine that we add a separate logic that collects the standard-defined attribute logic in one central place. This could be an abstract class, implemented by multiple derived classes for multiple versions of the standard. The central methods would be something like
virtual readDefaults(Attributable &) = 0;andvirtual writeDefaults(Attributable &) = 0;. - Instead of at construction time, defaults would be written at the time of
Series::close()andIteration::close()(not destructors, that causes too many issues down the road). This would postpone this logic to be as late as possible. The logic could take into consideration the dimensionality of meshes, that are then defined. - Reading defaults would happen at the same time as now (during parsing). It would deal leniently with missing / wrong values, e.g. by just setting the default, or ignoring it.
- The implementation would no longer be based (exclusively) on the class type, but rather on the value of
Attributable::myPath(). This increases reusability of classes.
To avoid merge conflicts, this should start after #1154 has been merged, or at least start based on that branch.