This simple C++ package provides convenient capabilites to read parameter values from a stream.
Purpose: say you have a number of numerical parameters declared in your program, i.e. an instance of a class for which you want sometimes to read in a different value than the predefined one. Then you could set up a huge parameter file which is scanned at startup time and where you give a value for each variable you want to be able to change sometimes. This is very errorprone, because you have to remember the ordering of the variables, the parameter file is not well readable (you cannot associate values with variables) and is larger then it has to be.
A better solution is the following: You give an unique name ( a string) to every variable you declare and want to be changeable. The parameterfile then contains only the names and values of the variables that are really subject to changes, the ordering does not matter, and you may easily read your parameter files. The only thing you have to do is to define operator >> for each class type you want to read in.
The class that achieves this is MutableVars: you add the names and references to a variable you want to be mutable, and then you may read in parameter files. How does this look like in a piece of code?
MutableVars MV; // define one instance of the bookkeeping class double x; myclass A; // a variable of some class readable with >> A AddVar(MV, "x",x); // add x to database AddVar(MV, "A",A); // add A to database ... MV.ReadValues(param_file); // read a parameter file ...
In the parameter file, you may (but do not have to!!) write the following:
x 0.123456 ... A <data of A>
where data of A is what you would use when you want to read A directly: cin >> A;