$extrastylesheet
libMesh::Factory< Base > Class Template Reference

#include <factory.h>

Inheritance diagram for libMesh::Factory< Base >:

List of all members.

Public Member Functions

virtual ~Factory ()
virtual UniquePtr< Base > create ()=0

Static Public Member Functions

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

Protected Member Functions

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

Static Protected Member Functions

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

Detailed Description

template<class Base>
class libMesh::Factory< Base >

Factory class defintion.

Definition at line 42 of file factory.h.


Constructor & Destructor Documentation

template<class Base >
libMesh::Factory< Base >::Factory ( const std::string &  name) [inline, protected]

Constructor. Takes the name to be mapped.

Definition at line 113 of file factory.h.

References libMesh::libmesh_assert(), and libMesh::Quality::name().

{
  // Make sure we haven't already added this name
  // to the map
  libmesh_assert (!factory_map().count(name));

  factory_map()[name] = this;
}
template<class Base>
virtual libMesh::Factory< Base >::~Factory ( ) [inline, virtual]

Destructor. (Empty.)

Definition at line 56 of file factory.h.

{}

Member Function Documentation

template<class Base >
UniquePtr< Base > libMesh::Factory< Base >::build ( const std::string &  name) [inline, static]

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().

{
  // name not found in the map
  if (!factory_map().count(name))
    {
      libMesh::err << "Tried to build an unknown type: " << name << std::endl;

      libMesh::err << "valid options are:" << std::endl;

      for (typename std::map<std::string,Factory<Base>*>::const_iterator
             it = factory_map().begin(); it != factory_map().end(); ++it)
        libMesh::err << "  " << it->first << std::endl;

      libmesh_error_msg("Exiting...");

      // We'll never get here
      return UniquePtr<Base>();
    }

  Factory<Base> *f = factory_map()[name];
  return UniquePtr<Base>(f->create());
}
template<class Base>
virtual UniquePtr<Base> libMesh::Factory< Base >::create ( ) [pure virtual]

Create a Base class. Force this to be implemented later.

Implemented in libMesh::FactoryImp< Derived, Base >.

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

template<>
std::map< std::string, Factory< Partitioner > * > & libMesh::Factory< Partitioner >::factory_map ( ) [protected]

Definition at line 40 of file partitioner_factory.C.

{
  static std::map<std::string, Factory<Partitioner>*> _map;
  return _map;
}
template<class Base>
static std::map<std::string, Factory<Base>*>& libMesh::Factory< Base >::factory_map ( ) [static, protected]

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


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