PSCF v1.5.0
TrajectoryReaderFactory.tpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "TrajectoryReaderFactory.h"
9
10// Subclasses of TrajectoryReader
11#include <rp/fts/trajectory/RGridTrajectoryReader.h>
12
13namespace Pscf {
14namespace Rp {
15
16 using namespace Util;
17
18 /*
19 * Constructor
20 */
21 template <int D, class T>
22 TrajectoryReaderFactory<D,T>::TrajectoryReaderFactory(
23 System<D,T>& system)
24 : sysPtr_(&system)
25 {}
26
27 /*
28 * Return pointer to an instance of TrajectoryReader subclass className.
29 */
30 template <int D, class T>
31 TrajectoryReader<D,T>*
32 TrajectoryReaderFactory<D,T>::factory(const std::string &className) const
33 {
34 TrajectoryReader<D,T>* ptr = 0;
35
36 // Try subfactories first
37 ptr = trySubfactories(className);
38 if (ptr) return ptr;
39
40 if (className == "RGridTrajectoryReader"
41 || className == "TrajectoryReader") {
42 ptr = new RGridTrajectoryReader<D,T>(*sysPtr_);
43 }
44
45 return ptr;
46 }
47
48}
49}
Base class template for classes that represent a complete system.
TrajectoryReader< D, T > * factory(const std::string &className) const
Create and instance of a specified subclass of TrajectoryReader.
Trajectory file reader (abstract base class).
TrajectoryReader< D, T > * trySubfactories(const std::string &className) const
Definition Factory.h:427
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.