- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
AlpsParameterSet Class Referenceabstract

This is the class serves as a holder for a set of parameters. More...

`#include <AlpsParameterBase.h>`

Inheritance diagram for AlpsParameterSet:
[legend]

## Public Member Functions
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...
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...

## Protected Attributes
Data members. All of them are protected.
std::vector< std::pair < std::string, AlpsParameter > > | keys_
| The keyword, parameter pairs. 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_
| The keyword, parameter pairs. More...

## Detailed Description

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

- first derive a subclass with the names of the parameters (see, e.g., AlpsParams.)
- then define the member functions `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 134 of file AlpsParameterBase.h.

## Constructor & Destructor Documentation

AlpsParameterSet::AlpsParameterSet | ( | int | c,
|  | int | i,
|  | int | d,
|  | int | s,
|  | int | sa
| ) |  |
| inline

The constructor allocate memory for parameters.

Definition at line 243 of file AlpsParameterBase.h.

virtual AlpsParameterSet::~AlpsParameterSet | ( |  | ) |
| inline virtual

The destructor deletes all data members.

Definition at line 253 of file AlpsParameterBase.h.

## Member Function Documentation

virtual void AlpsParameterSet::createKeywordList | ( |  | ) |
| pure virtual

Method for creating the list of keyword looked for in the parameter file.

Implemented in AlpsParams, BlisParams, BlisParams, AbcParams, VrpParams, and KnapParams.

virtual void AlpsParameterSet::setDefaultEntries | ( |  | ) |
| pure virtual

Method for setting the default values for the parameters.

Implemented in AlpsParams, BlisParams, BlisParams, AbcParams, VrpParams, and KnapParams.

virtual void AlpsParameterSet::pack | ( | AlpsEncoded & | buf | ) |
| inline virtual

Pack the parameter set into the buffer.

Reimplemented in AlpsParams, BlisParams, BlisParams, AbcParams, KnapParams, and VrpParams.

Definition at line 182 of file AlpsParameterBase.h.

virtual void AlpsParameterSet::unpack | ( | AlpsEncoded & | buf | ) |
| inline virtual

Unpack the parameter set from the buffer.

Reimplemented in AlpsParams, BlisParams, BlisParams, AbcParams, KnapParams, and VrpParams.

Definition at line 187 of file AlpsParameterBase.h.

void AlpsParameterSet::setEntry | ( | const AlpsParameter | key,
|  | const char * | val
| ) |  |
| 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 205 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.

## Member Data Documentation

std::vector< std::pair<std::string, AlpsParameter> > AlpsParameterSet::keys_
| protected

The keyword, parameter pairs.

Used when the parameter file is read in.

Definition at line 140 of file AlpsParameterBase.h.

std::vector<std::string> AlpsParameterSet::obsoleteKeys_
| protected

list of obsolete keywords.

If any of these is encountered a warning is printed.

Definition at line 144 of file AlpsParameterBase.h.

bool* AlpsParameterSet::bpar_
| protected

The bool parameters.

Definition at line 147 of file AlpsParameterBase.h.

int* AlpsParameterSet::ipar_
| protected

The integer parameters.

Definition at line 150 of file AlpsParameterBase.h.

double* AlpsParameterSet::dpar_
| protected

The double parameters.

Definition at line 153 of file AlpsParameterBase.h.

std::string* AlpsParameterSet::spar_
| protected

The string (actually, std::string) parameters.

Definition at line 156 of file AlpsParameterBase.h.

int AlpsParameterSet::numSa_
| protected

The "vector of string" parameters.

Definition at line 159 of file AlpsParameterBase.h.

std::vector<std::string>* AlpsParameterSet::sapar_
| protected

The keyword, parameter pairs.

Used when the parameter file is read in.

Definition at line 160 of file AlpsParameterBase.h.

The documentation for this class was generated from the following file:

- /tmp/CHiPPS-Blis-0.94.3/Alps/src/AlpsParameterBase.h