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 AutoPtr< Base > create ()=0
template<>
std::map< std::string, Factory
< Partitioner > * > & 
factory_map ()

Static Public Member Functions

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

Protected Member Functions

 Factory (const std::string &name)

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

00114 {
00115   // Make sure we haven't already added this name
00116   // to the map
00117   libmesh_assert (!factory_map().count(name));
00118 
00119   factory_map()[name] = this;
00120 }

template<class Base>
virtual libMesh::Factory< Base >::~Factory (  )  [inline, virtual]

Destructor. (Empty.)

Definition at line 56 of file factory.h.

00056 {}


Member Function Documentation

template<class Base >
AutoPtr< 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::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 Base>
virtual AutoPtr<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 (  )  [inline]

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]

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