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