Cantera  2.3.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 //! @deprecated The `ReactorFactory*` argument to this function is deprecated and
47 //! will be removed after Cantera 2.3.
48 inline ReactorBase* newReactor(const std::string& model,
49  ReactorFactory* f=0)
50 {
51  if (f == 0) {
52  f = ReactorFactory::factory();
53  } else {
54  warn_deprecated("newReactor(string, ReactorFactory*)",
55  "The `ReactorFactory*` argument to this function is deprecated and"
56  " will be removed after Cantera 2.3.");
57  }
58  return f->newReactor(model);
59 }
60 
61 }
62 
63 #endif
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
ReactorBase * newReactor(const std::string &model, ReactorFactory *f=0)
Create a Reactor object of the specified type.
Base class for stirred reactors.
Definition: ReactorBase.h:44
Namespace for the Cantera kernel.
Definition: application.cpp:29
File contains the FactoryBase class declarations.