ryujin 2.5.0 revision 3a6c8d57210175dea14d8116e1fe878f349f8c1c
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ryujin::Library< Base, Args > Class Template Referencefinal

#include <include/ryujin/base/library.h>

Public Types

using Creator = std::function< std::unique_ptr< Base >(Args...)>
 

Public Member Functions

 Library ()=delete
 
template<typename T >
requires std::derived_from<T, Base> && std::constructible_from<T, Args...>
auto creator () -> Creator
 

Static Public Member Functions

template<typename T >
requires std::derived_from<T, Base> && std::constructible_from<T, Args...>
static Creator creator ()
 
static void add (Creator creator)
 
template<typename T >
requires std::derived_from<T, Base> && std::constructible_from<T, Args...>
static void add ()
 
static std::vector< std::unique_ptr< Base > > create (Args... args)
 
static std::vector< std::string > names (Args... args)
 
static dealii::Patterns::Selection selection (const std::vector< std::unique_ptr< Base > > &objects)
 
static Base & select (const std::vector< std::unique_ptr< Base > > &objects, const std::string &name)
 

Detailed Description

template<typename Base, typename... Args>
class ryujin::Library< Base, Args >

A registry of creator functions for the abstract base class Base. A creator constructs an object of a class derived from Base from the arguments Args.

Library has only static members and is never constructed. One registry exists per instance: Library<Geometry<2>, const std::string &> and Library<Geometry<3>, const std::string &> are separate registries.

Entries are not keyed by name when they are added. The name of an entry is the name() of the object that it constructs: create() constructs all entries and throws if two of them share a name.

The registry starts with the built-in entries returned by defaults(), which is called when the registry is first used. add() appends further entries, at any time; an entry added after a call to create() is seen by every subsequent call. Objects are created in the order of registration.

A client can add its own entries with add(), for example in main() or in the constructor of an object at namespace scope.

Definition at line 48 of file library.h.

Member Typedef Documentation

◆ Creator

template<typename Base , typename... Args>
using ryujin::Library< Base, Args >::Creator = std::function<std::unique_ptr<Base>(Args...)>

A function that constructs an object of a class derived from Base.

Definition at line 56 of file library.h.

Constructor & Destructor Documentation

◆ Library()

template<typename Base , typename... Args>
ryujin::Library< Base, Args >::Library ( )
delete

Member Function Documentation

◆ creator() [1/2]

template<typename Base , typename... Args>
template<typename T >
requires std::derived_from<T, Base> && std::constructible_from<T, Args...>
static Creator ryujin::Library< Base, Args >::creator ( )
static

Return a creator that constructs an object of class T.

◆ add() [1/2]

template<typename Base , typename... Args>
void ryujin::Library< Base, Args >::add ( Creator  creator)
static

Append an entry to the creators() table.

Definition at line 155 of file library.h.

◆ add() [2/2]

template<typename Base , typename... Args>
requires std::derived_from<T, Base> && std::constructible_from<T, Args...>
template<typename T >
requires std::derived_from<T, Base> && std::constructible_from<T, Args...>
void ryujin::Library< Base, Args >::add ( )
inlinestatic

Append an entry to the creators() table that constructs an object of class T with the specified arguments.

Definition at line 137 of file library.h.

References ryujin::add().

◆ create()

template<typename Base , typename... Args>
std::vector< std::unique_ptr< Base > > ryujin::Library< Base, Args >::create ( Args...  args)
static

◆ names()

template<typename Base , typename... Args>
std::vector< std::string > ryujin::Library< Base, Args >::names ( Args...  args)
static

Return the names of the objects that create() constructs, in the same order.

Definition at line 183 of file library.h.

◆ selection()

template<typename Base , typename... Args>
dealii::Patterns::Selection ryujin::Library< Base, Args >::selection ( const std::vector< std::unique_ptr< Base > > &  objects)
static

Return a dealii::Patterns::Selection of the names of the given objects, as returned by create(). It is the pattern of the run time parameter that selects one of the objects by name.

Definition at line 193 of file library.h.

Referenced by ryujin::EquationDispatch::EquationDispatch().

◆ select()

template<typename Base , typename... Args>
Base & ryujin::Library< Base, Args >::select ( const std::vector< std::unique_ptr< Base > > &  objects,
const std::string &  name 
)
static

Return the object of the given objects, as returned by create(), whose name() is name. Throws if there is none.

Definition at line 204 of file library.h.

Referenced by ryujin::EquationDispatch::dispatch(), ryujin::EulerPoisson::ParabolicModule< HyperbolicDescription, dim, Number >::ParabolicModule(), and ryujin::InitialValues< HyperbolicDescription, dim, Number >::parse_parameters_callback().

◆ creator() [2/2]

template<typename Base , typename... Args>
template<typename T >
requires std::derived_from<T, Base> && std::constructible_from<T, Args...>
auto ryujin::Library< Base, Args >::creator ( ) -> Creator
inline

Definition at line 126 of file library.h.


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