AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/core/Factory.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
5#include <unordered_map>
8#include "AMReX_Print.H"
63template <
class Base,
class... Args>
71 static std::unique_ptr<Base>
create(
const std::string& key, Args... args)
74 auto ptr =
table().at(key)(std::forward<Args>(args)...);
75 amrex::Print() <<
"Creating " << Base::base_identifier()
76 <<
" instance: " << key << std::endl;
71 static std::unique_ptr<Base>
create(
const std::string& key, Args... args) {
…}
84 static void print(std::ostream& os)
86 const auto& tbl =
table();
87 os << Base::base_identifier() <<
" " << tbl.size() << std::endl;
88 for (
const auto& it : tbl) {
89 os <<
" - " << it.first << std::endl;
84 static void print(std::ostream& os) {
…}
104 [](Args... args) -> std::unique_ptr<Base> {
105 return std::unique_ptr<Base>(
106 new T(std::forward<Args>(args)...));
115 const auto it = tbl.find(T::identifier());
135 const auto& tbl =
table();
136 if (tbl.find(key) == tbl.end()) {
138 if (amrex::ParallelDescriptor::IOProcessor()) {
143 "In " + Base::base_identifier() +
144 " cannot find instance: " + key);
158template <
class Base,
class... Args>
160bool Factory<Base, Args...>::Register<T>::registered =
Definition BCInterface.cpp:7
Class to handle registration of subclass for runtime selection.
Definition Factory.H:96
Register()
Definition Factory.H:121
friend T
Definition Factory.H:97
~Register() override
Definition Factory.H:111
static bool registered
Definition Factory.H:98
static bool add_sub_type()
Definition Factory.H:100
static std::unique_ptr< Base > create(const std::string &key, Args... args)
Definition Factory.H:71
std::unordered_map< std::string, CreatorFunc > LookupTable
Definition Factory.H:129
friend Base
Definition Factory.H:125
static void print(std::ostream &os)
Definition Factory.H:84
virtual ~Factory()=default
static void key_exists_or_error(const std::string &key)
Definition Factory.H:133
static LookupTable & table()
Lookup table containing all registered instances.
Definition Factory.H:149
std::unique_ptr< Base >(*)(Args...) CreatorFunc
Definition Factory.H:128