forked from ange-yaghi/engine-sim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengine_context.cpp
More file actions
150 lines (127 loc) · 3.59 KB
/
Copy pathengine_context.cpp
File metadata and controls
150 lines (127 loc) · 3.59 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "../include/engine_context.h"
#include "../include/cylinder_bank_node.h"
es_script::EngineContext::EngineContext() {
/* void */
}
es_script::EngineContext::~EngineContext() {
/* void */
}
void es_script::EngineContext::addHead(CylinderHeadNode *node, CylinderHead *head) {
m_heads[node] = head;
}
CylinderHead *es_script::EngineContext::getHead(CylinderHeadNode *head) {
auto it = m_heads.find(head);
if (it != m_heads.end()) {
return it->second;
}
else return nullptr;
}
void es_script::EngineContext::addBank(CylinderBankNode *node, CylinderBank *bank) {
m_banks[node] = bank;
}
CylinderBank *es_script::EngineContext::getBank(CylinderBankNode *bank) const {
auto it = m_banks.find(bank);
if (it != m_banks.end()) {
return it->second;
}
else return nullptr;
}
void es_script::EngineContext::addRodJournal(RodJournalNode *node, int index) {
m_rodJournals[node] = index;
}
int es_script::EngineContext::getRodJournalIndex(RodJournalNode *node) const {
auto it = m_rodJournals.find(node);
if (it != m_rodJournals.end()) {
return it->second;
}
else return -1;
}
void es_script::EngineContext::addIntake(IntakeNode *node, Intake *intake) {
m_intakes[node] = intake;
}
Intake *es_script::EngineContext::getIntake(IntakeNode *intake) const {
auto it = m_intakes.find(intake);
if (it != m_intakes.end()) {
return it->second;
}
else return nullptr;
}
void es_script::EngineContext::addExhaust(
ExhaustSystemNode *node,
ExhaustSystem *exhaust)
{
m_exhaustSystems[node] = exhaust;
}
ExhaustSystem *es_script::EngineContext::getExhaust(ExhaustSystemNode *exhaust) const {
auto it = m_exhaustSystems.find(exhaust);
if (it != m_exhaustSystems.end()) {
return it->second;
}
else return nullptr;
}
void es_script::EngineContext::addFunction(FunctionNode *node, Function *function) {
m_functions[node] = function;
}
Function *es_script::EngineContext::getFunction(FunctionNode *exhaust) const {
auto it = m_functions.find(exhaust);
if (it != m_functions.end()) {
return it->second;
}
else return nullptr;
}
void es_script::EngineContext::addImpulseResponse(
ImpulseResponseNode *node,
ImpulseResponse *impulse)
{
m_impulseResponses[node] = impulse;
}
ImpulseResponse *es_script::EngineContext::getImpulseResponse(
ImpulseResponseNode *node) const
{
auto it = m_impulseResponses.find(node);
if (it != m_impulseResponses.end()) {
return it->second;
}
else return nullptr;
}
void es_script::EngineContext::addCrankshaft(
CrankshaftNode *node,
Crankshaft *crankshaft)
{
m_crankshafts[node] = crankshaft;
}
Crankshaft *es_script::EngineContext::getCrankshaft(CrankshaftNode *node) const {
auto it = m_crankshafts.find(node);
if (it != m_crankshafts.end()) {
return it->second;
}
else return nullptr;
}
void es_script::EngineContext::addConnectingRod(
ConnectingRodNode *node,
ConnectingRod *rod)
{
m_rods[node] = rod;
}
ConnectingRod *es_script::EngineContext::getConnectingRod(
ConnectingRodNode *node) const
{
auto it = m_rods.find(node);
if (it != m_rods.end()) {
return it->second;
}
else return nullptr;
}
void es_script::EngineContext::setCylinderIndex(
const CylinderBankNode *bank,
int localIndex,
int globalIndex)
{
m_cylinderIndices[{ bank, localIndex }] = globalIndex;
}
int es_script::EngineContext::getCylinderIndex(
const CylinderBankNode *bank,
int localIndex) const
{
return m_cylinderIndices.at({ bank, localIndex });
}