Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FalloffFactory.h
Go to the documentation of this file.
1 /**
2  * @file FalloffFactory.h
3  * Parameterizations for reaction falloff functions. Used by classes
4  * that implement gas-phase kinetics (GasKinetics, GRI_30_Kinetics)
5  * (see \ref falloffGroup and class \link Cantera::Falloff Falloff\endlink).
6  */
7 // Copyright 2001 California Institute of Technology
8 
9 #ifndef CT_NEWFALLOFF_H
10 #define CT_NEWFALLOFF_H
11 
13 #include "cantera/base/ct_thread.h"
14 #include "cantera/base/smart_ptr.h"
15 #include "cantera/kinetics/Falloff.h"
16 
17 namespace Cantera
18 {
19 
20 /**
21  * Factory class to construct falloff function calculators.
22  * The falloff factory is accessed through static method factory:
23  *
24  * @code
25  * Falloff* f = FalloffFactory::factory()->newFalloff(type, c)
26  * @endcode
27  *
28  * @ingroup falloffGroup
29  */
31 {
32 public:
33  /**
34  * Return a pointer to the factory. On the first call, a new instance is
35  * created. Since there is no need to instantiate more than one factory,
36  * on all subsequent calls, a pointer to the existing factory is returned.
37  */
38  static FalloffFactory* factory() {
39  ScopedLock lock(falloff_mutex);
40  if (!s_factory) {
42  }
43  return s_factory;
44  }
45 
46  virtual void deleteFactory() {
47  ScopedLock lock(falloff_mutex);
48  delete s_factory;
49  s_factory = 0;
50  }
51 
52  //! Return a pointer to a new falloff function calculator.
53  /*!
54  * @param type Integer flag specifying the type of falloff function. The
55  * standard types are defined in file reaction_defs.h. A
56  * factory class derived from FalloffFactory may define other
57  * types as well.
58  * @param c input vector of doubles which populates the falloff
59  * parameterization.
60  * @return Returns a pointer to a new Falloff class.
61  */
62  virtual Falloff* newFalloff(int type, const vector_fp& c);
63 
64 private:
65  //! Pointer to the single instance of the factory
67 
68  //! default constructor, which is defined as private
70 
71  //! Mutex for use when calling the factory
72  static mutex_t falloff_mutex;
73 };
74 
75 //! @copydoc FalloffFactory::newFalloff
76 shared_ptr<Falloff> newFalloff(int type, const vector_fp& c);
77 
78 }
79 #endif
virtual Falloff * newFalloff(int type, const vector_fp &c)
Return a pointer to a new falloff function calculator.
shared_ptr< Falloff > newFalloff(int type, const vector_fp &c)
Return a pointer to a new falloff function calculator.
Base class for factories.
Definition: FactoryBase.h:18
static mutex_t falloff_mutex
Mutex for use when calling the factory.
FalloffFactory()
default constructor, which is defined as private
static FalloffFactory * factory()
Return a pointer to the factory.
virtual void deleteFactory()
Virtual abstract function that deletes the factory.
static FalloffFactory * s_factory
Pointer to the single instance of the factory.
Base class for falloff function calculators.
Definition: Falloff.h:23
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
Factory class to construct falloff function calculators.
File contains the FactoryBase class declarations.