Simpatico  v1.10
McCommandFactory.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 "McCommandFactory.h" // class header
9 
10 #include <mcMd/mcSimulation/McSimulation.h>
11 #include <mcMd/mcSimulation/McSystem.h>
12 
13 // Commands
14 #include <mcMd/commands/McDeformCommand.h>
15 
16 namespace McMd
17 {
18 
19  using namespace Util;
20 
21  /*
22  * Constructor.
23  */
25  McSystem& system)
26  : simulationPtr_(&simulation),
27  systemPtr_(&system)
28  {}
29 
30  /*
31  * Return a pointer to a instance of Command subclass className.
32  */
33  Command* McCommandFactory::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 == "McDeformCommand") {
42  ptr = new McDeformCommand(system());
43  }
44 
45  return ptr;
46  }
47 
48 }
A System for use in a Markov chain Monte Carlo simulation.
Definition: McSystem.h:52
McSystem & system() const
Return reference to parent McSystem.
Command to deform the unit cell.
virtual Command * factory(const std::string &className) const
Return pointer to a new Command object.
A Monte-Carlo simulation of one McSystem.
Definition: McSimulation.h:32
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).
McCommandFactory(McSimulation &simulation, McSystem &system)
Constructor.