PSCF v1.5.0
EnvironmentFactory.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 "EnvironmentFactory.h"
9#include "FilmEnvironment.h"
10
11namespace Pscf {
12namespace Rp {
13
14 using namespace Util;
15
16 /*
17 * Constructor
18 */
19 template <int D, class T>
21 : sysPtr_(&system)
22 {}
23
24 /*
25 * Return a pointer to a instance of Environment subclass className.
26 */
27 template <int D, class T>
29 EnvironmentFactory<D,T>::factory(std::string const& className) const
30 {
31 Environment* ptr = nullptr;
32
33 // Try subfactories first
35 if (ptr) return ptr;
36
37 // Try to match classname
38 if (className == "FilmEnvironment") {
39 ptr = new FilmEnvironment<D,T>(*sysPtr_);
40 }
41
42 return ptr;
43 }
44
45}
46}
47
EnvironmentFactory(System< D, T > &system)
Constructor.
Environment * factory(const std::string &className) const
Method to create any Environment supplied with PSCF.
Environment generator for variable-cell SCFT.
Definition Environment.h:59
FilmEnvironment(System< D, T > &sys)
Constructor.
Base class template for classes that represent a complete system.
Data * trySubfactories(const std::string &className) const
Search through subfactories for match.
Definition Factory.h:427
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.