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

#include <factory.h>

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

List of all members.

Public Member Functions

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

Static Public Member Functions

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

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.

00091 : Factory<Base>(name) { }

template<class Derived, class Base>
libMesh::FactoryImp< Derived, Base >::~FactoryImp (  )  [inline]

Destructor. Empty.

Definition at line 96 of file factory.h.

00096 {}


Member Function Documentation

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

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::Factory< Base >::factory_map().

00127 {
00128   // name not found in the map
00129   if (!factory_map().count(name))
00130     {
00131       libMesh::err << "Tried to build an unknown type: " << name << std::endl;
00132 
00133       libMesh::err << "valid options are:" << std::endl;
00134 
00135       for (typename std::map<std::string,Factory<Base>*>::const_iterator
00136              it = factory_map().begin(); it != factory_map().end(); ++it)
00137         libMesh::err << "  " << it->first << std::endl;
00138 
00139       libmesh_error();
00140 
00141       // Do this the stoopid way for IBM xlC
00142       AutoPtr<Base> ret_val (NULL);
00143 
00144       return ret_val;
00145     }
00146 
00147   // Do this the stoopid way for IBM xlC
00148   Factory<Base> *f = factory_map()[name];
00149 
00150   AutoPtr<Base> ret_val (f->create());
00151 
00152   return ret_val;
00153 }

template<class Derived , class Base >
AutoPtr< Base > libMesh::FactoryImp< Derived, Base >::create (  )  [inline, private, virtual]
Returns:
a new object of type Derived.

Implements libMesh::Factory< Base >.

Definition at line 170 of file factory.h.

00171 {
00172   // Do this the stoopid way for IBM xlC
00173   AutoPtr<Base> ret_val (new Derived);
00174 
00175   return ret_val;
00176 }

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

Definition at line 40 of file partitioner_factory.C.

00041 {
00042   static std::map<std::string, Factory<Partitioner>*> _map;
00043   return _map;
00044 }

template<class Base>
static std::map<std::string, Factory<Base>*>& libMesh::Factory< Base >::factory_map (  )  [static, protected, inherited]

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

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


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

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:21 UTC

Hosted By:
SourceForge.net Logo