[parametertree] allow weak reference / sym-links in ParameterTree
There are a couple of use-cases for references in the tree. After a first attempt this issue should collect a proper definition of the requirements and structure the discussion (see also !580 (closed)).
Status quo:
- The
ParameterTree
models a hierarchic structure of sections, similar to a nested dict in python. - Leafs are values, where one particular kind of values is also an array.
- This data-model differs from the often used json-data-model (!), where dicts and arrays can be nested.
Requirements:
- Aliasing a section to another section
- Aliasing a value to another value
- Alias target may be defined after the alias
- An alias should track the value of the target
- Aliasing should work across parses (i.e. an alias defined on the command line should be able to reference a section in a parameter file read later)
- keep compatible to the current API, of course
Open questions:
- Do we need cycles in the tree or can we for this thing to model a DAG?
- in case of cycles, we need to keep track of what is a reference and what not.
- in case of a DAG we have to check for cycles during parsing an bail out in case.
- Do we need to allow modifying values?
- The current
get
method does not allow to modify the internal data, where as theoperator[]
is in my opinion more an internal interface for constructing a tree - if we don't support modification, we might avoid real references by copying values during parsing
- The current
- Do we want to support references as sub-expressions of a value, e.g.
[config]
zslice = 0.3
position = ( 1.0, 10.3, @zslice )
label = "foo".@zslice
- How flexible does the reference need to be?
- There is a proposal for JSON (json-path) using a similar syntax to XPath.
- How to reference relative paths?
- How to reference parents?
- Do we need something like 7th-sibling?
- I tend to to the idea to keep it simple and just use relative and absolute paths.
- Which syntax to we want to use (in the ini-file parser)
- current suggestion is
-
[foo = bar]
for a section alias foo referencing the section bar -
foo = @sec.bar
for a key foo mapping to the key bar in section sec
-
- we might want to unify both and use
[foo = @bar]
- current suggestion is