template<class Base > Factory< Base >::Factory (const std::string &name) [inline, protected]Constructor. Takes the name to be mapped.
Definition at line 111 of file factory.h.
References 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 Factory< Base >::~Factory () [inline, virtual]Destructor. (Empty.)
Definition at line 54 of file factory.h.
{}
Member Function Documentation
template<class Base > AutoPtr< Base > Factory< Base >::build (const std::string &name) [inline, static]Builds an object of type Base identified by name.
Definition at line 124 of file factory.h.
References Factory< Base >::create(), and Quality::name().
{
// name not found in the map
if (!factory_map().count(name))
{
std::cerr << 'Tried to build an unknown type: ' << name << std::endl;
std::cerr << 'valid options are:' << std::endl;
for (typename std::map<std::string,Factory<Base>*>::const_iterator
it = factory_map().begin(); it != factory_map().end(); ++it)
std::cerr << ' ' << it->first << std::endl;
libmesh_error();
// Do this the stoopid way for IBM xlC
AutoPtr<Base> ret_val (NULL);
return ret_val;
}
// Do this the stoopid way for IBM xlC
Factory<Base> *f = factory_map()[name];
AutoPtr<Base> ret_val (f->create());
return ret_val;
}
template<class Base> virtual AutoPtr<Base> Factory< Base >::create () [pure virtual]Create a Base class. Force this to be implemented later.
Implemented in FactoryImp< Derived, Base >.
Referenced by Factory< Base >::build().
template<class Base> static std::map<std::string, Factory<Base>*>& Factory< Base >::factory_map () [static, protected]Map from a name to a Factory<Base>* pointer.