Alps
2.0.2
|
This is the class serves as a holder for a set of parameters. More...
#include <AlpsParameterBase.h>
Public Member Functions | |
Pure virtual functions that must be defined for each parameter set. | |
If the user creates a new parameter set, she must define these two methods for the class. | |
virtual void | createKeywordList ()=0 |
Method for creating the list of keyword looked for in the parameter file. More... | |
virtual void | setDefaultEntries ()=0 |
Method for setting the default values for the parameters. More... | |
Pack and unpack | |
virtual void | pack (AlpsEncoded &buf) |
Pack the parameter set into the buffer. More... | |
virtual void | unpack (AlpsEncoded &buf) |
Unpack the parameter set from the buffer. More... | |
void | setEntry (const AlpsParameter key, const char *val) |
First, there is the assignment operator that sets the whole parameter set at once. More... | |
void | readFromStream (std::istream &parstream) |
Read the parameters from the stream specified in the argument. More... | |
void | readFromFile (const char *paramfile) |
Read parameters from a file. More... | |
void | readFromArglist (const int argnum, const char *const *arglist) |
Read parameters from the command line. More... | |
void | writeToStream (std::ostream &outstream) const |
Write keyword-value pairs to the stream specified in the argument. More... | |
AlpsParameterSet (int c, int i, int d, int s, int sa) | |
The constructor allocate memory for parameters. More... | |
virtual | ~AlpsParameterSet () |
The destructor deletes all data members. More... | |
Protected Attributes | |
Data members. All of them are protected. | |
std::vector< std::pair< std::string, AlpsParameter > > | keys_ |
The keyword, parameter pairs. More... | |
std::string | prefix_ |
Prefix to be used for looking up parameters. More... | |
std::vector< std::string > | obsoleteKeys_ |
list of obsolete keywords. More... | |
bool * | bpar_ |
The bool parameters. More... | |
int * | ipar_ |
The integer parameters. More... | |
double * | dpar_ |
The double parameters. More... | |
std::string * | spar_ |
The string (actually, std::string) parameters. More... | |
int | numSa_ |
The "vector of string" parameters. More... | |
std::vector< std::string > * | sapar_ |
This is the class serves as a holder for a set of parameters.
For example, Alps stores has a parameter set for each process. Of course, the user can use this class for her own parameters. To use this class the user must
createKeywordList()
and setDefaultEntries()
. For an example look at the file AlpsParams.cpp
. Essentially, the first method defines what keywords should be looked for in the parameter file, and if one is found which parameter should take the corresponding value; the other method specifies the default values for each parameter. After this the user can read in the parameters from a file, she can set/access the parameters in the parameter set.
Definition at line 138 of file AlpsParameterBase.h.
|
inline |
The constructor allocate memory for parameters.
Definition at line 251 of file AlpsParameterBase.h.
|
inlinevirtual |
The destructor deletes all data members.
Definition at line 262 of file AlpsParameterBase.h.
|
pure virtual |
Method for creating the list of keyword looked for in the parameter file.
Implemented in AlpsParams, AbcParams, AbcParams, AbcParams, and KnapParams.
|
pure virtual |
Method for setting the default values for the parameters.
Implemented in AlpsParams, AbcParams, AbcParams, AbcParams, and KnapParams.
|
inlinevirtual |
Pack the parameter set into the buffer.
Reimplemented in AlpsParams, AbcParams, AbcParams, AbcParams, and KnapParams.
Definition at line 190 of file AlpsParameterBase.h.
|
inlinevirtual |
Unpack the parameter set from the buffer.
Reimplemented in AlpsParams, AbcParams, AbcParams, AbcParams, and KnapParams.
Definition at line 195 of file AlpsParameterBase.h.
|
inline |
First, there is the assignment operator that sets the whole parameter set at once.
Individual members of the parameter set can be set for using the overloaded setEntry() method. Using the example in the class documentation the user can set a parameter with the "<code>param.setEntry(USER_par::parameter_name, param_value)</code>" expression.
Definition at line 213 of file AlpsParameterBase.h.
void AlpsParameterSet::readFromStream | ( | std::istream & | parstream | ) |
Read the parameters from the stream specified in the argument.
The stream is interpreted as a lines separated by newline characters. The first word on each line is tested for match with the keywords specified in the createKeywordList() method. If there is a match then the second word will be interpreted as the value for the corresponding parameter. Any further words on the line are discarded. Every non-matching line is discarded.
If the keyword corresponds to a non-array parameter then the new value simply overwrites the old one. Otherwise, i.e., if it is a StringArrayPar, the value is appended to the list of strings in that array.
void AlpsParameterSet::readFromFile | ( | const char * | paramfile | ) |
Read parameters from a file.
void AlpsParameterSet::readFromArglist | ( | const int | argnum, |
const char *const * | arglist | ||
) |
Read parameters from the command line.
void AlpsParameterSet::writeToStream | ( | std::ostream & | outstream | ) | const |
Write keyword-value pairs to the stream specified in the argument.
Each keyword-value pair is separated by a newline character.
|
protected |
The keyword, parameter pairs.
Used when the parameter file is read in.
Definition at line 144 of file AlpsParameterBase.h.
|
protected |
Prefix to be used for looking up parameters.
Definition at line 148 of file AlpsParameterBase.h.
|
protected |
list of obsolete keywords.
If any of these is encountered a warning is printed.
Definition at line 152 of file AlpsParameterBase.h.
|
protected |
The bool parameters.
Definition at line 155 of file AlpsParameterBase.h.
|
protected |
The integer parameters.
Definition at line 158 of file AlpsParameterBase.h.
|
protected |
The double parameters.
Definition at line 161 of file AlpsParameterBase.h.
|
protected |
The string (actually, std::string) parameters.
Definition at line 164 of file AlpsParameterBase.h.
|
protected |
The "vector of string" parameters.
Definition at line 167 of file AlpsParameterBase.h.
|
protected |
Definition at line 168 of file AlpsParameterBase.h.