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

#include <HydrodynamicsModelFactory.hpp>

Public Types

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

Public Member Functions

 ~HydrodynamicsModelFactory ()
 
bool registerHydrodynamicsModel (HydrodynamicsModelCreator *creator)
 
bool unregisterHydrodynamicsModel (const std::string &id)
 
HydrodynamicsModelcreateHydrodynamicsModel (const std::string &id, StuntDouble *sd, SimInfo *info)
 
IdentVectorType getIdents ()
 

Static Public Member Functions

static HydrodynamicsModelFactorygetInstance ()
 

Private Member Functions

 HydrodynamicsModelFactory ()
 

Private Attributes

CreatorMapType creatorMap_
 

Static Private Attributes

static HydrodynamicsModelFactoryinstance_ = NULL
 

Detailed Description

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

Definition at line 70 of file HydrodynamicsModelFactory.hpp.

Member Typedef Documentation

◆ CreatorMapType

◆ IdentVectorIterator

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

Definition at line 75 of file HydrodynamicsModelFactory.hpp.

◆ IdentVectorType

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

Definition at line 74 of file HydrodynamicsModelFactory.hpp.

Constructor & Destructor Documentation

◆ ~HydrodynamicsModelFactory()

OpenMD::HydrodynamicsModelFactory::~HydrodynamicsModelFactory ( )

Definition at line 52 of file HydrodynamicsModelFactory.cpp.

References creatorMap_.

◆ HydrodynamicsModelFactory()

OpenMD::HydrodynamicsModelFactory::HydrodynamicsModelFactory ( )
inlineprivate

Definition at line 125 of file HydrodynamicsModelFactory.hpp.

Referenced by getInstance().

Member Function Documentation

◆ createHydrodynamicsModel()

HydrodynamicsModel * OpenMD::HydrodynamicsModelFactory::createHydrodynamicsModel ( const std::string &  id,
StuntDouble sd,
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
sda pointer to the StuntDouble being modeled
infoa pointer to the SimInfo object

Definition at line 69 of file HydrodynamicsModelFactory.cpp.

References creatorMap_.

Referenced by getInstance(), and main().

◆ getIdents()

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

Returns all of the registed type identifiers

Returns
all of the registed type identifiers

Definition at line 79 of file HydrodynamicsModelFactory.cpp.

References creatorMap_.

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

◆ getInstance()

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

◆ registerHydrodynamicsModel()

bool OpenMD::HydrodynamicsModelFactory::registerHydrodynamicsModel ( HydrodynamicsModelCreator creator)

Registers a creator with a type identifier

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

Definition at line 60 of file HydrodynamicsModelFactory.cpp.

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

Referenced by getInstance(), and registerHydrodynamicsModels().

◆ unregisterHydrodynamicsModel()

bool OpenMD::HydrodynamicsModelFactory::unregisterHydrodynamicsModel ( 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 65 of file HydrodynamicsModelFactory.cpp.

References creatorMap_.

Referenced by getInstance().

Member Data Documentation

◆ creatorMap_

CreatorMapType OpenMD::HydrodynamicsModelFactory::creatorMap_
private

◆ instance_

HydrodynamicsModelFactory * OpenMD::HydrodynamicsModelFactory::instance_ = NULL
staticprivate

Definition at line 126 of file HydrodynamicsModelFactory.hpp.

Referenced by getInstance().


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