Skip to content

ParametersTable

Clifford Bohm edited this page Aug 28, 2017 · 4 revisions

The following is a more detailed description of the ParametersTable class. This Page assumes you have read the pages on Parameters and Parameters Name Space.

This more detailed description describes how parameters are implemented in MABE, but ParametersLinks (PLs) provides an interface to Parameters, and so unless you are doing something extreme, the following information should not be anything you need to worry about.

ParametersTable is a class which allows MABE to store and manipulate parameters. At the core, a ParametersTable contains a look up table of parameter names to values.
Parameters are designed to be fast when reading at the expense of being relatively slow for some write operations.

Parameter Value Types

Values in parameter tables can be bool, string, int or double.

set and lookup

If you have a parameter table called PT, you can set a value in that table with:

PT.setParameter("ParameterName",value);

The type of the parameter is determined by value.

You can read a value with one of the lookup functions. You must use the lookup function which matches the parameter type. To lookup a integer, you would use:

PT.lookupInt("ParameterName");

Parameter Trees

Parameters tables contain links to other parameters tables. Each parameter table has a link for one parent and a list of undetermined size of links for children.
A ParameterTable with no parent is a root table.
Every ParameterTable in a Parameter Tree has a name. The root tables name is "" (a blank string). each child of a root table will have a name which ends with "::". Children of non-root tables will have names that start with the parents name. In the example below, wolf::nice:: is a child of wolf::

Parameter Inheritance

Parameters may be set in any table. If a parameter is looked up in a table which does not have a value for that parameter, a search will be preformed up the tree until the value is found. When the value is found, a link will be established so that future lookups will be faster. This does mean that some changes to tables (in particular adding and removing parameters) require additional time to insure that the links are all correct.

Adding a table to a parameters tree

When you add a new table to a parametes tree, any intermediate tables are automaticly generated. In the example above, if I only had the root table, and I added wolf::nice::, woof:: would also be added. Tables will be automaticly generated if they are needed.

lookups from the root table

You can access any part of the tree from the root. Let us assume we had a ParametersTable called root which was a root (no parent).

root.setParameter("GLOBAL-popSize",100,"dogs::big::");
root.lookupInt("GLOBAL-popSize","dogs::big::")

This would set popSize = 100 in the table called "dogs::big::" and then lookup this value.

register_parameter

Note that when you are writing code, you generally will not use ParameterTable::register_parameter, but instead will use Parameters::register_parameter. see Adding Parameters to Code.

register_parameter is a function used to add parameters to parameters trees.

register_parameter(const string& name, const T& default_value, const string& documentation)

register_parameter creates a parameter called name, set to default_value in both the parameters table used to call it and the root table.

More Features

Every Parameters Table has a few additional features.

Every table has a pointer to the root table for that tree
Every table has a pointer to a single lookup table which relates each name space and it's table (parametersTablesRegistry).
This means that as long as you have access to any part of a parameters tree, you can quickly get anywhere else.
a unique ID
this integer is used to make working with and deleting child tables faster
Every table has a pointer to a single lookup table which relates parameter with it's documentation (parameter Documentation)
This is used when files are written.
Clone this wiki locally