Poster of Linux kernelThe best gift for a Linux geek
Parameters

Parameters

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

Parameters -  

SYNOPSIS


#include <parameters.h>  

Classes


class Parameter

class Value
 

Public Types


typedef std::map< std::string, Value * >::iterator iterator

typedef std::map< std::string, Value * >::const_iterator const_iterator
 

Public Member Functions


Parameters ()

Parameters (const Parameters &)

~Parameters ()

Parameters & operator= (const Parameters &)

template<typename T > bool have_parameter (const std::string &) const

template<typename T > const T & get (const std::string &) const

template<typename T > T & set (const std::string &)

void remove (const std::string &)

unsigned int n_parameters () const

template<typename T > unsigned int n_parameters () const

void clear ()

void print (std::ostream &os=std::cout) const

iterator begin ()

const_iterator begin () const

iterator end ()

const_iterator end () const
 

Private Attributes


std::map< std::string, Value * > _values
 

Detailed Description

This class provides the ability to map between arbitrary, user-defined strings and several data types. This can be used to provide arbitrary user-specified options.

Author:

Benjamin S. Kirk

Date:

2004

Version:

Revision:

3391

Definition at line 49 of file parameters.h.  

Member Typedef Documentation

 

typedef std::map<std::string, Value*>::const_iterator Parameters::const_iteratorConstant parameter map iterator.

Definition at line 207 of file parameters.h.  

typedef std::map<std::string, Value*>::iterator Parameters::iteratorParameter map iterator.

Definition at line 202 of file parameters.h.  

Constructor & Destructor Documentation

 

Parameters::Parameters () [inline]Default constructor. Does nothing.

Definition at line 56 of file parameters.h.

{};
 

Parameters::Parameters (const Parameters &p) [inline]Copy constructor.

Definition at line 311 of file parameters.h.

{
  *this = p;
}
 

Parameters::~Parameters () [inline]Destructor. Clears any allocated memory.

Definition at line 319 of file parameters.h.

References clear().

{
  this->clear ();
}
 

Member Function Documentation

 

Parameters::iterator Parameters::begin () [inline]Iterator pointing to the beginning of the set of parameters.

Definition at line 450 of file parameters.h.

References _values.

{
  return _values.begin();
}
 

Parameters::const_iterator Parameters::begin () const [inline]Iterator pointing to the beginning of the set of parameters.

Definition at line 456 of file parameters.h.

References _values.

{
  return _values.begin();
}
 

void Parameters::clear () [inline]Clears internal data structures & frees any allocated memory.

Definition at line 281 of file parameters.h.

References _values.

Referenced by EquationSystems::clear(), operator=(), and ~Parameters().

{                         // before its first use (for some compilers)
  while (!_values.empty())
    {
      Parameters::iterator it = _values.begin();
      
      delete it->second;      
      it->second = NULL;
      
      _values.erase(it);
    }
}
 

Parameters::iterator Parameters::end () [inline]Iterator pointing to the end of the set of parameters

Definition at line 462 of file parameters.h.

References _values.

{
  return _values.end();
}
 

Parameters::const_iterator Parameters::end () const [inline]Iterator pointing to the end of the set of parameters

Definition at line 468 of file parameters.h.

References _values.

{
  return _values.end();
}
 

template<typename T > const T & Parameters::get (const std::string &name) const [inline]Returns:

a constant reference to the specified parameter value. Requires, of course, that the parameter exists.

Definition at line 375 of file parameters.h.

References _values, and Quality::name().

Referenced by LinearImplicitSystem::adjoint_solve(), FrequencySystem::clear_all(), FEComputeData::init(), FrequencySystem::init_data(), FrequencySystem::n_frequencies(), FrequencySystem::set_current_frequency(), NonlinearImplicitSystem::set_solver_parameters(), LinearImplicitSystem::solve(), FrequencySystem::solve(), and EigenSystem::solve().

{
  if (!this->have_parameter<T>(name))
    {
      std::cerr << 'ERROR: no '
                << typeid(T).name()
                << ' parameter named ''
                << name << '':' << std::endl
                << *this;
      
      libmesh_error();
    }

  Parameters::const_iterator it = _values.find(name);

  libmesh_assert (it != _values.end());
  libmesh_assert (it->second != NULL);
  libmesh_assert (dynamic_cast<const Parameter<T>*>(it->second) != NULL);
  
  return dynamic_cast<Parameter<T>*>(it->second)->get();
}
 

template<typename T > bool Parameters::have_parameter (const std::string &name) const [inline]Returns:

true if a parameter of type T with a specified name exists, false otherwise.

Definition at line 360 of file parameters.h.

References _values.

Referenced by FrequencySystem::clear_all(), FEComputeData::init(), FrequencySystem::init_data(), and EigenSystem::solve().

{
  Parameters::const_iterator it = _values.find(name);

  if (it != _values.end())
    if (dynamic_cast<const Parameter<T>*>(it->second) != NULL)
      return true;

  return false;
}
 

template<typename T > unsigned int Parameters::n_parameters () constReturns:

the number of parameters of the requested type.

 

unsigned int Parameters::n_parameters () const [inline]Returns:

the total number of parameters.

Definition at line 104 of file parameters.h.

References _values.

{ return _values.size(); }
 

Parameters & Parameters::operator= (const Parameters &rhs) [inline]Assignment operator.

Definition at line 297 of file parameters.h.

References _values, and clear().

{
  this->clear();
  
  for (Parameters::const_iterator it = rhs._values.begin();
       it != rhs._values.end(); ++it)
    _values[it->first] = it->second->clone();
  
  return *this;
}
 

void Parameters::print (std::ostream &os = std::cout) const [inline]Prints the contents to the specified stream.

Definition at line 327 of file parameters.h.

References _values.

Referenced by operator<<().

{
  Parameters::const_iterator it = _values.begin();

  os << 'Name	 Type	 Value
     << '---------------------;
  while (it != _values.end())
    {
      os << ' '   << it->first
         << '	 ' << it->second->type()
         << '	 ';   it->second->print(os);      
      os << ';

      ++it;
    }
}
 

void Parameters::remove (const std::string &name) [inline]Removes the specified parameter from the list, if it exists.

Definition at line 418 of file parameters.h.

References _values.

Referenced by FrequencySystem::clear_all().

{
  Parameters::iterator it = _values.find(name);

  if (it != _values.end())
    {
      delete it->second;
      it->second = NULL;

      _values.erase(it);
    }
}
 

template<typename T > T & Parameters::set (const std::string &name) [inline]Returns:

a writeable reference to the specified parameter. This method will create the parameter if it does not exist, so it can be used to define parameters which will later be accessed with the get() member.

Definition at line 401 of file parameters.h.

References _values, Quality::name(), and Parameters::Parameter< T >::set().

Referenced by NewmarkSystem::clear(), EquationSystems::EquationSystems(), NewmarkSystem::NewmarkSystem(), NonlinearImplicitSystem::NonlinearImplicitSystem(), FrequencySystem::set_current_frequency(), FrequencySystem::set_frequencies(), FrequencySystem::set_frequencies_by_range(), FrequencySystem::set_frequencies_by_steps(), and NewmarkSystem::set_newmark_parameters().

{
  Parameter<T>* param = NULL;
  
  if (!this->have_parameter<T>(name))
    _values[name] = new Parameter<T>;

  param = dynamic_cast<Parameter<T>*>(_values[name]);

  libmesh_assert (param != NULL);
  
  return param->set();
}
 

Member Data Documentation

 

std::map<std::string, Value*> Parameters::_values [private]Data structure to map names with values.

Definition at line 234 of file parameters.h.

Referenced by begin(), clear(), end(), get(), have_parameter(), n_parameters(), operator=(), print(), remove(), and set().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Classes
Public Types
Public Member Functions
Private Attributes
Detailed Description
Member Typedef Documentation
typedef std::map<std::string, Value*>::const_iterator Parameters::const_iteratorConstant parameter map iterator.
typedef std::map<std::string, Value*>::iterator Parameters::iteratorParameter map iterator.
Constructor & Destructor Documentation
Parameters::Parameters () [inline]Default constructor. Does nothing.
Parameters::Parameters (const Parameters &p) [inline]Copy constructor.
Parameters::~Parameters () [inline]Destructor. Clears any allocated memory.
Member Function Documentation
Parameters::iterator Parameters::begin () [inline]Iterator pointing to the beginning of the set of parameters.
Parameters::const_iterator Parameters::begin () const [inline]Iterator pointing to the beginning of the set of parameters.
void Parameters::clear () [inline]Clears internal data structures & frees any allocated memory.
Parameters::iterator Parameters::end () [inline]Iterator pointing to the end of the set of parameters
Parameters::const_iterator Parameters::end () const [inline]Iterator pointing to the end of the set of parameters
template<typename T > const T & Parameters::get (const std::string &name) const [inline]Returns:
template<typename T > bool Parameters::have_parameter (const std::string &name) const [inline]Returns:
template<typename T > unsigned int Parameters::n_parameters () constReturns:
unsigned int Parameters::n_parameters () const [inline]Returns:
Parameters & Parameters::operator= (const Parameters &rhs) [inline]Assignment operator.
void Parameters::print (std::ostream &os = std::cout) const [inline]Prints the contents to the specified stream.
void Parameters::remove (const std::string &name) [inline]Removes the specified parameter from the list, if it exists.
template<typename T > T & Parameters::set (const std::string &name) [inline]Returns:
Member Data Documentation
std::map<std::string, Value*> Parameters::_values [private]Data structure to map names with values.
Author

This document was created by man2html, using the manual pages.
Time: 21:52:00 GMT, April 16, 2011