Blockstructured Adaptive Mesh Refinement in object-oriented C++
#include "stl_CompConf.h"
#include "string_CompConf.h"
#include "IO/mutator.h"
Include dependency graph for read-parameters.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Functions | |
template<class T> void | AddVar (MutableVars &MV, const string &name, T &v) |
template<class T> void | AddVar (MutableVars &MV, const char *name, T &v) |
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 ...
x 0.123456 ... A <data of A>
Definition in file read-parameters.h.
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04