OpenMD  2.5
Molecular Dynamics in the Open
OpenMD::OptimizationFactory Class Reference

#include <OptimizationFactory.hpp>

Public Types

typedef std::map< std::string, OptimizationCreator * > CreatorMapType
 
typedef std::vector< std::string > IdentVectorType
 
typedef std::vector< std::string >::iterator IdentVectorIterator
 

Public Member Functions

 ~OptimizationFactory ()
 
bool registerOptimization (OptimizationCreator *creator)
 
bool unregisterOptimization (const std::string &id)
 
QuantLib::OptimizationMethodcreateOptimization (const std::string &id, SimInfo *info)
 
IdentVectorType getIdents ()
 

Static Public Member Functions

static OptimizationFactorygetInstance ()
 

Private Member Functions

 OptimizationFactory ()
 

Private Attributes

CreatorMapType creatorMap_
 

Static Private Attributes

static OptimizationFactoryinstance_ = NULL
 

Detailed Description

Factory pattern and Singleton Pattern are used to define an interface for creating an Optimization.

Definition at line 62 of file OptimizationFactory.hpp.

Member Typedef Documentation

◆ CreatorMapType

Definition at line 65 of file OptimizationFactory.hpp.

◆ IdentVectorIterator

typedef std::vector<std::string>::iterator OpenMD::OptimizationFactory::IdentVectorIterator

Definition at line 67 of file OptimizationFactory.hpp.

◆ IdentVectorType

typedef std::vector<std::string> OpenMD::OptimizationFactory::IdentVectorType

Definition at line 66 of file OptimizationFactory.hpp.

Constructor & Destructor Documentation

◆ ~OptimizationFactory()

OpenMD::OptimizationFactory::~OptimizationFactory ( )

Definition at line 51 of file OptimizationFactory.cpp.

References creatorMap_.

◆ OptimizationFactory()

OpenMD::OptimizationFactory::OptimizationFactory ( )
inlineprivate

Definition at line 116 of file OptimizationFactory.hpp.

Member Function Documentation

◆ createOptimization()

QuantLib::OptimizationMethod * OpenMD::OptimizationFactory::createOptimization ( const std::string &  id,
SimInfo info 
)

Looks up the type identifier in the internal map. If it is found, it invokes the corresponding creator for the type identifier and returns its result.

Returns
a pointer of the concrete object, return NULL if no creator is registed for creating this concrete object
Parameters
idthe identification of the concrete object
infopointer to the SimInfo object

Definition at line 68 of file OptimizationFactory.cpp.

References creatorMap_.

Referenced by OpenMD::FluctuatingChargePropagator::initialize(), and main().

◆ getIdents()

std::vector< std::string > OpenMD::OptimizationFactory::getIdents ( )

Returns all of the registed type identifiers

Returns
all of the registed type identifiers

Definition at line 78 of file OptimizationFactory.cpp.

References creatorMap_.

Referenced by OpenMD::operator<<().

◆ getInstance()

static OptimizationFactory* OpenMD::OptimizationFactory::getInstance ( )
inlinestatic

Returns an instance of Optimization factory

Returns
an instance of Optimization factory

Definition at line 75 of file OptimizationFactory.hpp.

Referenced by OpenMD::FluctuatingChargePropagator::initialize(), and main().

◆ registerOptimization()

bool OpenMD::OptimizationFactory::registerOptimization ( OptimizationCreator creator)

Registers a creator with a type identifier

Returns
true if registration is succeed, otherwise return false
Parameters
creatorthe object responsible to create the concrete object

Definition at line 59 of file OptimizationFactory.cpp.

References creatorMap_, and OpenMD::OptimizationCreator::getIdent().

◆ unregisterOptimization()

bool OpenMD::OptimizationFactory::unregisterOptimization ( const std::string &  id)

Unregisters the creator for the given type identifier. If the type identifier was previously registered, the function returns true.

Returns
truethe type identifier was previously registered and the creator is removed, otherwise return false
Parameters
idthe identification of the concrete object

Definition at line 64 of file OptimizationFactory.cpp.

References creatorMap_.

Member Data Documentation

◆ creatorMap_

CreatorMapType OpenMD::OptimizationFactory::creatorMap_
private

◆ instance_

OptimizationFactory * OpenMD::OptimizationFactory::instance_ = NULL
staticprivate

Definition at line 118 of file OptimizationFactory.hpp.


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