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

#include <IntegratorFactory.hpp>

Public Types

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

Public Member Functions

 ~IntegratorFactory ()
 
bool registerIntegrator (IntegratorCreator *creator)
 
bool unregisterIntegrator (const std::string &id)
 
IntegratorcreateIntegrator (const std::string &id, SimInfo *info)
 
IdentVectorType getIdents ()
 

Static Public Member Functions

static IntegratorFactorygetInstance ()
 

Private Member Functions

 IntegratorFactory ()
 

Private Attributes

CreatorMapType creatorMap_
 

Static Private Attributes

static IntegratorFactoryinstance_ = NULL
 

Detailed Description

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

Definition at line 66 of file IntegratorFactory.hpp.

Member Typedef Documentation

◆ CreatorMapType

Definition at line 69 of file IntegratorFactory.hpp.

◆ IdentVectorIterator

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

Definition at line 71 of file IntegratorFactory.hpp.

◆ IdentVectorType

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

Definition at line 70 of file IntegratorFactory.hpp.

Constructor & Destructor Documentation

◆ ~IntegratorFactory()

OpenMD::IntegratorFactory::~IntegratorFactory ( )

Definition at line 51 of file IntegratorFactory.cpp.

References creatorMap_.

◆ IntegratorFactory()

OpenMD::IntegratorFactory::IntegratorFactory ( )
inlineprivate

Definition at line 120 of file IntegratorFactory.hpp.

Referenced by getInstance().

Member Function Documentation

◆ createIntegrator()

Integrator * OpenMD::IntegratorFactory::createIntegrator ( 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 string of the concrete object
infopointer to the concrete SimInfo object

Definition at line 68 of file IntegratorFactory.cpp.

References creatorMap_.

Referenced by getInstance(), and main().

◆ getIdents()

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

Returns all of the registed type identifiers

Returns
all of the registed type identifiers

Definition at line 78 of file IntegratorFactory.cpp.

References creatorMap_.

Referenced by getInstance(), and OpenMD::operator<<().

◆ getInstance()

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

Returns an instance of Integrator factory

Returns
an instance of Integrator factory

Definition at line 79 of file IntegratorFactory.hpp.

References createIntegrator(), getIdents(), instance_, IntegratorFactory(), registerIntegrator(), and unregisterIntegrator().

Referenced by main().

◆ registerIntegrator()

bool OpenMD::IntegratorFactory::registerIntegrator ( IntegratorCreator creator)

Registers a creator with a type identifier

Returns
true if registration is successful, otherwise return false
Parameters
creatorthe object responsible for creating the concrete object

Definition at line 59 of file IntegratorFactory.cpp.

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

Referenced by getInstance().

◆ unregisterIntegrator()

bool OpenMD::IntegratorFactory::unregisterIntegrator ( 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 IntegratorFactory.cpp.

References creatorMap_.

Referenced by getInstance().

Member Data Documentation

◆ creatorMap_

CreatorMapType OpenMD::IntegratorFactory::creatorMap_
private

◆ instance_

IntegratorFactory * OpenMD::IntegratorFactory::instance_ = NULL
staticprivate

Definition at line 121 of file IntegratorFactory.hpp.

Referenced by getInstance().


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