ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
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
 

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()

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 ( )
inlinestatic

Return a creator that constructs an object of class T.

Definition at line 63 of file library.h.

◆ 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 140 of file library.h.

◆ add() [2/2]

template<typename Base , typename... Args>
template<typename T >
requires std::derived_from<T, Base> && std::constructible_from<T, Args...>
static 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 81 of file library.h.

References ryujin::Library< Base, Args >::add().

Referenced by ryujin::Library< Base, Args >::add().

◆ create()

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

Construct one object per entry, in the order of registration. Throws if two objects share a name.

Definition at line 148 of file library.h.

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

◆ 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 168 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 178 of file library.h.

◆ 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 189 of file library.h.

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


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