20 #ifndef LIBMESH_FACTORY_H 21 #define LIBMESH_FACTORY_H 65 static std::unique_ptr<Base>
build (
const std::string &
name);
71 virtual std::unique_ptr<Base>
create () = 0;
79 static std::map<std::string, Factory<Base> *> &
factory_map();
87 template <
class Derived,
class Base>
107 virtual std::unique_ptr<Base>
create ()
override;
114 template <
class Base>
120 libmesh_assert (!factory_map().count(
name));
122 factory_map()[
name] =
this;
127 template <
class Base>
132 if (!factory_map().count(
name))
138 for (
const auto & pr : factory_map())
141 libmesh_error_msg(
"Exiting...");
145 return std::unique_ptr<Base>(f->
create());
150 template <
class Derived,
class Base>
154 return libmesh_make_unique<Derived>();
160 #endif // LIBMESH_FACTORY_H std::string name(const ElemQuality q)
static std::map< std::string, Factory< Base > * > & factory_map()
Handles name-based creation of objects.
virtual std::unique_ptr< Base > create()=0
FactoryImp(const std::string &name)
OStreamProxy err(std::cerr)
virtual std::unique_ptr< Base > create() override
Factory(const std::string &name)
static std::unique_ptr< Base > build(const std::string &name)