Teuchos::ParameterList Class Reference

The Teuchos::ParameterList class provides a templated parameter list. More...

#include <Teuchos_ParameterList.hpp>

Collaboration diagram for Teuchos::ParameterList:

[legend]
List of all members.

Public Types

typedef Map::const_iterator ConstIterator
 Parameter container const iterator typedef.

Public Member Functions

Constructors/Destructor.
 ParameterList ()
 Constructor.
 ParameterList (const ParameterList &source)
 Copy Constructor.
 ~ParameterList ()
 Deconstructor.
Set Methods
ParameterListoperator= (const ParameterList &source)
 Replace the current parameter list with source.
template<typename T>
void set (const string &name, T value)
 Sets different types of parameters. The type depends on the second entry.
void set (const string &name, char *value)
 Template specialization for the case when a user sets the parameter with a character string in parenthesis.
void set (const string &name, const char *value)
 Template specialization for the case when a user sets the parameter with a character string in parenthesis.
void set (const string &name, ParameterList value)
 Template specialization for the case when a user sets the parameter with a ParameterList.
void setEntry (const string &name, const ParameterEntry &entry)
 Set a parameter directly as a ParameterEntry.
Get Methods
template<typename T>
T & get (const string &name, T def_value)
 Retrieves parameter name of type T from list, if it exists, else the def_value is used to enter a new parameter into the list.
std::string & get (const string &name, char *def_value)
 Template specialization of get, where the nominal value is a character string in parenthesis. Both char* and string are stored as strings and return string values.
std::string & get (const string &name, const char *def_value)
 Template specialization of get, where the nominal value is a character string in parenthesis. Both char* and string are stored as strings and return string values.
template<typename T>
T & get (const string &name)
 Retrieves parameter name of type T from a list, an exception is thrown if this parameter doesn't exist.
template<typename T>
const T & get (const string &name) const
 Retrieves parameter name of type T from a constant list, an exception is thrown if this parameter doesn't exist.
Sublist Methods
ParameterListsublist (const string &name)
 Creates an empty sublist and returns a reference to the sublist name. If the list already exists, returns reference to that sublist. If the name exists but is not a sublist, an exception is thrown.
const ParameterListsublist (const string &name) const
 Return a const reference to an existing sublist name. If the list does not already exist or the name exists but is not a sublist, an exception is thrown.
Attribute Methods
bool isParameter (const string &name) const
 Query the existence of a parameter.
bool isSublist (const string &name) const
 Query the existence of a parameter and whether it is a parameter list.
template<typename T>
bool isType (const string &name) const
 Query the existence and type of a parameter.
I/O Methods
ostream & print (ostream &os, int indent=0) const
 Printing method for parameter lists. Indenting is used to indicate parameter list hierarchies.
void unused (ostream &os) const
 Print out unused parameters in the ParameterList.
Read-only access to the iterator
ConstIterator begin () const
 An iterator pointing to the first entry.
ConstIterator end () const
 An iterator pointing beyond the last entry.
const ParameterEntryentry (ConstIterator i) const
 Access to ParameterEntry (i.e., returns i->second).
const string & name (ConstIterator i) const
 Access to name (i.e., returns i->first).

Private Types

typedef Teuchos::map< string,
ParameterEntry
Map
 Parameter container typedef.
typedef Map::iterator Iterator
 Parameter container iterator typedef.

Private Member Functions

ParameterEntryentry (Iterator i)
 Access to ParameterEntry (i.e., returns i->second).

Private Attributes

Map params_
 Parameter list.

Related Functions

(Note that these are not member functions.)

template<typename T>
T & getParameter (ParameterList &l, const string &name)
 A templated helper function for getting a parameter from a non-const list. This helper function prevents the need for giving a nominal value of the specific template type.
template<typename T>
const T & getParameter (const ParameterList &l, const string &name)
 A templated helper function for getting a parameter from a const list. This helper function prevents the need for giving a nominal value of the specific template type.
template<typename T>
bool isParameterType (ParameterList &l, const string &name)
 A templated helper function for determining the type of a parameter entry for a non-const list. This helper function avoids the need for giving a nominal value of the specific template type.
template<typename T>
bool isParameterType (const ParameterList &l, const string &name)
 A templated helper function for determining the type of a parameter entry for a const list. This helper function avoids the need for giving a nominal value of the specific template type.
ostream & operator<< (ostream &os, const ParameterList &l)
 Output stream operator for handling the printing of the parameter list.

Detailed Description

The Teuchos::ParameterList class provides a templated parameter list.

Parameters can be added and retreived with the templated "get" and "set" methods. These parameters can be the standard types (double, float, int, ...) and parameter lists, allowing for a hierarchy of parameter lists. These parameters can also be pointers to vectors or functions.

Note:
Examples:

ParameterList/cxx_main.cpp.

Definition at line 62 of file Teuchos_ParameterList.hpp.


Member Typedef Documentation

typedef Teuchos::map<string, ParameterEntry> Teuchos::ParameterList::Map [private]
 

Parameter container typedef.

Definition at line 65 of file Teuchos_ParameterList.hpp.

typedef Map::iterator Teuchos::ParameterList::Iterator [private]
 

Parameter container iterator typedef.

Definition at line 68 of file Teuchos_ParameterList.hpp.

typedef Map::const_iterator Teuchos::ParameterList::ConstIterator
 

Parameter container const iterator typedef.

Definition at line 75 of file Teuchos_ParameterList.hpp.


Constructor & Destructor Documentation

ParameterList::ParameterList  ) 
 

Constructor.

Definition at line 38 of file Teuchos_ParameterList.cpp.

ParameterList::ParameterList const ParameterList source  ) 
 

Copy Constructor.

Definition at line 40 of file Teuchos_ParameterList.cpp.

ParameterList::~ParameterList  ) 
 

Deconstructor.

Definition at line 54 of file Teuchos_ParameterList.cpp.


Member Function Documentation

ParameterList & ParameterList::operator= const ParameterList source  ) 
 

Replace the current parameter list with source.

Definition at line 45 of file Teuchos_ParameterList.cpp.

template<typename T>
void Teuchos::ParameterList::set const string &  name,
value
 

Sets different types of parameters. The type depends on the second entry.

Note:
  • Use static_cast<T>() when the type is ambiguous.
  • Both char* and string map to are stored as strings internally.
  • Sets the parameter as "unused".
Examples:
ParameterList/cxx_main.cpp.

Definition at line 246 of file Teuchos_ParameterList.hpp.

void Teuchos::ParameterList::set const string &  name,
char *  value
[inline]
 

Template specialization for the case when a user sets the parameter with a character string in parenthesis.

Definition at line 107 of file Teuchos_ParameterList.hpp.

void Teuchos::ParameterList::set const string &  name,
const char *  value
[inline]
 

Template specialization for the case when a user sets the parameter with a character string in parenthesis.

Definition at line 113 of file Teuchos_ParameterList.hpp.

void Teuchos::ParameterList::set const string &  name,
ParameterList  value
[inline]
 

Template specialization for the case when a user sets the parameter with a ParameterList.

Definition at line 118 of file Teuchos_ParameterList.hpp.

void Teuchos::ParameterList::setEntry const string &  name,
const ParameterEntry entry
[inline]
 

Set a parameter directly as a ParameterEntry.

Note:
This is required to preserve the isDefault value when reading back from XML. KL 7 August 2004

Definition at line 125 of file Teuchos_ParameterList.hpp.

template<typename T>
T & Teuchos::ParameterList::get const string &  name,
def_value
 

Retrieves parameter name of type T from list, if it exists, else the def_value is used to enter a new parameter into the list.

Note:
  • Use the static_cast<T>() when the type is ambiguous.
  • Both char* and string map to are stored as strings internally.
  • Sets the parameter as "used".
Examples:
ParameterList/cxx_main.cpp.

Definition at line 252 of file Teuchos_ParameterList.hpp.

std::string& Teuchos::ParameterList::get const string &  name,
char *  def_value
[inline]
 

Template specialization of get, where the nominal value is a character string in parenthesis. Both char* and string are stored as strings and return string values.

Definition at line 146 of file Teuchos_ParameterList.hpp.

std::string& Teuchos::ParameterList::get const string &  name,
const char *  def_value
[inline]
 

Template specialization of get, where the nominal value is a character string in parenthesis. Both char* and string are stored as strings and return string values.

Definition at line 152 of file Teuchos_ParameterList.hpp.

template<typename T>
T & Teuchos::ParameterList::get const string &  name  ) 
 

Retrieves parameter name of type T from a list, an exception is thrown if this parameter doesn't exist.

Note:
The syntax for calling this method is: list.template get<int>( "Iters" )

Definition at line 266 of file Teuchos_ParameterList.hpp.

template<typename T>
const T & Teuchos::ParameterList::get const string &  name  )  const
 

Retrieves parameter name of type T from a constant list, an exception is thrown if this parameter doesn't exist.

Note:
The syntax for calling this method is: list.template get<int>( "Iters" )

Definition at line 281 of file Teuchos_ParameterList.hpp.

ParameterList & ParameterList::sublist const string &  name  ) 
 

Creates an empty sublist and returns a reference to the sublist name. If the list already exists, returns reference to that sublist. If the name exists but is not a sublist, an exception is thrown.

Examples:
ParameterList/cxx_main.cpp.

Definition at line 83 of file Teuchos_ParameterList.cpp.

const ParameterList & ParameterList::sublist const string &  name  )  const
 

Return a const reference to an existing sublist name. If the list does not already exist or the name exists but is not a sublist, an exception is thrown.

Definition at line 100 of file Teuchos_ParameterList.cpp.

bool ParameterList::isParameter const string &  name  )  const
 

Query the existence of a parameter.

Returns:
"true" if a parameter with this name exists, else "false".
Examples:
ParameterList/cxx_main.cpp.

Definition at line 78 of file Teuchos_ParameterList.cpp.

bool ParameterList::isSublist const string &  name  )  const
 

Query the existence of a parameter and whether it is a parameter list.

Returns:
"true" if a parameter with this name exists and is itself a parameter list, else "false".
Examples:
ParameterList/cxx_main.cpp.

Definition at line 68 of file Teuchos_ParameterList.cpp.

template<typename T>
bool Teuchos::ParameterList::isType const string &  name  )  const
 

Query the existence and type of a parameter.

Returns:
"true" is a parameter with this name exists and is of type T, else "false".
Note:
The syntax for calling this method is: list.template isType<int>( "Iters" )

Definition at line 317 of file Teuchos_ParameterList.hpp.

ostream & ParameterList::print ostream &  os,
int  indent = 0
const
 

Printing method for parameter lists. Indenting is used to indicate parameter list hierarchies.

Definition at line 115 of file Teuchos_ParameterList.cpp.

void ParameterList::unused ostream &  os  )  const
 

Print out unused parameters in the ParameterList.

Examples:
ParameterList/cxx_main.cpp.

Definition at line 58 of file Teuchos_ParameterList.cpp.

ParameterList::ConstIterator ParameterList::begin  )  const
 

An iterator pointing to the first entry.

Definition at line 139 of file Teuchos_ParameterList.cpp.

ParameterList::ConstIterator ParameterList::end  )  const
 

An iterator pointing beyond the last entry.

Definition at line 144 of file Teuchos_ParameterList.cpp.

const ParameterEntry & ParameterList::entry ConstIterator  i  )  const
 

Access to ParameterEntry (i.e., returns i->second).

Definition at line 180 of file Teuchos_ParameterList.cpp.

const string & ParameterList::name ConstIterator  i  )  const
 

Access to name (i.e., returns i->first).

Definition at line 170 of file Teuchos_ParameterList.cpp.

ParameterEntry & ParameterList::entry Iterator  i  )  [private]
 

Access to ParameterEntry (i.e., returns i->second).

Definition at line 175 of file Teuchos_ParameterList.cpp.


Friends And Related Function Documentation

template<typename T>
T & getParameter ParameterList l,
const string &  name
[related]
 

A templated helper function for getting a parameter from a non-const list. This helper function prevents the need for giving a nominal value of the specific template type.

Note:
The syntax for calling this function is: getParameter<int>( list, "Iters" )

Definition at line 343 of file Teuchos_ParameterList.hpp.

template<typename T>
const T & getParameter const ParameterList l,
const string &  name
[related]
 

A templated helper function for getting a parameter from a const list. This helper function prevents the need for giving a nominal value of the specific template type.

Note:
The syntax for calling this function is: getParameter<int>( list, "Iters" )

Definition at line 365 of file Teuchos_ParameterList.hpp.

template<typename T>
bool isParameterType ParameterList l,
const string &  name
[related]
 

A templated helper function for determining the type of a parameter entry for a non-const list. This helper function avoids the need for giving a nominal value of the specific template type.

Note:
The syntax for calling this function is: isParameterType<int>( list, "Iters" )

Definition at line 387 of file Teuchos_ParameterList.hpp.

template<typename T>
bool isParameterType const ParameterList l,
const string &  name
[related]
 

A templated helper function for determining the type of a parameter entry for a const list. This helper function avoids the need for giving a nominal value of the specific template type.

Note:
The syntax for calling this function is: isParameterType<int>( list, "Iters" )

Definition at line 399 of file Teuchos_ParameterList.hpp.

ostream & operator<< ostream &  os,
const ParameterList l
[related]
 

Output stream operator for handling the printing of the parameter list.

Definition at line 407 of file Teuchos_ParameterList.hpp.


Member Data Documentation

Map Teuchos::ParameterList::params_ [private]
 

Parameter list.

Definition at line 241 of file Teuchos_ParameterList.hpp.


The documentation for this class was generated from the following files:
Generated on Thu Sep 18 12:41:20 2008 for Teuchos - Trilinos Tools Package by doxygen 1.3.9.1