Configs - lms-org/lms GitHub Wiki
Configs are usual std::map<std::string, std::string>
that contain key-value
pairs. While keys are always considered to be strings, the value can be
interpreted as int, bool, float or a list of those.
Configs get loaded during framework startup and get updated whenever their
corresponding files changes. They can be accessed with config()
inside
modules.
Module configs can be written in XML or in LCONF files.
framework.xml
<framework>
<module>
<name>my_module</name>
<!-- This is a config named 'default' -->
<config>
<width>300</width>
<isFloat>true</isFloat>
<pixel>
<x>100</x>
</pixel>
</config>
<!-- This is a config named 'sensor' -->
<config name="sensor">
<sensorList>PROXIMITY,GPS,MOUSE</sensorList>
</config>
<!-- This is a config named 'default'.
The content is loaded from another file.
Specifying a config with the same name twice
results in overwriting keys. -->
<config include="format.lconf">
</framework>
format.lconf
format = RGB
gain = 0.9
int width =
config().get<int>("width"); // == 300
bool isFloat =
config().get<bool>("isFloat"); // == true
float pixelX =
config().get<float>("pixel.x"); // == 100
float pixelY =
config().get<float>("pixel.y", 20); // == 20 (default value)
std::string format =
config().get<std::string>("format"); // == "RGB"
std::vector<std::string> sensorList =
config("sensor").getArray<std::string>("sensorList");
// == {"PROXIMITY", "GPS", "MOUSE"}