Reference documentation for deal.II version Git a7d922cd5a 2021-01-15 21:19:32 -0700
Patterns::PatternBase Class Referenceabstract

#include <deal.II/base/patterns.h>

Inheritance diagram for Patterns::PatternBase:
[legend]

Public Types

enum  OutputStyle { Machine, Text, LaTeX }

Public Member Functions

virtual ~PatternBase ()=default

virtual bool match (const std::string &test_string) const =0

virtual std::string description (const OutputStyle style=Machine) const =0

virtual std::unique_ptr< PatternBaseclone () const =0

virtual std::size_t memory_consumption () const

Detailed Description

Base class to declare common interface. The purpose of this class is mostly to define the interface of patterns, and to force derived classes to have a clone function. It is thus, in the languages of the "Design Patterns" book (Gamma et al.), a "prototype".

Definition at line 79 of file patterns.h.

◆ OutputStyle

List of possible description output formats.

Capitalization chosen for similarity to ParameterHandler::OutputStyle.

Enumerator
Machine

Simple text suitable for machine parsing in the static public member functions for all of the built in inheriting classes.

Preferably human readable, but machine parsing is more critical.

Text

Easily human readable plain text format suitable for plain text documentation.

LaTeX

Easily human readable LaTeX format suitable for printing in manuals.

Definition at line 98 of file patterns.h.

◆ ~PatternBase()

 virtual Patterns::PatternBase::~PatternBase ( )
virtualdefault

Make destructor of this and all derived classes virtual.

◆ match()

 virtual bool Patterns::PatternBase::match ( const std::string & test_string ) const
pure virtual

Return true if the given string matches the pattern.

◆ description()

 virtual std::string Patterns::PatternBase::description ( const OutputStyle style = Machine ) const
pure virtual

Return a string describing the pattern.

◆ clone()

 virtual std::unique_ptr Patterns::PatternBase::clone ( ) const
pure virtual

Return a pointer to an exact copy of the object. This is necessary since we want to store objects of this type in containers, were we need to copy objects without knowledge of their actual data type (we only have pointers to the base class).

Ownership of the objects returned by this function is passed to the caller of this function.

◆ memory_consumption()

 std::size_t Patterns::PatternBase::memory_consumption ( ) const
virtual

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::MultipleSelection, Patterns::Tuple, Patterns::Map, Patterns::List, and Patterns::Selection.

Definition at line 192 of file patterns.cc.

The documentation for this class was generated from the following files: