forked from Cantera/cantera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlowDeviceFactory.cpp
46 lines (36 loc) · 1.2 KB
/
FlowDeviceFactory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! @file FlowDeviceFactory.cpp
// This file is part of Cantera. See License.txt in the top-level directory or
// at https://cantera.org/license.txt for license and copyright information.
#include "cantera/zeroD/FlowDeviceFactory.h"
#include "cantera/zeroD/flowControllers.h"
namespace Cantera
{
FlowDeviceFactory* FlowDeviceFactory::s_factory = 0;
std::mutex FlowDeviceFactory::flowDevice_mutex;
FlowDeviceFactory::FlowDeviceFactory()
{
reg("MassFlowController", []() { return new MassFlowController(); });
reg("PressureController", []() { return new PressureController(); });
reg("Valve", []() { return new Valve(); });
}
FlowDeviceFactory* FlowDeviceFactory::factory() {
std::unique_lock<std::mutex> lock(flowDevice_mutex);
if (!s_factory) {
s_factory = new FlowDeviceFactory;
}
return s_factory;
}
void FlowDeviceFactory::deleteFactory() {
std::unique_lock<std::mutex> lock(flowDevice_mutex);
delete s_factory;
s_factory = 0;
}
shared_ptr<FlowDevice> newFlowDevice(const string& model)
{
return shared_ptr<FlowDevice>(FlowDeviceFactory::factory()->create(model));
}
shared_ptr<FlowDevice> newFlowDevice3(const string& model)
{
return newFlowDevice(model);
}
}