Simpatico  v1.10
tools/analyzers/AnalyzerFactory.cpp
1 #ifndef MDCF_ANALYZER_FACTORY_CPP
2 #define MDCF_ANALYZER_FACTORY_CPP
3 
4 /*
5 * Simpatico - Processor Package for Polymeric and Molecular Liquids
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include "AnalyzerFactory.h" // Class header
12 
13 #include <tools/processor/Processor.h>
14 
15 // Analyzers
16 #include "LogStep.h"
17 #include "LammpsDumpWriter.h"
18 
19 namespace Tools
20 {
21 
22  using namespace Util;
23 
24  /*
25  * Constructor.
26  */
27  AnalyzerFactory::AnalyzerFactory(Processor& processor)
28  : processorPtr_(&processor)
29  {}
30 
31  /*
32  * Return a pointer to an instance of Analyzer subclass className.
33  */
34  Analyzer* AnalyzerFactory::factory(const std::string &className) const
35  {
36  Analyzer* ptr = 0;
37 
38  // Try subfactories first (if any)
39  ptr = trySubfactories(className);
40  if (ptr) return ptr;
41 
42  // Analyzers
43  if (className == "LogStep") {
44  ptr = new LogStep(processor());
45  } else
46  if (className == "LammpsDumpWriter") {
47  ptr = new LammpsDumpWriter(processor());
48  }
49  return ptr;
50  }
51 
52 }
53 #endif
Analyzer * 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.
virtual Analyzer * factory(const std::string &className) const
Return pointer to a new Analyzer object.