Simpatico  v1.10
MdCommandFactory.cpp
1 /*
2 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
3 *
4 * Copyright 2010 - 2017, The Regents of the University of Minnesota
5 * Distributed under the terms of the GNU General Public License.
6 */
7 
8 #include "MdCommandFactory.h" // Class header
9 
10 #include <mcMd/mdSimulation/MdSimulation.h>
11 #include <mcMd/mdSimulation/MdSystem.h>
12 
13 // Commands
14 #include <mcMd/commands/MdDeformCommand.h>
15 
16 namespace McMd
17 {
18 
19  using namespace Util;
20 
21  /*
22  * Constructor.
23  */
25  MdSystem& system)
26  : simulationPtr_(&simulation),
27  systemPtr_(&system)
28  {}
29 
30  /*
31  * Return a pointer to a instance of Command subclass className.
32  */
33  Command* MdCommandFactory::factory(const std::string &className) const
34  {
35  Command* ptr = 0;
36 
37  // Try subfactories first (if any)
38  ptr = trySubfactories(className);
39  if (ptr) return ptr;
40 
41  if (className == "MdDeformCommand") {
42  ptr = new MdDeformCommand(system());
43  }
44 
45  return ptr;
46  }
47 
48 }
MdCommandFactory(MdSimulation &simulation, MdSystem &system)
Constructor.
Command to deform the unit cell.
Command * trySubfactories(const std::string &className) const
Search through subfactories for match.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Command is an object that can be invoked from the command script.
Definition: Command.h:40
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
A System for Molecular Dynamics simulation.
Definition: MdSystem.h:68
virtual Command * factory(const std::string &className) const
Return pointer to a new Command object.
MdSystem & system() const
Return reference to parent MdSystem.
A molecular dynamics simulation of a single MdSystem.
Definition: MdSimulation.h:26