G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsOptionList Class Reference

Detailed Description

Class which holds a list of parameters/options, and provides easy access to them.

Every parameter has a unique label, and its value can be retrieved using that.

+ Inheritance diagram for gsOptionList:

Classes

struct  OptionListEntry
 

Public Types

enum  updateType
 Options for gsOptionList::update.
 

Public Member Functions

void addInt (const std::string &label, const std::string &desc, const index_t &value)
 Adds a option named label, with description desc and value value. More...
 
void addMultiInt (const std::string &label, const std::string &desc, const std::vector< index_t > &values)
 Adds an option-group gn containing values of a std::vector. More...
 
void addReal (const std::string &label, const std::string &desc, const Real &value)
 Adds a option named label, with description desc and value value. More...
 
void addString (const std::string &label, const std::string &desc, const std::string &value)
 Adds a option named label, with description desc and value value. More...
 
void addSwitch (const std::string &label, const std::string &desc, const bool &value)
 Adds a option named label, with description desc and value value. More...
 
index_t askInt (const std::string &label, const index_t &value=0) const
 Reads value for option label from options. More...
 
Real askReal (const std::string &label, const Real &value=0) const
 Reads value for option label from options. More...
 
std::string askString (const std::string &label, const std::string &value="") const
 Reads value for option label from options. More...
 
bool askSwitch (const std::string &label, const bool &value=false) const
 Reads value for option label from options. More...
 
std::vector< OptionListEntrygetAllEntries () const
 Provides a list of all entries as vector of gsOptionList::OptionListEntry structs.
 
gsOptionList getGroup (const std::string &gn) const
 Creates a new gsOptionList, where only the options from the group gn are taken. In the result, the groupname and the corresponding dot are removed. More...
 
const index_tgetInt (const std::string &label) const
 Reads value for option label from options. More...
 
std::vector< index_tgetMultiInt (const std::string &gn) const
 Reads values of an option-group gn into a std::vector. More...
 
std::vector< Real > getMultiReal (const std::string &gn) const
 Reads values of an option-group gn into a std::vector. More...
 
std::vector< std::string > getMultiString (const std::string &gn) const
 Reads values of an option-group gn into a std::vector. More...
 
Real getReal (const std::string &label) const
 Reads value for option label from options. More...
 
std::string getString (const std::string &label) const
 Reads value for option label from options. More...
 
bool getSwitch (const std::string &label) const
 Reads value for option label from options. More...
 
bool hasGlobals () const
 Checks if there are labels that do not belong to a group. More...
 
bool hasGroup (const std::string &gn) const
 Checks if there are labels that belong to the group gn. More...
 
std::ostream & print (std::ostream &os) const
 Prints this list of options to stream os.
 
void remove (const std::string &label)
 Removes the option named label (if it exists).
 
void setInt (const std::string &label, const index_t &value)
 Sets an existing option label to be equal to value. More...
 
void setReal (const std::string &label, const Real &value)
 Sets an existing option label to be equal to value. More...
 
void setString (const std::string &label, const std::string &value)
 Sets an existing option label to be equal to value. More...
 
void setSwitch (const std::string &label, const bool &value)
 Sets an existing option label to be equal to value. More...
 
size_t size () const
 Returns the length of this list of options.
 
void swap (gsOptionList &other)
 Swaps contents.
 
void toggleSwitch (const std::string &label)
 Toggles switch ( boolean )
 
void update (const gsOptionList &other, updateType type=ignoreIfUnknown)
 Updates the object using the data from other. More...
 
gsOptionList wrapIntoGroup (const std::string &gn) const
 Creates a new gsOptionList where all labels are wrapped into a groupname gn. More...
 

Private Member Functions

bool exists (const std::string &label) const
 Returns true iff an option named label exists.
 
std::string getInfo (const std::string &label) const
 Gives information regarding the option named label.
 
bool isInt (const std::string &label) const
 Returns true iff an int named label exists.
 
bool isReal (const std::string &label) const
 Returns true iff a real named label exists.
 
bool isString (const std::string &label) const
 Returns true iff a string named label exists.
 
bool isSwitch (const std::string &label) const
 Returns true iff a switch named label exists.
 

Private Attributes

IntTable m_ints
 Integer-valued options/parameters.
 
RealTable m_reals
 Real-valued options/parameters.
 
StringTable m_strings
 String-valued options/parameters.
 
SwitchTable m_switches
 Switches (ON/OFF) options/parameters.
 

Member Function Documentation

void addInt ( const std::string &  label,
const std::string &  desc,
const index_t value 
)

Adds a option named label, with description desc and value value.

If an option with label already exists with the same type, the function overwrites it. If it has another type, the function throws.

void addMultiInt ( const std::string &  label,
const std::string &  desc,
const std::vector< index_t > &  values 
)

Adds an option-group gn containing values of a std::vector.

If gn is not found, the function throws.

void addReal ( const std::string &  label,
const std::string &  desc,
const Real &  value 
)

Adds a option named label, with description desc and value value.

If an option with label already exists with the same type, the function overwrites it. If it has another type, the function throws.

void addString ( const std::string &  label,
const std::string &  desc,
const std::string &  value 
)

Adds a option named label, with description desc and value value.

If an option with label already exists with the same type, the function overwrites it. If it has another type, the function throws.

void addSwitch ( const std::string &  label,
const std::string &  desc,
const bool &  value 
)

Adds a option named label, with description desc and value value.

If an option with label already exists with the same type, the function overwrites it. If it has another type, the function throws.

index_t askInt ( const std::string &  label,
const index_t value = 0 
) const

Reads value for option label from options.

If label is not found, it defaults to value (otherwise value is not used).

gsOptionList::Real askReal ( const std::string &  label,
const Real &  value = 0 
) const

Reads value for option label from options.

If label is not found, it defaults to value (otherwise value is not used).

std::string askString ( const std::string &  label,
const std::string &  value = "" 
) const

Reads value for option label from options.

If label is not found, it defaults to value (otherwise value is not used).

bool askSwitch ( const std::string &  label,
const bool &  value = false 
) const

Reads value for option label from options.

If label is not found, it defaults to value (otherwise value is not used).

gsOptionList getGroup ( const std::string &  gn) const

Creates a new gsOptionList, where only the options from the group gn are taken. In the result, the groupname and the corresponding dot are removed.

If the groupname is "IterativeSolver", then a label "InterativeSolver.Tolerance" becomes "Tolerance" and a label "Basis.Degree" is ignored.

const index_t & getInt ( const std::string &  label) const

Reads value for option label from options.

If label is not found, the function throws.

std::vector< index_t > getMultiInt ( const std::string &  gn) const

Reads values of an option-group gn into a std::vector.

If gn is not found, the function throws.

std::vector< gsOptionList::Real > getMultiReal ( const std::string &  gn) const

Reads values of an option-group gn into a std::vector.

If gn is not found, the function throws.

std::vector< std::string > getMultiString ( const std::string &  gn) const

Reads values of an option-group gn into a std::vector.

If gn is not found, the function throws.

gsOptionList::Real getReal ( const std::string &  label) const

Reads value for option label from options.

If label is not found, the function throws.

std::string getString ( const std::string &  label) const

Reads value for option label from options.

If label is not found, the function throws.

bool getSwitch ( const std::string &  label) const

Reads value for option label from options.

If label is not found, the function throws.

bool hasGlobals ( ) const

Checks if there are labels that do not belong to a group.

This is the case if there is a label which does not contain a dot.

bool hasGroup ( const std::string &  gn) const

Checks if there are labels that belong to the group gn.

This is the case if there is a label which starts with the groupname and a dot.

void setInt ( const std::string &  label,
const index_t value 
)

Sets an existing option label to be equal to value.

If label is not found, the function throws.

void setReal ( const std::string &  label,
const Real &  value 
)

Sets an existing option label to be equal to value.

If label is not found, the function throws.

void setString ( const std::string &  label,
const std::string &  value 
)

Sets an existing option label to be equal to value.

If label is not found, the function throws.

void setSwitch ( const std::string &  label,
const bool &  value 
)

Sets an existing option label to be equal to value.

If label is not found, the function throws.

void update ( const gsOptionList other,
gsOptionList::updateType  type = ignoreIfUnknown 
)

Updates the object using the data from other.

Options which do not exist in other, are kept unchanged. Options in other which do not exist in this, are kept unchanged if type is set to gsOptionList::ignoreIfUnknown (default) or are added if type is set to gsOptionList::addIfUnknown.

gsOptionList wrapIntoGroup ( const std::string &  gn) const

Creates a new gsOptionList where all labels are wrapped into a groupname gn.

Wrapping means that the label is prepended with the groupname and a dot. So, the label "Tolerance" wrapped into the group "IterativeSolver" is "InterativeSolver.Tolerance"