Cantera  3.1.0a1
Loading...
Searching...
No Matches
Func1Factory.h
Go to the documentation of this file.
1//! @file Func1Factory.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef FUNC1_FACTORY_H
7#define FUNC1_FACTORY_H
8
11
12namespace Cantera
13{
14
15//! Factory class to create Func1 objects
16//!
17//! This class is mainly used via the newFunc1() function, for example:
18//!
19//! ```cpp
20//! shared_ptr<Func1> d1 = newFunc1("sin", {1.0});
21//! ```
22//! @since New in %Cantera 3.0
23class Func1Factory : public Factory<Func1, const vector<double>&>
24{
25public:
26 /**
27 * Return a pointer to the factory. On the first call, a new instance is
28 * created. Since there is no need to instantiate more than one factory,
29 * on all subsequent calls, a pointer to the existing factory is returned.
30 */
31 static Func1Factory* factory();
32
33 void deleteFactory() override;
34
35private:
36 //! Pointer to the single instance of the factory
38
39 //! default constructor, which is defined as private
41
42 //! Mutex for use when calling the factory
43 static std::mutex s_mutex;
44};
45
46
47//! Factory class to create Func1 compound objects - version A
48//!
49//! This class is mainly used via the newFunc1(const string&, const shared_ptr<Func1>,
50//! const shared_ptr<Func1>) function, for example:
51//!
52//! ```cpp
53//! shared_ptr<Func1> d1 = newFunc1("sum", f1, f2);
54//! ```
55//! @since New in %Cantera 3.0
57 : public Factory<Func1, const shared_ptr<Func1>, const shared_ptr<Func1>>
58{
59public:
60 /**
61 * Return a pointer to the factory. On the first call, a new instance is
62 * created. Since there is no need to instantiate more than one factory,
63 * on all subsequent calls, a pointer to the existing factory is returned.
64 */
65 static Math1FactoryA* factory();
66
67 void deleteFactory() override;
68
69private:
70 //! Pointer to the single instance of the factory
72
73 //! default constructor, which is defined as private
75
76 //! Mutex for use when calling the factory
77 static std::mutex s_mutex;
78};
79
80
81//! Factory class to create Func1 compound objects - version B
82//!
83//! This class is mainly used via the newFunc1(const string&, const shared_ptr<Func1>,
84//! double) function, for example:
85//!
86//! ```cpp
87//! shared_ptr<Func1> d1 = newFunc1("plus-constant", f, 1.);
88//! ```
89//! @since New in %Cantera 3.0
90class Math1FactoryB : public Factory<Func1, const shared_ptr<Func1>, double>
91{
92public:
93 /**
94 * Return a pointer to the factory. On the first call, a new instance is
95 * created. Since there is no need to instantiate more than one factory,
96 * on all subsequent calls, a pointer to the existing factory is returned.
97 */
98 static Math1FactoryB* factory();
99
100 void deleteFactory() override;
101
102private:
103 //! Pointer to the single instance of the factory
105
106 //! default constructor, which is defined as private
108
109 //! Mutex for use when calling the factory
110 static std::mutex s_mutex;
111};
112
113
114//! Create a new simple functor object (see @ref func1simple).
115//! @param func1Type String identifying functor type.
116//! @param coeff Coefficient; definition depends on functor type.
117//! @ingroup func1simple
118//! @since New in %Cantera 3.0
119shared_ptr<Func1> newFunc1(const string& func1Type, double coeff=1.);
120
121//! Create a new advanced functor object (see @ref func1advanced).
122//! @param func1Type String identifying functor type.
123//! @param params Parameter vector; definition depends on functor type.
124//! @ingroup func1advanced
125//! @since New in %Cantera 3.0
126shared_ptr<Func1> newFunc1(const string& func1Type, const vector<double>& params);
127
128//! Create a new compound functor object (see @ref func1compound).
129//! @param func1Type String identifying functor type.
130//! @param f1 First Func1 object.
131//! @param f2 Second Func1 object.
132//! @ingroup func1compound
133//! @since New in %Cantera 3.0
134shared_ptr<Func1> newFunc1(const string& func1Type,
135 const shared_ptr<Func1> f1, const shared_ptr<Func1> f2);
136
137//! Create a new modified functor object (see @ref func1modified).
138//! @param func1Type String identifying functor type.
139//! @param f Func1 object.
140//! @param coeff Coefficient; definition depends on functor type.
141//! @ingroup func1modified
142//! @since New in %Cantera 3.0
143shared_ptr<Func1> newFunc1(const string& func1Type,
144 const shared_ptr<Func1> f, double coeff);
145
146}
147
148#endif
File contains the FactoryBase class declarations.
Factory class that supports registering functions to create objects.
Definition FactoryBase.h:69
Factory class to create Func1 objects.
static std::mutex s_mutex
Mutex for use when calling the factory.
static Func1Factory * s_factory
Pointer to the single instance of the factory.
void deleteFactory() override
Virtual abstract function that deletes the factory.
Func1Factory()
default constructor, which is defined as private
static Func1Factory * factory()
Return a pointer to the factory.
Factory class to create Func1 compound objects - version A.
static Math1FactoryA * s_factory
Pointer to the single instance of the factory.
Math1FactoryA()
default constructor, which is defined as private
static std::mutex s_mutex
Mutex for use when calling the factory.
void deleteFactory() override
Virtual abstract function that deletes the factory.
static Math1FactoryA * factory()
Return a pointer to the factory.
Factory class to create Func1 compound objects - version B.
static std::mutex s_mutex
Mutex for use when calling the factory.
void deleteFactory() override
Virtual abstract function that deletes the factory.
Math1FactoryB()
default constructor, which is defined as private
static Math1FactoryB * factory()
Return a pointer to the factory.
static Math1FactoryB * s_factory
Pointer to the single instance of the factory.
shared_ptr< Func1 > newFunc1(const string &func1Type, double coeff)
Create a new simple functor object (see Simple Functors).
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564