template<class Derived, class Base> class FactoryImp< Derived, Base >
Factory implementation class.
Definition at line 82 of file factory.h.
Constructor & Destructor Documentation
template<class Derived, class Base> FactoryImp< Derived, Base >::FactoryImp (const std::string &name) [inline]Constructor. Takes a name as input.
Definition at line 89 of file factory.h.
: Factory<Base>(name) { }
template<class Derived, class Base> FactoryImp< Derived, Base >::~FactoryImp () [inline]Destructor. Empty.
Definition at line 94 of file factory.h.
{}
Member Function Documentation
template<class Base > AutoPtr< Base > Factory< Base >::build (const std::string &name) [inline, static, inherited]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 Derived , class Base > AutoPtr< Base > FactoryImp< Derived, Base >::create () [inline, private, virtual]Returns:
a new object of type Derived.
Implements Factory< Base >.
Definition at line 168 of file factory.h.
{
// Do this the stoopid way for IBM xlC
AutoPtr<Base> ret_val (new Derived);
return ret_val;
}
template<class Base> static std::map<std::string, Factory<Base>*>& Factory< Base >::factory_map () [static, protected, inherited]Map from a name to a Factory<Base>* pointer.