Alps  2.0.2
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:
+ Collaboration diagram for AlpsParameterSet:

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_
 

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

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.

Constructor & Destructor Documentation

◆ AlpsParameterSet()

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

The constructor allocate memory for parameters.

Definition at line 251 of file AlpsParameterBase.h.

◆ ~AlpsParameterSet()

virtual AlpsParameterSet::~AlpsParameterSet ( )
inlinevirtual

The destructor deletes all data members.

Definition at line 262 of file AlpsParameterBase.h.

Member Function Documentation

◆ createKeywordList()

virtual void AlpsParameterSet::createKeywordList ( )
pure virtual

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

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

◆ setDefaultEntries()

virtual void AlpsParameterSet::setDefaultEntries ( )
pure virtual

Method for setting the default values for the parameters.

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

◆ pack()

virtual void AlpsParameterSet::pack ( AlpsEncoded buf)
inlinevirtual

Pack the parameter set into the buffer.

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

Definition at line 190 of file AlpsParameterBase.h.

◆ unpack()

virtual void AlpsParameterSet::unpack ( AlpsEncoded buf)
inlinevirtual

Unpack the parameter set from the buffer.

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

Definition at line 195 of file AlpsParameterBase.h.

◆ setEntry()

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 213 of file AlpsParameterBase.h.

◆ readFromStream()

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.

◆ readFromFile()

void AlpsParameterSet::readFromFile ( const char *  paramfile)

Read parameters from a file.

◆ readFromArglist()

void AlpsParameterSet::readFromArglist ( const int  argnum,
const char *const *  arglist 
)

Read parameters from the command line.

◆ writeToStream()

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

◆ keys_

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 144 of file AlpsParameterBase.h.

◆ prefix_

std::string AlpsParameterSet::prefix_
protected

Prefix to be used for looking up parameters.

Definition at line 148 of file AlpsParameterBase.h.

◆ obsoleteKeys_

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

list of obsolete keywords.

If any of these is encountered a warning is printed.

Definition at line 152 of file AlpsParameterBase.h.

◆ bpar_

bool* AlpsParameterSet::bpar_
protected

The bool parameters.

Definition at line 155 of file AlpsParameterBase.h.

◆ ipar_

int* AlpsParameterSet::ipar_
protected

The integer parameters.

Definition at line 158 of file AlpsParameterBase.h.

◆ dpar_

double* AlpsParameterSet::dpar_
protected

The double parameters.

Definition at line 161 of file AlpsParameterBase.h.

◆ spar_

std::string* AlpsParameterSet::spar_
protected

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

Definition at line 164 of file AlpsParameterBase.h.

◆ numSa_

int AlpsParameterSet::numSa_
protected

The "vector of string" parameters.

Definition at line 167 of file AlpsParameterBase.h.

◆ sapar_

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

Definition at line 168 of file AlpsParameterBase.h.


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