Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes | List of all members
FunctionFactory Class Reference

A Factory singleton class for creating objects whose class derives from FunctionBase. More...

#include <FunctionFactory.h>

Inheritance diagram for FunctionFactory:
Inheritance graph
[legend]
Collaboration diagram for FunctionFactory:
Collaboration graph
[legend]

Public Member Functions

void add (FunctionBase *)
 Adds a prototype object to the list of prototypes.
FunctionBasecreate (const std::string &name)
 Creates a new object from a prototype named name.
bool exists (const std::string &name) const
 Returns true if prototype with name name exists in the factory, otherwise returns false.
const std::vector< std::string > & names () const
 Returns the list of available prototype names.
FunctionBaseprototype (const std::string &name) const
 Returns a pointer to a prototype with name name.
void remove (const std::string &name)
 Removes the named prototype object from the list of prototypes.

Static Public Member Functions

static FunctionFactoryinstance ()
 Returns a pointer to the singleton instance.

Protected Member Functions

 FunctionFactory ()
 A default constructor for prevent creation except by the itself or the derived classes.

Protected Attributes

std::vector< std::string > m_names
 The list of available types by names.
std::map< std::string,
FunctionBase * > 
m_types
 A list of available types.

Private Member Functions

 FunctionFactory (const FunctionFactory &)
 A private copy constructor to prevent copying.
void initialize ()
 Initializes the factory with a set of default functions.

Static Private Attributes

static FunctionFactorys_instance = 0
 A pointer to the singleton object.

Detailed Description

A Factory singleton class for creating objects whose class derives from FunctionBase.

Requests:
Be able to add new functions from a shared library.
Author
Paul F. Kunz Paul_.nosp@m.Kunz.nosp@m.@slac.nosp@m..sta.nosp@m.nford.nosp@m..edu

Definition at line 31 of file FunctionFactory.h.

Constructor & Destructor Documentation

FunctionFactory ( const FunctionFactory )
private

A private copy constructor to prevent copying.

FunctionFactory ( )
protected

A default constructor for prevent creation except by the itself or the derived classes.

Definition at line 40 of file FunctionFactory.cxx.

Referenced by FunctionFactory::instance().

Member Function Documentation

void add ( FunctionBase )
inherited

Adds a prototype object to the list of prototypes.

Referenced by FunctionFactory::initialize().

FunctionBase * create ( const std::string &  name)
inherited

Creates a new object from a prototype named name.

If found, returns a new object by invoking the clone() member function of the prototype. If not found, throws a FactoryException object with the name not found.

bool exists ( const std::string &  name) const
inherited

Returns true if prototype with name name exists in the factory, otherwise returns false.

void initialize ( )
private

Initializes the factory with a set of default functions.

Definition at line 53 of file FunctionFactory.cxx.

References Factory< FunctionBase >::add().

Referenced by FunctionFactory::instance().

FunctionFactory * instance ( )
static

Returns a pointer to the singleton instance.

Definition at line 44 of file FunctionFactory.cxx.

References FunctionFactory::FunctionFactory(), FunctionFactory::initialize(), and FunctionFactory::s_instance.

const std::vector< std::string >& names ( ) const
inherited

Returns the list of available prototype names.

FunctionBase * prototype ( const std::string &  name) const
inherited

Returns a pointer to a prototype with name name.

If a prototype with name doesn't exit, throws a FactoryException object with the name not found.

void remove ( const std::string &  name)
inherited

Removes the named prototype object from the list of prototypes.

Member Data Documentation

std::vector< std::string > m_names
mutableprotectedinherited

The list of available types by names.

This list should be identical to the list of m_types keys. It is updated when the member function names is called.

Definition at line 58 of file Factory.h.

std::map< std::string, FunctionBase * > m_types
protectedinherited

A list of available types.

Definition at line 53 of file Factory.h.

FunctionFactory * s_instance = 0
staticprivate

A pointer to the singleton object.

Definition at line 37 of file FunctionFactory.h.

Referenced by FunctionFactory::instance().


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

Generated for HippoDraw Class Library by doxygen