I've often come across APIs that allow users to get and set various parameters that control a module's operation. I now find myself contemplating writing yet another properties API but don't want to reinvent the wheel.
The following is typical basic client code:
setInt("bitrate", 1000);
setEnum("mode", MODE_FAST);
setStr("output file", "music.mp3");
Frequently there are dozens of parameters that can be set and such property sets are often under continuous development.
Some APIs are smarter than others, more advanced features being:
- Hierarchical grouping of properties
- Enumeration of properties
- Numeric parameters with enforced minima and maxima
- Default parameter values
- Settings that are enabled, disabled or read only
- Dynamic parameters - settings that appear, disappear, have min/max set, become enabled, disabled or read only depending on other parameters' state.
- Properties accessed via UUID key rather than textual name
Beyond the C-style accessors in the sample code above, I've come across frameworks that can:
- Read/write properties to file (e.g. XML)
- Read/write settings to Windows Registry
- Interface with system properties APIs like
IPersistPropertyBag
- Have default dumb GUI implementations, e.g. tree-view or list
- Have GUI extensions appropriate to minima/maxima/enabled state reducing repetition in GUI code.
I would love to find a well-designed public library that provides a framework for all of the above but so far have drawn a blank. I'm aware of Boost.PropertyTree but it's only really a skeleton. Are there other portable properties API frameworks that I should be aware of?
std::vector
to be thread safe but it should be easy to write thread safe libraries and implementations using such an API. – Kelila