Cantera  2.4.0
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 
8 // This file is part of Cantera. See License.txt in the top-level directory or
9 // at http://www.cantera.org/license.txt for license and copyright information.
10 
11 #ifndef CT_NEWFALLOFF_H
12 #define CT_NEWFALLOFF_H
13 
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  */
30 class FalloffFactory : public Factory<Falloff>
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  std::unique_lock<std::mutex> lock(falloff_mutex);
40  if (!s_factory) {
42  }
43  return s_factory;
44  }
45 
46  virtual void deleteFactory() {
47  std::unique_lock<std::mutex> 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  * @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 std::mutex 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.
static std::mutex 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:28
Factory class that supports registering functions to create objects.
Definition: FactoryBase.h:71
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.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
File contains the FactoryBase class declarations.