Poster of Linux kernelThe best gift for a Linux geek
Factory

Factory

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

Factory -  

SYNOPSIS


#include <factory.h>

Inherited by FactoryImp< Derived, Base >.  

Public Member Functions


virtual ~Factory ()

virtual AutoPtr< Base > create ()=0
 

Static Public Member Functions


static AutoPtr< 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 Factory< Base >

Factory class defintion.

Definition at line 40 of file factory.h.  

Constructor & Destructor Documentation

 

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.

 

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

Definition at line 39 of file partitioner_factory.C.

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

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Static Public Member Functions
Protected Member Functions
Static Protected Member Functions
Detailed Description
template<class Base> class Factory< Base >
Constructor & Destructor Documentation
template<class Base > Factory< Base >::Factory (const std::string &name) [inline, protected]Constructor. Takes the name to be mapped.
template<class Base> virtual Factory< Base >::~Factory () [inline, virtual]Destructor. (Empty.)
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.
template<class Base> virtual AutoPtr<Base> Factory< Base >::create () [pure virtual]Create a Base class. Force this to be implemented later.
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.
template<> std::map< std::string, Factory< Partitioner > * > & Factory< Partitioner >::factory_map () [protected]
Author

This document was created by man2html, using the manual pages.
Time: 21:45:57 GMT, April 16, 2011