Parameters Class Reference
#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.
- 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_iterator |
Constant parameter map iterator.
Definition at line 207 of file parameters.h.
| typedef std::map<std::string, Value*>::iterator Parameters::iterator |
Parameter map iterator.
Definition at line 202 of file parameters.h.
Constructor & Destructor Documentation
| Parameters::Parameters | ( | ) | [inline] |
| Parameters::Parameters | ( | const Parameters & | p | ) | [inline] |
| Parameters::~Parameters | ( | ) | [inline] |
Destructor. Clears any allocated memory.
Definition at line 319 of file parameters.h.
References clear().
00320 { 00321 this->clear (); 00322 }
Member Function Documentation
| 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.
00457 { 00458 return _values.begin(); 00459 }
| 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.
00451 { 00452 return _values.begin(); 00453 }
| 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().
00282 { // before its first use (for some compilers) 00283 while (!_values.empty()) 00284 { 00285 Parameters::iterator it = _values.begin(); 00286 00287 delete it->second; 00288 it->second = NULL; 00289 00290 _values.erase(it); 00291 } 00292 }
| 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.
00469 { 00470 return _values.end(); 00471 }
| 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.
00463 { 00464 return _values.end(); 00465 }
| 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 QuadratureRules::name().
Referenced by 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().
00376 { 00377 if (!this->have_parameter<T>(name)) 00378 { 00379 std::cerr << "ERROR: no " 00380 << typeid(T).name() 00381 << " parameter named \"" 00382 << name << "\":" << std::endl 00383 << *this; 00384 00385 libmesh_error(); 00386 } 00387 00388 Parameters::const_iterator it = _values.find(name); 00389 00390 libmesh_assert (it != _values.end()); 00391 libmesh_assert (it->second != NULL); 00392 libmesh_assert (dynamic_cast<const Parameter<T>*>(it->second) != NULL); 00393 00394 return dynamic_cast<Parameter<T>*>(it->second)->get(); 00395 }
| bool Parameters::have_parameter | ( | const std::string & | name | ) | const [inline] |
- Returns:
trueif a parameter of typeTwith a specified name exists,falseotherwise.
Definition at line 360 of file parameters.h.
References _values.
Referenced by FrequencySystem::clear_all(), FEComputeData::init(), FrequencySystem::init_data(), and EigenSystem::solve().
00361 { 00362 Parameters::const_iterator it = _values.find(name); 00363 00364 if (it != _values.end()) 00365 if (dynamic_cast<const Parameter<T>*>(it->second) != NULL) 00366 return true; 00367 00368 return false; 00369 }
| unsigned int Parameters::n_parameters | ( | ) | const [inline] |
- Returns:
- 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.
00104 { return _values.size(); }
| Parameters & Parameters::operator= | ( | const Parameters & | rhs | ) | [inline] |
Assignment operator.
Definition at line 297 of file parameters.h.
References _values, and clear().
00298 { 00299 this->clear(); 00300 00301 for (Parameters::const_iterator it = rhs._values.begin(); 00302 it != rhs._values.end(); ++it) 00303 _values[it->first] = it->second->clone(); 00304 00305 return *this; 00306 }
| 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<<().
00328 { 00329 Parameters::const_iterator it = _values.begin(); 00330 00331 os << "Name\t Type\t Value\n" 00332 << "---------------------\n"; 00333 while (it != _values.end()) 00334 { 00335 os << " " << it->first 00336 << "\t " << it->second->type() 00337 << "\t "; it->second->print(os); 00338 os << '\n'; 00339 00340 ++it; 00341 } 00342 }
| 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().
00419 { 00420 Parameters::iterator it = _values.find(name); 00421 00422 if (it != _values.end()) 00423 { 00424 delete it->second; 00425 it->second = NULL; 00426 00427 _values.erase(it); 00428 } 00429 }
| 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, 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().
00402 { 00403 Parameter<T>* param = NULL; 00404 00405 if (!this->have_parameter<T>(name)) 00406 _values[name] = new Parameter<T>; 00407 00408 param = dynamic_cast<Parameter<T>*>(_values[name]); 00409 00410 libmesh_assert (param != NULL); 00411 00412 return param->set(); 00413 }
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().
The documentation for this class was generated from the following file: