Cantera  3.1.0a1
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 
7 #include "cantera/zeroD/Wall.h"
8 
9 namespace Cantera
10 {
11 
12 WallFactory* WallFactory::s_factory = 0;
13 std::mutex WallFactory::wall_mutex;
14 
15 WallFactory::WallFactory()
16 {
17  reg("Wall", []() { return new Wall(); });
18 }
19 
20 WallFactory* 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 
34 shared_ptr<WallBase> newWall(const string& model)
35 {
36  return shared_ptr<WallBase>(WallFactory::factory()->create(model));
37 }
38 
39 shared_ptr<WallBase> newWall3(const string& model)
40 {
41  return newWall(model);
42 }
43 
44 }
Header file for base class WallBase.
void reg(const string &name, function< WallBase *(Args...)> f)
Register a new object construction function.
Definition: FactoryBase.h:80
void deleteFactory() override
Virtual abstract function that deletes the factory.
Definition: WallFactory.cpp:28
shared_ptr< WallBase > newWall(const string &model)
Create a WallBase object of the specified type.
Definition: WallFactory.cpp:34
shared_ptr< WallBase > newWall3(const string &model)
Create a WallBase object of the specified type.
Definition: WallFactory.cpp:39
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:564