Cantera  2.5.1
ReactorFactory.h
Go to the documentation of this file.
1 //! @file ReactorFactory.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 REACTOR_FACTORY_H
7 #define REACTOR_FACTORY_H
8 
11 
12 namespace Cantera
13 {
14 
15 class ReactorFactory : public Factory<ReactorBase>
16 {
17 public:
18  static ReactorFactory* factory() {
19  std::unique_lock<std::mutex> lock(reactor_mutex);
20  if (!s_factory) {
21  s_factory = new ReactorFactory;
22  }
23  return s_factory;
24  }
25 
26  virtual void deleteFactory() {
27  std::unique_lock<std::mutex> lock(reactor_mutex);
28  delete s_factory;
29  s_factory = 0;
30  }
31 
32  //! Create a new reactor by type identifier.
33  /*!
34  * @param n the type to be created.
35  */
36  virtual ReactorBase* newReactor(int n);
37 
38  //! Create a new reactor by type name.
39  /*!
40  * @param reactorType the type to be created.
41  */
42  virtual ReactorBase* newReactor(const std::string& reactorType);
43 
44  //! Register a new reactor type identifier.
45  /*!
46  * @param name the name of the reactor type.
47  * @param type the type identifier of the reactor.
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 reactor type identifier / reactor 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 ReactorFactory* s_factory;
63  static std::mutex reactor_mutex;
64  ReactorFactory();
65 };
66 
67 //! Create a Reactor object of the specified type
68 inline ReactorBase* newReactor(const std::string& model)
69 {
70  return ReactorFactory::factory()->newReactor(model);
71 }
72 
73 }
74 
75 #endif
File contains the FactoryBase class declarations.
Base class for stirred reactors.
Definition: ReactorBase.h:48
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
ReactorBase * newReactor(const std::string &model)
Create a Reactor object of the specified type.