| Cantera 3.0.0

Loading...
Searching...
No Matches
FlowDeviceFactory.cpp
Go to the documentation of this file.
1//! @file FlowDeviceFactory.cpp
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#include "cantera/zeroD/FlowDeviceFactory.h"
7#include "cantera/zeroD/flowControllers.h"
8
9 namespace Cantera
10{
11
12FlowDeviceFactory* FlowDeviceFactory::s_factory = 0;
13std::mutex FlowDeviceFactory::flowDevice_mutex;
14
15FlowDeviceFactory::FlowDeviceFactory()
16{
17 reg("MassFlowController", []() { return new MassFlowController(); });
18 reg("PressureController", []() { return new PressureController(); });
19 reg("Valve", []() { return new Valve(); });
20}
21
22FlowDeviceFactory* FlowDeviceFactory::factory() {
23 std::unique_lock<std::mutex> lock(flowDevice_mutex);
24 if (!s_factory) {
25 s_factory = new FlowDeviceFactory;
26 }
27 return s_factory;
28}
29
30 void FlowDeviceFactory::deleteFactory() {
31 std::unique_lock<std::mutex> lock(flowDevice_mutex);
32 delete s_factory;
33 s_factory = 0;
34}
35
36
37 FlowDevice* FlowDeviceFactory::newFlowDevice(const string& flowDeviceType)
38{
39 warn_deprecated("FlowDeviceFactory::newFlowDevice",
40 "To be removed after Cantera 3.0; for new behavior, see 'newFlowDevice3'.");
41 return create(flowDeviceType);
42}
43
44 FlowDevice* newFlowDevice(const string& model)
45{
46 warn_deprecated("newFlowDevice",
47 "To be changed after Cantera 3.0; for new behavior, see 'newFlowDevice3'.");
48 return FlowDeviceFactory::factory()->newFlowDevice(model);
49}
50
51shared_ptr<FlowDevice> newFlowDevice3(const string& model)
52{
53 shared_ptr<FlowDevice> fdptr(FlowDeviceFactory::factory()->create(model));
54 return fdptr;
55}
56
57}
FlowDeviceFactory.h
Cantera::Factory< FlowDevice >::create
FlowDevice * create(const string &name, Args... args)
Create an object using the object construction function corresponding to "name" and the provided cons...
Definition FactoryBase.h:75
Cantera::Factory< FlowDevice >::reg
void reg(const string &name, function< FlowDevice *(Args...)> f)
Register a new object construction function.
Definition FactoryBase.h:80
Cantera::FlowDeviceFactory::newFlowDevice
FlowDevice * newFlowDevice(const string &flowDeviceType)
Create a new flow device by type name.
Definition FlowDeviceFactory.cpp:37
Cantera::FlowDeviceFactory::deleteFactory
void deleteFactory() override
Virtual abstract function that deletes the factory.
Definition FlowDeviceFactory.cpp:30
Cantera::FlowDevice
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition FlowDevice.h:24
flowControllers.h
Some flow devices derived from class FlowDevice.
Cantera::newFlowDevice
FlowDevice * newFlowDevice(const string &model)
Create a FlowDevice object of the specified type.
Definition FlowDeviceFactory.cpp:44
Cantera::newFlowDevice3
shared_ptr< FlowDevice > newFlowDevice3(const string &model)
Create a FlowDevice object of the specified type.
Definition FlowDeviceFactory.cpp:51
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::warn_deprecated
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1926