libMesh::FactoryImp< Derived, Base > Class Template Reference

#include <factory.h>

Inheritance diagram for libMesh::FactoryImp< Derived, Base >:

Public Member Functions

 FactoryImp (const std::string &name)
 
 ~FactoryImp ()
 

Static Public Member Functions

static AutoPtr< Base > build (const std::string &name)
 

Protected Member Functions

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

Static Protected Member Functions

static std::map< std::string,
Factory< Base > * > & 
factory_map ()
 

Private Member Functions

AutoPtr< Base > create ()
 

Detailed Description

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

Factory implementation class.

Definition at line 84 of file factory.h.

Constructor & Destructor Documentation

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

Constructor. Takes a name as input.

Definition at line 91 of file factory.h.

91 : Factory<Base>(name) { }
template<class Derived, class Base>
libMesh::FactoryImp< Derived, Base >::~FactoryImp ( )
inline

Destructor. Empty.

Definition at line 96 of file factory.h.

96 {}

Member Function Documentation

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

Builds an object of type Base identified by name.

Definition at line 126 of file factory.h.

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

127 {
128  // name not found in the map
129  if (!factory_map().count(name))
130  {
131  libMesh::err << "Tried to build an unknown type: " << name << std::endl;
132 
133  libMesh::err << "valid options are:" << std::endl;
134 
135  for (typename std::map<std::string,Factory<Base>*>::const_iterator
136  it = factory_map().begin(); it != factory_map().end(); ++it)
137  libMesh::err << " " << it->first << std::endl;
138 
139  libmesh_error();
140 
141  // Do this the stoopid way for IBM xlC
142  AutoPtr<Base> ret_val (NULL);
143 
144  return ret_val;
145  }
146 
147  // Do this the stoopid way for IBM xlC
148  Factory<Base> *f = factory_map()[name];
149 
150  AutoPtr<Base> ret_val (f->create());
151 
152  return ret_val;
153 }
template<class Derived , class Base >
AutoPtr< Base > libMesh::FactoryImp< Derived, Base >::create ( )
inlineprivatevirtual
Returns
a new object of type Derived.

Implements libMesh::Factory< Base >.

Definition at line 170 of file factory.h.

171 {
172  // Do this the stoopid way for IBM xlC
173  AutoPtr<Base> ret_val (new Derived);
174 
175  return ret_val;
176 }
template<>
std::map< std::string, Factory< Partitioner > * > & libMesh::Factory< Partitioner >::factory_map ( )
protectedinherited

Definition at line 40 of file partitioner_factory.C.

41 {
42  static std::map<std::string, Factory<Partitioner>*> _map;
43  return _map;
44 }
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.


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:00 UTC

Hosted By:
SourceForge.net Logo