Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  delete s_factory;
33  s_factory = 0;
34  }
35 
36  /**
37  * Create a new reactor.
38  * @param n the type to be created.
39  */
40  virtual ReactorBase* newReactor(int n);
41  virtual ReactorBase* newReactor(const std::string& reactorType);
42 
43 private:
44  static ReactorFactory* s_factory;
45  static mutex_t reactor_mutex;
46  ReactorFactory() {}
47 };
48 
49 inline ReactorBase* newReactor(const std::string& model,
50  ReactorFactory* f=0)
51 {
52  if (f == 0) {
53  f = ReactorFactory::factory();
54  }
55  return f->newReactor(model);
56 }
57 
58 }
59 
60 #endif
Base class for factories.
Definition: FactoryBase.h:18
File contains the FactoryBase class declarations.