Cantera  2.5.1
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 https://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  * @deprecated To be removed after Cantera 2.5.
63  */
64  virtual Falloff* newFalloff(int type, const vector_fp& c);
65 
66  //! Return a pointer to a new falloff function calculator.
67  /*!
68  * @param type String identifier specifying the type of falloff function.
69  * The standard types match class names defined in Falloff.h.
70  * A factory class derived from FalloffFactory may define
71  * other types as well.
72  * @param c input vector of doubles which populates the falloff
73  * parameterization.
74  * @returns a pointer to a new Falloff class.
75  */
76  virtual Falloff* newFalloff(const std::string& type, const vector_fp& c);
77 
78 private:
79  //! Pointer to the single instance of the factory
81 
82  //! default constructor, which is defined as private
84 
85  //! Mutex for use when calling the factory
86  static std::mutex falloff_mutex;
87 };
88 
89 //! @copydoc FalloffFactory::newFalloff
90 /*!
91  * @deprecated To be removed after Cantera 2.5.
92  */
93 shared_ptr<Falloff> newFalloff(int type, const vector_fp& c);
94 
95 //! @copydoc FalloffFactory::newFalloff
96 shared_ptr<Falloff> newFalloff(const std::string& type, const vector_fp& c);
97 
98 }
99 #endif
File contains the FactoryBase class declarations.
Factory class that supports registering functions to create objects.
Definition: FactoryBase.h:71
Factory class to construct falloff function calculators.
static FalloffFactory * factory()
Return a pointer to the factory.
static FalloffFactory * s_factory
Pointer to the single instance of the factory.
static std::mutex falloff_mutex
Mutex for use when calling the factory.
virtual Falloff * newFalloff(int type, const vector_fp &c)
Return a pointer to a new falloff function calculator.
FalloffFactory()
default constructor, which is defined as private
virtual void deleteFactory()
Virtual abstract function that deletes the factory.
Base class for falloff function calculators.
Definition: Falloff.h:30
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:180
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
shared_ptr< Falloff > newFalloff(int type, const vector_fp &c)
Return a pointer to a new falloff function calculator.