deal.II version GIT relicensing-2167-g9622207b8f 2024-11-21 12:40:00+00:00
|
#include <deal.II/base/patterns.h>
Public Types | |
enum | OutputStyle { Machine , Text , LaTeX } |
Public Member Functions | |
Integer (const int lower_bound=min_int_value, const int upper_bound=max_int_value) | |
virtual bool | match (const std::string &test_string) const override |
virtual std::string | description (const OutputStyle style=Machine) const override |
virtual std::unique_ptr< PatternBase > | clone () const override |
virtual std::size_t | memory_consumption () const |
Static Public Member Functions | |
static std::unique_ptr< Integer > | create (const std::string &description) |
Static Public Attributes | |
static const int | min_int_value = std::numeric_limits<int>::min() |
static const int | max_int_value = std::numeric_limits<int>::max() |
Private Attributes | |
const int | lower_bound |
const int | upper_bound |
Static Private Attributes | |
static const char * | description_init = "[Integer" |
Test for the string being an integer. If bounds are given to the constructor, then the integer given also needs to be within the interval specified by these bounds. Note that unlike common convention in the C++ standard library, both bounds of this interval are inclusive; the reason is that in practice in most cases, one needs closed intervals, but these can only be realized with inclusive bounds for non-integer values. We thus stay consistent by always using closed intervals.
If the upper bound given to the constructor is smaller than the lower bound, then every integer is allowed.
Giving bounds may be useful if for example a value can only be positive and less than a reasonable upper bound (for example the number of refinement steps to be performed), or in many other cases.
Definition at line 191 of file patterns.h.
|
inherited |
List of possible description output formats.
Capitalization chosen for similarity to ParameterHandler::OutputStyle.
Definition at line 100 of file patterns.h.
Patterns::Integer::Integer | ( | const int | lower_bound = min_int_value , |
const int | upper_bound = max_int_value |
||
) |
Constructor. Bounds can be specified within which a valid parameter has to be. If the upper bound is smaller than the lower bound, then the entire set of integers is implied. The default values are chosen such that no bounds are enforced on parameters.
Note that the range implied by an object of the current type is inclusive of both bounds values, i.e., the upper_bound
is an allowed value, rather than indicating a half-open value as is often done in other contexts.
Definition at line 210 of file patterns.cc.
|
overridevirtual |
Return true
if the string is an integer and its value is within the specified range.
Implements Patterns::PatternBase.
Definition at line 218 of file patterns.cc.
|
overridevirtual |
Return a description of the pattern that valid strings are expected to match. If bounds were specified to the constructor, then include them into this description.
Implements Patterns::PatternBase.
Definition at line 240 of file patterns.cc.
|
overridevirtual |
Return a copy of the present object, which is newly allocated on the heap. Ownership of that object is transferred to the caller of this function.
Implements Patterns::PatternBase.
Definition at line 301 of file patterns.cc.
|
static |
Create a new object if the start of description matches description_init. Ownership of that object is transferred to the caller of this function.
Definition at line 309 of file patterns.cc.
|
virtualinherited |
Determine an estimate for the memory consumption (in bytes) of this object. To avoid unnecessary overhead, we do not force derived classes to provide this function as a virtual overloaded one, but rather try to cast the present object to one of the known derived classes and if that fails then take the size of this base class instead and add 32 byte (this value is arbitrary, it should account for virtual function tables, and some possible data elements). Since there are usually not many thousands of objects of this type around, and since the memory_consumption mechanism is used to find out where memory in the range of many megabytes is, this seems like a reasonable approximation.
On the other hand, if you know that your class deviates from this assumption significantly, you can still overload this function.
Reimplemented in Patterns::Selection, Patterns::List, Patterns::Map, Patterns::Tuple, and Patterns::MultipleSelection.
Definition at line 189 of file patterns.cc.
Minimal integer value. If the numeric_limits class is available use this information to obtain the extremal values, otherwise set it so that this class understands that all values are allowed.
Definition at line 199 of file patterns.h.
Maximal integer value. If the numeric_limits class is available use this information to obtain the extremal values, otherwise set it so that this class understands that all values are allowed.
Definition at line 206 of file patterns.h.
|
private |
Value of the lower bound. A number that satisfies the match operation of this class must be equal to this value or larger, if the bounds of the interval for a valid range.
Definition at line 261 of file patterns.h.
|
private |
Value of the upper bound. A number that satisfies the match operation of this class must be equal to this value or less, if the bounds of the interval for a valid range.
Definition at line 269 of file patterns.h.
|
staticprivate |
Initial part of description
Definition at line 274 of file patterns.h.