Go to the documentation of this file.
20 #ifndef LIBMESH_PARAMETERS_H
21 #define LIBMESH_PARAMETERS_H
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/reference_counted_object.h"
26 #include "libmesh/print_trace.h"
45 void print_helper(std::ostream & os,
const std::vector<P> * param);
48 void print_helper(std::ostream & os,
const std::vector<std::vector<P>> * param);
105 template <
typename T>
106 const T &
get (
const std::string &)
const;
113 template <
typename T>
114 void insert (
const std::string &);
122 template <
typename T>
123 T &
set (
const std::string &);
134 void remove (
const std::string &);
141 #ifdef LIBMESH_HAVE_RTTI
145 template <
typename T>
147 #endif // LIBMESH_HAVE_RTTI
152 virtual void clear ();
171 #ifdef LIBMESH_HAVE_RTTI
176 virtual std::string
type ()
const = 0;
177 #endif // LIBMESH_HAVE_RTTI
183 virtual void print(std::ostream &)
const = 0;
196 template <
typename T>
211 #ifdef LIBMESH_HAVE_RTTI
215 virtual std::string
type ()
const;
216 #endif // LIBMESH_HAVE_RTTI
221 virtual void print(std::ostream &)
const;
238 typedef std::map<std::string, Value *>::iterator
iterator;
279 #ifdef LIBMESH_HAVE_RTTI
280 template <
typename T>
288 template <
typename T>
296 template <
typename T>
320 it->second =
nullptr;
340 for (
const auto & pr : source.
_values)
344 _values[pr.first] = pr.second->clone();
371 os <<
"Name\t Type\t Value\n"
372 <<
"---------------------\n";
375 os <<
" " << it->first
376 #ifdef LIBMESH_HAVE_RTTI
377 <<
"\t " << it->second->type()
378 #endif // LIBMESH_HAVE_RTTI
379 <<
"\t "; it->second->print(os);
400 template <
typename T>
407 #ifdef LIBMESH_HAVE_RTTI
408 if (
dynamic_cast<const Parameter<T> *
>(it->second) !=
nullptr)
419 template <
typename T>
423 if (!this->have_parameter<T>(
name))
425 std::ostringstream oss;
428 #ifdef LIBMESH_HAVE_RTTI
431 oss <<
" parameter named \""
432 <<
name <<
"\" found.\n\n"
433 <<
"Known parameters:\n"
436 libmesh_error_msg(oss.str());
444 return cast_ptr<Parameter<T> *>(it->second)->
get();
447 template <
typename T>
451 if (!this->have_parameter<T>(
name))
458 template <
typename T>
462 if (!this->have_parameter<T>(
name))
478 it->second =
nullptr;
486 #ifdef LIBMESH_HAVE_RTTI
487 template <
typename T>
491 unsigned int cnt = 0;
496 for (; it != vals_end; ++it)
497 if (
dynamic_cast<Parameter<T> *
>(it->second) !=
nullptr)
540 os << static_cast<int>(*param);
548 os << static_cast<int>(*param);
555 for (
const auto & p : *param)
561 void print_helper(std::ostream & os,
const std::vector<std::vector<P>> * param)
563 for (
const auto & pv : *param)
564 for (
const auto & p : pv)
570 #endif // LIBMESH_PARAMETERS_H
Concrete definition of a parameter value for a specified type.
virtual void print(std::ostream &) const =0
Prints the parameter value to the specified stream.
virtual void clear()
Clears internal data structures & frees any allocated memory.
void remove(const std::string &)
Removes the specified parameter from the list, if it exists.
void print(std::ostream &os=libMesh::out) const
Prints the contents, by default to libMesh::out.
virtual Value * clone() const
Clone this value.
iterator begin()
Iterator pointing to the beginning of the set of parameters.
T _value
Stored parameter value.
void print_helper(std::ostream &os, const P *param)
Helper functions for printing scalar, vector and vector<vector> types.
This class implements reference counting.
The libMesh namespace provides an interface to certain functionality in the library.
virtual Parameters & operator+=(const Parameters &source)
Addition/Assignment operator.
std::ostream & operator<<(std::ostream &os, const OrderWrapper &order)
Overload stream operators.
Tnew cast_ptr(Told *oldvar)
virtual std::string type() const =0
String identifying the type of parameter stored.
virtual std::string type() const
String identifying the type of parameter stored.
virtual void print(std::ostream &) const
Prints the parameter value to the specified stream.
bool have_parameter(const std::string &) const
iterator end()
Iterator pointing to the end of the set of parameters.
virtual Parameters & operator=(const Parameters &source)
Assignment operator.
std::size_t n_parameters() const
std::string demangle(const char *name)
Mostly system independent demangler.
Parameters()
Default constructor.
Abstract definition of a parameter value.
std::map< std::string, Value * >::iterator iterator
Parameter map iterator.
T & set(const std::string &)
virtual void set_attributes(const std::string &, bool)
Overridable function to set any extended attributes for classes inheriting from this class.
std::map< std::string, Value * > _values
Data structure to map names with values.
void insert(const std::string &)
Inserts a new Parameter into the object but does not return a writable reference.
const T & get(const std::string &) const
virtual ~Value()
Destructor.
std::map< std::string, Value * >::const_iterator const_iterator
Constant parameter map iterator.
virtual ~Parameters()
Destructor.
This class provides the ability to map between arbitrary, user-defined strings and several data types...
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
virtual Value * clone() const =0
Clone this value.