Cantera  2.5.1
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 
8 
9 using namespace std;
10 namespace Cantera
11 {
12 
13 FlowDeviceFactory* FlowDeviceFactory::s_factory = 0;
14 std::mutex FlowDeviceFactory::flowDevice_mutex;
15 
16 FlowDeviceFactory::FlowDeviceFactory()
17 {
18  reg("MassFlowController", []() { return new MassFlowController(); });
19  reg("PressureController", []() { return new PressureController(); });
20  reg("Valve", []() { return new Valve(); });
21 
22  // only used by clib
23  reg_type("MassFlowController", MFC_Type);
24  reg_type("PressureController", PressureController_Type);
25  reg_type("Valve", Valve_Type);
26 }
27 
28 FlowDevice* FlowDeviceFactory::newFlowDevice(const std::string& flowDeviceType)
29 {
30  return create(flowDeviceType);
31 }
32 
33 FlowDevice* FlowDeviceFactory::newFlowDevice(int ir)
34 {
35  try {
36  return create(m_types.at(ir));
37  } catch (out_of_range&) {
38  throw CanteraError("FlowDeviceFactory::newFlowDevice",
39  "unknown flowDevice type!");
40  }
41 }
42 
43 }
Some flow devices derived from class FlowDevice.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
FlowDevice * newFlowDevice(const std::string &model)
Create a FlowDevice object of the specified type.
const int MFC_Type
Magic numbers.
Definition: FlowDevice.h:21