Simpatico  v1.10
ConfigReaderFactory.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 "ConfigReaderFactory.h"
9 
10 // Subclasses of ConfigReader
11 #include "DdMdConfigReader.h"
12 #include "HoomdConfigReader.h"
13 
14 namespace Tools
15 {
16 
17  using namespace Util;
18 
19  /*
20  * Constructor
21  */
23  : configurationPtr_(&configuration)
24  {}
25 
26  /*
27  * Return a pointer to a instance of ConfigReader subclass className.
28  */
29  ConfigReader* ConfigReaderFactory::factory(const std::string &className) const
30  {
31  ConfigReader *ptr = 0;
32 
33  // Try subfactories first.
34  ptr = trySubfactories(className);
35  if (ptr) return ptr;
36 
37  if (className == "DdMdConfigReader") {
38  ptr = new DdMdConfigReader(*configurationPtr_);
39  } else
40  if (className == "DdMdConfigReader_Molecule") {
41  bool hasMolecules = true;
42  ptr = new DdMdConfigReader(*configurationPtr_, hasMolecules);
43  } else
44  if (className == "HoomdConfigReader") {
45  ptr = new HoomdConfigReader(*configurationPtr_);
46  }
47 
48  return ptr;
49  }
50 
51 }
Abstract reader/writer for configuration files.
Definition: ConfigReader.h:27
ConfigReader * factory(const std::string &subclassName) const
Create an instance of a specified subclass of ConfigReader.
Native / default DdMd format for configuration files.
An instantaneous molecular dynamics configuration.
Definition: Configuration.h:40
ConfigReader * trySubfactories(const std::string &className) const
Search through subfactories for match.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Single-processor classes for pre- and post-processing MD trajectories.
ConfigReaderFactory(Configuration &configuration)
Constructor.
Reader for Hoomd-blue XML configuration files.