libMesh
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | List of all members
libMesh::FactoryImp< Derived, Base > Class Template Reference

Factory implementation class. More...

#include <factory.h>

Inheritance diagram for libMesh::FactoryImp< Derived, Base >:
[legend]

Public Member Functions

 FactoryImp (const std::string &name)
 Constructor. More...
 
 ~FactoryImp ()
 Destructor. More...
 

Static Public Member Functions

static UniquePtr< Base > build (const std::string &name)
 Builds an object of type Base identified by name. More...
 

Protected Member Functions

template<>
std::map< std::string, Factory< FunctionBase< Number > > * > & factory_map ()
 
template<>
std::map< std::string, Factory< Partitioner > * > & factory_map ()
 

Static Protected Member Functions

static std::map< std::string, Factory< Base > * > & factory_map ()
 Map from a name to a Factory<Base> * pointer. More...
 

Private Member Functions

virtual UniquePtr< Base > create () libmesh_override
 

Detailed Description

template<class Derived, class Base>
class libMesh::FactoryImp< Derived, Base >

Factory implementation class.

Definition at line 88 of file factory.h.

Constructor & Destructor Documentation

template<class Derived, class Base>
libMesh::FactoryImp< Derived, Base >::FactoryImp ( const std::string &  name)

Constructor.

Takes a name as input.

Definition at line 95 of file factory.h.

95 : Factory<Base>(name) { }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
template<class Derived, class Base>
libMesh::FactoryImp< Derived, Base >::~FactoryImp ( )

Destructor.

Empty.

Definition at line 100 of file factory.h.

References libMesh::Factory< Base >::create().

100 {}

Member Function Documentation

template<class Base >
UniquePtr< Base > libMesh::Factory< Base >::build ( const std::string &  name)
staticinherited

Builds an object of type Base identified by name.

Definition at line 129 of file factory.h.

References libMesh::err, libMesh::Factory< Base >::factory_map(), and libMesh::Quality::name().

Referenced by libMesh::Factory< Base >::~Factory().

130 {
131  // name not found in the map
132  if (!factory_map().count(name))
133  {
134  libMesh::err << "Tried to build an unknown type: " << name << std::endl;
135 
136  libMesh::err << "valid options are:" << std::endl;
137 
138  for (typename std::map<std::string,Factory<Base> *>::const_iterator
139  it = factory_map().begin(); it != factory_map().end(); ++it)
140  libMesh::err << " " << it->first << std::endl;
141 
142  libmesh_error_msg("Exiting...");
143 
144  // We'll never get here
145  return UniquePtr<Base>();
146  }
147 
148  Factory<Base> * f = factory_map()[name];
149  return UniquePtr<Base>(f->create());
150 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
OStreamProxy err
static std::map< std::string, Factory< Base > * > & factory_map()
Map from a name to a Factory<Base> * pointer.
template<class Derived , class Base >
UniquePtr< Base > libMesh::FactoryImp< Derived, Base >::create ( )
privatevirtual
Returns
A new object of type Derived.

Implements libMesh::Factory< Base >.

Definition at line 156 of file factory.h.

157 {
158  return UniquePtr<Base>(new Derived);
159 }
template<>
std::map< std::string, Factory< Partitioner > * > & libMesh::Factory< Partitioner >::factory_map ( )
protectedinherited

Definition at line 38 of file partitioner_factory.C.

39 {
40  static std::map<std::string, Factory<Partitioner> *> _map;
41  return _map;
42 }
template<>
std::map< std::string, Factory< FunctionBase< Number > > * > & libMesh::Factory< FunctionBase< Number > >::factory_map ( )
protectedinherited

Definition at line 62 of file factoryfunction.C.

References libMesh::example_one_factory.

63 {
64  static std::map<std::string, Factory<FunctionBase<Number>> *> _map;
65  return _map;
66 }
template<class Base >
static std::map<std::string, Factory<Base> *>& libMesh::Factory< Base >::factory_map ( )
staticprotectedinherited

Map from a name to a Factory<Base> * pointer.

Referenced by libMesh::Factory< Base >::build(), libMesh::Factory< Base >::Factory(), and libMesh::Factory< Base >::~Factory().


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