Cantera  2.1.2
ReactorFactory.h
Go to the documentation of this file.
1 /**
2  * @file ReactorFactory.h
3  */
4 // Copyright 2001 California Institute of Technology
5 
6 
7 #ifndef REACTOR_FACTORY_H
8 #define REACTOR_FACTORY_H
9 
10 #include "ReactorBase.h"
12 #include "cantera/base/ct_thread.h"
13 
14 namespace Cantera
15 {
16 
17 class ReactorFactory : Cantera::FactoryBase
18 {
19 
20 public:
21 
22  static ReactorFactory* factory() {
23  ScopedLock lock(reactor_mutex);
24  if (!s_factory) {
25  s_factory = new ReactorFactory;
26  }
27  return s_factory;
28  }
29 
30  virtual void deleteFactory() {
31  ScopedLock lock(reactor_mutex);
32  if (s_factory) {
33  delete s_factory;
34  s_factory = 0;
35  }
36  }
37 
38  /**
39  * Create a new reactor.
40  * @param n the type to be created.
41  */
42  virtual ReactorBase* newReactor(int n);
43  virtual ReactorBase* newReactor(const std::string& reactorType);
44 
45 private:
46  static ReactorFactory* s_factory;
47  static mutex_t reactor_mutex;
48  ReactorFactory() {}
49 };
50 
51 inline ReactorBase* newReactor(const std::string& model,
52  ReactorFactory* f=0)
53 {
54  if (f == 0) {
55  f = ReactorFactory::factory();
56  }
57  return f->newReactor(model);
58 }
59 
60 }
61 
62 #endif
63 
64 
65 
Base class for factories.
Definition: FactoryBase.h:18
File contains the FactoryBase class declarations.