GRINS-0.8.0
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions
GRINS::FactoryAbstract< Base > Class Template Referenceabstract

Abstract factory. More...

#include <factory_abstract.h>

Inheritance diagram for GRINS::FactoryAbstract< Base >:
Inheritance graph
[legend]

Public Member Functions

virtual ~FactoryAbstract ()
 
virtual libMesh::UniquePtr< Base > create ()=0
 Subclasses implement the actual construction of the Base object in create(). More...
 

Static Public Member Functions

static libMesh::UniquePtr< Base > build (const std::string &name)
 Use this method to build objects of type Base. More...
 

Protected Member Functions

 FactoryAbstract (const std::string &name)
 Constructor is protected. Use the build() method to construct Base objects. More...
 
template<>
std::map< std::string, FactoryAbstract< CatalycityBase > * > & factory_map ()
 
template<>
std::map< std::string, FactoryAbstract< libMesh::DirichletBoundary > * > & factory_map ()
 
template<>
std::map< std::string, FactoryAbstract< NeumannBCContainer > * > & factory_map ()
 
template<>
std::map< std::string, FactoryAbstract< Physics > * > & factory_map ()
 
template<>
std::map< std::string, FactoryAbstract< Solver > * > & factory_map ()
 
template<>
std::map< std::string, FactoryAbstract< libMesh::ErrorEstimator > * > & factory_map ()
 
template<>
std::map< std::string, FactoryAbstract< FEVariablesBase > * > & factory_map ()
 

Static Protected Member Functions

static FactoryAbstract< Base > & get_factory (const std::string &name)
 Helper method that looks up the factory and returns it if present, or error if it's not. More...
 
template<typename DerivedType >
static DerivedType & get_factory_subclass (const std::string &name)
 Like get_factory, but will downcast to DerivedType. More...
 
static std::map< std::string, FactoryAbstract< Base > * > & factory_map ()
 

Detailed Description

template<typename Base>
class GRINS::FactoryAbstract< Base >

Abstract factory.

Copied from libMesh::Factory. The main difference is the helper method to fetch the factory (this was moved out of the build() function in libMesh::Factory). That is useful so subclasses can additional static methods that dispatch to virtual methods of the subclass.

Definition at line 45 of file factory_abstract.h.

Constructor & Destructor Documentation

template<typename Base>
virtual GRINS::FactoryAbstract< Base >::~FactoryAbstract ( )
inlinevirtual

Definition at line 49 of file factory_abstract.h.

49 {}
template<class Base >
GRINS::FactoryAbstract< Base >::FactoryAbstract ( const std::string &  name)
inlineprotected

Constructor is protected. Use the build() method to construct Base objects.

Definition at line 75 of file factory_abstract.h.

76  {
77  // Make sure we haven't already added this name
78  // to the map
79  libmesh_assert (!factory_map().count(name));
80 
81  factory_map()[name] = this;
82  }
static std::map< std::string, FactoryAbstract< Base > * > & factory_map()

Member Function Documentation

template<class Base >
libMesh::UniquePtr< Base > GRINS::FactoryAbstract< Base >::build ( const std::string &  name)
inlinestatic

Use this method to build objects of type Base.

Definition at line 86 of file factory_abstract.h.

References GRINS::FactoryAbstract< Base >::create().

87  {
88  FactoryAbstract<Base>& factory = get_factory(name);
89  return factory.create();
90  }
static FactoryAbstract< Base > & get_factory(const std::string &name)
Helper method that looks up the factory and returns it if present, or error if it's not...
template<typename Base>
virtual libMesh::UniquePtr<Base> GRINS::FactoryAbstract< Base >::create ( )
pure virtual
template<>
std::map< std::string, FactoryAbstract< Physics > * > & GRINS::FactoryAbstract< Physics >::factory_map ( )
protected

Definition at line 33 of file physics_factory_base.C.

34  {
35  static std::map<std::string, FactoryAbstract<Physics>*> _map;
36  return _map;
37  }
template<>
std::map< std::string, FactoryAbstract< libMesh::ErrorEstimator > * > & GRINS::FactoryAbstract< libMesh::ErrorEstimator >::factory_map ( )
protected

Definition at line 33 of file error_estimator_factory_base.C.

34  {
35  static std::map<std::string, FactoryAbstract<libMesh::ErrorEstimator>*> _map;
36  return _map;
37  }
template<>
std::map< std::string, FactoryAbstract< libMesh::DirichletBoundary > * > & GRINS::FactoryAbstract< libMesh::DirichletBoundary >::factory_map ( )
protected

Definition at line 33 of file dirichlet_bc_factory_abstract.C.

34  {
35  static std::map<std::string, FactoryAbstract<libMesh::DirichletBoundary>*> _map;
36  return _map;
37  }
template<>
std::map< std::string, FactoryAbstract< CatalycityBase > * > & GRINS::FactoryAbstract< CatalycityBase >::factory_map ( )
protected

Definition at line 34 of file catalycity_factory_abstract.C.

35  {
36  static std::map<std::string, FactoryAbstract<CatalycityBase>*> _map;
37  return _map;
38  }
template<>
std::map< std::string, FactoryAbstract< Solver > * > & GRINS::FactoryAbstract< Solver >::factory_map ( )
protected

Definition at line 41 of file solver_factory_abstract.C.

42  {
43  static std::map<std::string, FactoryAbstract<Solver>*> _map;
44  return _map;
45  }
template<typename Base>
static std::map<std::string, FactoryAbstract<Base>*>& GRINS::FactoryAbstract< Base >::factory_map ( )
staticprotected
template<>
std::map< std::string, FactoryAbstract< NeumannBCContainer > * > & GRINS::FactoryAbstract< NeumannBCContainer >::factory_map ( )
protected

Definition at line 77 of file neumann_bc_factory_abstract.C.

78  {
79  static std::map<std::string, FactoryAbstract<NeumannBCContainer>*> _map;
80  return _map;
81  }
template<>
std::map< std::string, FactoryAbstract< FEVariablesBase > * > & GRINS::FactoryAbstract< FEVariablesBase >::factory_map ( )
protected

Definition at line 125 of file variable_factory.C.

126  {
127  static std::map<std::string, FactoryAbstract<FEVariablesBase>*> _map;
128  return _map;
129  }
template<class Base >
FactoryAbstract< Base > & GRINS::FactoryAbstract< Base >::get_factory ( const std::string &  name)
inlinestaticprotected

Helper method that looks up the factory and returns it if present, or error if it's not.

Definition at line 94 of file factory_abstract.h.

95  {
96  if (!factory_map().count(name))
97  {
98  std::stringstream ss;
99  ss << "ERROR: Tried to build an unknown FactoryAbstract type: "
100  << name << std::endl
101  << "valid options are:" << std::endl;
102 
103  for( typename std::map<std::string,FactoryAbstract<Base>*>::const_iterator
104  it = factory_map().begin(); it != factory_map().end(); ++it )
105  ss << " " << it->first << std::endl;
106 
107  libmesh_error_msg(ss.str());
108  }
109 
110  FactoryAbstract<Base>* factory = factory_map()[name];
111  return *factory;
112  }
static std::map< std::string, FactoryAbstract< Base > * > & factory_map()
template<class Base >
template<typename DerivedType >
DerivedType & GRINS::FactoryAbstract< Base >::get_factory_subclass ( const std::string &  name)
inlinestaticprotected

Like get_factory, but will downcast to DerivedType.

Definition at line 117 of file factory_abstract.h.

118  {
119  FactoryAbstract<Base>& raw_factory = get_factory(name);
120  DerivedType& factory = libMesh::cast_ref<DerivedType&>(raw_factory);
121  return factory;
122  }
static FactoryAbstract< Base > & get_factory(const std::string &name)
Helper method that looks up the factory and returns it if present, or error if it's not...

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

Generated on Tue Dec 19 2017 12:47:30 for GRINS-0.8.0 by  doxygen 1.8.9.1