Cantera  3.0.0
Loading...
Searching...
No Matches
WallFactory.cpp
Go to the documentation of this file.
1//! @file WallFactory.cpp
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
8
9namespace Cantera
10{
11
12WallFactory* WallFactory::s_factory = 0;
13std::mutex WallFactory::wall_mutex;
14
15WallFactory::WallFactory()
16{
17 reg("Wall", []() { return new Wall(); });
18}
19
20WallFactory* WallFactory::factory() {
21 std::unique_lock<std::mutex> lock(wall_mutex);
22 if (!s_factory) {
23 s_factory = new WallFactory;
24 }
25 return s_factory;
26}
27
29 std::unique_lock<std::mutex> lock(wall_mutex);
30 delete s_factory;
31 s_factory = 0;
32}
33
34WallBase* WallFactory::newWall(const string& wallType)
35{
36 warn_deprecated("WallFactory::newWall",
37 "To be removed after Cantera 3.0; for new behavior, see 'newWall3'.");
38 return create(wallType);
39}
40
41WallBase* newWall(const string& model)
42{
43 warn_deprecated("newWall",
44 "To be changed after Cantera 3.0; for new behavior, see 'newWall3'.");
45 return WallFactory::factory()->newWall(model);
46}
47
48shared_ptr<WallBase> newWall3(const string& model)
49{
50 shared_ptr<WallBase> wptr(WallFactory::factory()->create(model));
51 return wptr;
52}
53
54}
Header file for base class WallBase.
WallBase * create(const string &name, Args... args)
Create an object using the object construction function corresponding to "name" and the provided cons...
Definition FactoryBase.h:75
void reg(const string &name, function< WallBase *(Args...)> f)
Register a new object construction function.
Definition FactoryBase.h:80
Base class for 'walls' (walls, pistons, etc.) connecting reactors.
Definition Wall.h:22
void deleteFactory() override
Virtual abstract function that deletes the factory.
WallBase * newWall(const string &wallType)
Create a new wall by type name.
shared_ptr< WallBase > newWall3(const string &model)
Create a WallBase object of the specified type.
WallBase * newWall(const string &model)
Create a WallBase object of the specified type.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1926