Cantera  2.4.0
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 http://www.cantera.org/license.txt for license and copyright information.
5 
6 #ifndef REACTOR_FACTORY_H
7 #define REACTOR_FACTORY_H
8 
9 #include "ReactorBase.h"
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  /**
33  * Create a new reactor.
34  * @param n the type to be created.
35  */
36  virtual ReactorBase* newReactor(int n);
37  virtual ReactorBase* newReactor(const std::string& reactorType);
38 
39 private:
40  static ReactorFactory* s_factory;
41  static std::mutex reactor_mutex;
42  ReactorFactory();
43 };
44 
45 //! Create a Reactor object of the specified type
46 inline ReactorBase* newReactor(const std::string& model)
47 {
48  return ReactorFactory::factory()->newReactor(model);
49 }
50 
51 }
52 
53 #endif
Base class for stirred reactors.
Definition: ReactorBase.h:44
ReactorBase * newReactor(const std::string &model)
Create a Reactor object of the specified type.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
File contains the FactoryBase class declarations.