OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
OpenMD::LatticeFactory Class Reference

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

#include <LatticeFactory.hpp>

Public Types

using CreatorMapType = std::map<std::string, LatticeCreator*>
 
using IdentVectorType = std::vector<std::string>
 
using IdentVectorIterator = std::vector<std::string>::iterator
 

Public Member Functions

bool registerLattice (LatticeCreator *creator)
 Registers a creator with a type identifier.
 
bool unregisterLattice (const std::string &id)
 Unregisters the creator for the given type identifier.
 
LatticecreateLattice (const std::string &id)
 Looks up the type identifier in the internal map.
 
IdentVectorType getIdents ()
 Returns all of the registed type identifiers.
 

Static Public Member Functions

static LatticeFactorygetInstance ()
 Returns an instance of Lattice factory.
 

Detailed Description

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

Definition at line 71 of file LatticeFactory.hpp.

Member Typedef Documentation

◆ CreatorMapType

using OpenMD::LatticeFactory::CreatorMapType = std::map<std::string, LatticeCreator*>

Definition at line 73 of file LatticeFactory.hpp.

◆ IdentVectorIterator

using OpenMD::LatticeFactory::IdentVectorIterator = std::vector<std::string>::iterator

Definition at line 75 of file LatticeFactory.hpp.

◆ IdentVectorType

using OpenMD::LatticeFactory::IdentVectorType = std::vector<std::string>

Definition at line 74 of file LatticeFactory.hpp.

Member Function Documentation

◆ createLattice()

Lattice * OpenMD::LatticeFactory::createLattice ( const std::string & id)

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

Definition at line 64 of file LatticeFactory.cpp.

◆ getIdents()

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

Returns all of the registed type identifiers.

Returns
all of the registed type identifiers

Definition at line 74 of file LatticeFactory.cpp.

Referenced by OpenMD::operator<<().

◆ getInstance()

static LatticeFactory & OpenMD::LatticeFactory::getInstance ( )
inlinestatic

Returns an instance of Lattice factory.

Returns
an instance of Lattice factory

Definition at line 81 of file LatticeFactory.hpp.

Referenced by OpenMD::registerLattice().

◆ registerLattice()

bool OpenMD::LatticeFactory::registerLattice ( LatticeCreator * 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 54 of file LatticeFactory.cpp.

Referenced by OpenMD::registerLattice().

◆ unregisterLattice()

bool OpenMD::LatticeFactory::unregisterLattice ( 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 60 of file LatticeFactory.cpp.


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