20 #ifndef LIBMESH_FACTORY_H 21 #define LIBMESH_FACTORY_H 25 #include "libmesh/libmesh_common.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>
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 std::make_unique<Derived>();
160 #endif // LIBMESH_FACTORY_H std::string name(const ElemQuality q)
This function returns a string containing some name for q.
~FactoryImp()=default
Destructor.
static std::map< std::string, Factory< Base > * > & factory_map()
Map from a name to a Factory<Base> * pointer.
virtual ~Factory()=default
Destructor.
The libMesh namespace provides an interface to certain functionality in the library.
Factory implementation class.
Factory class definition.
virtual std::unique_ptr< Base > create()=0
Create a Base class.
FactoryImp(const std::string &name)
Constructor.
virtual std::unique_ptr< Base > create() override
Factory(const std::string &name)
Constructor.
static std::unique_ptr< Base > build(const std::string &name)
Builds an object of type Base identified by name.