Cantera  2.5.1
WallFactory.h
Go to the documentation of this file.
1 //! @file WallFactory.h
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 
6 #ifndef WALL_FACTORY_H
7 #define WALL_FACTORY_H
8 
10 #include "cantera/zeroD/Wall.h"
11 
12 namespace Cantera
13 {
14 
15 class WallFactory : public Factory<WallBase>
16 {
17 public:
18  static WallFactory* factory() {
19  std::unique_lock<std::mutex> lock(wall_mutex);
20  if (!s_factory) {
21  s_factory = new WallFactory;
22  }
23  return s_factory;
24  }
25 
26  virtual void deleteFactory() {
27  std::unique_lock<std::mutex> lock(wall_mutex);
28  delete s_factory;
29  s_factory = 0;
30  }
31 
32  //! Create a new wall by type identifier.
33  /*!
34  * @param n the type to be created.
35  */
36  virtual WallBase* newWall(int n);
37 
38  //! Create a new wall by type name.
39  /*!
40  * @param wallType the type to be created.
41  */
42  virtual WallBase* newWall(const std::string& wallType);
43 
44  //! Register a new wall type identifier.
45  /*!
46  * @param name the name of the wall type.
47  * @param type the type identifier of the wall.
48  * Integer type identifiers are used by clib and matlab interfaces.
49  *
50  * @deprecated To be removed after Cantera 2.5.
51  */
52  void reg_type(const std::string& name, const int type) {
53  m_types[type] = name;
54  }
55 
56 protected:
57  //! Map containing wall type identifier / wall type name pairs.
58  //! @deprecated To be removed after Cantera 2.5.
59  std::unordered_map<int, std::string> m_types;
60 
61 private:
62  static WallFactory* s_factory;
63  static std::mutex wall_mutex;
64  WallFactory();
65 };
66 
67 //! Create a Wall object of the specified type
68 inline WallBase* newWall(const std::string& model)
69 {
70  return WallFactory::factory()->newWall(model);
71 }
72 
73 }
74 
75 #endif
File contains the FactoryBase class declarations.
Header file for base class WallBase.
Base class for 'walls' (walls, pistons, etc.) connecting reactors.
Definition: Wall.h:29
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
WallBase * newWall(const std::string &model)
Create a Wall object of the specified type.
Definition: WallFactory.h:68