]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/performancedb.cxx
Merge branch 'maint' into next
[flightgear.git] / src / AIModel / performancedb.cxx
1 #include "performancedb.hxx"
2
3 PerformanceDB::PerformanceDB()
4 {
5     // these are the 6 classes originally defined in the PERFSTRUCT
6     // Plus a few more for testing
7     registerPerformanceData("heavy_jet", new PerformanceData(
8         4.0, 2.0,  3000.0, 1500.0,  150.0, 160.0,  300.0, 430.0,  300.0,  170.0, 150.0, 15.0));
9     registerPerformanceData("light", new PerformanceData(
10         2.0, 2.0,  450.0, 1000.0,  70.0, 70.0,  80.0, 100.0,  80.0,  70.0, 60.0, 15.0));
11     registerPerformanceData("ww2_fighter", new PerformanceData(
12         4.0, 2.0,  3000.0, 1500.0,  110.0, 110.0,  180.0, 250.0,  200.0,  130.0, 100.0, 15.0));
13     registerPerformanceData("jet_fighter", new PerformanceData(
14         7.0, 3.0,  4000.0, 2000.0,  120.0, 150.0,  350.0, 500.0,  350.0,  170.0, 150.0, 15.0));
15     registerPerformanceData("jet_transport", new PerformanceData(
16         5.0, 2.0,  3000.0, 1500.0,  100.0, 140.0,  300.0, 430.0,  300.0,  170.0, 130.0, 15.0));
17     registerPerformanceData("tanker", new PerformanceData(
18         5.0, 2.0,  3000.0, 1500.0,  100.0, 140.0,  300.0, 430.0,  300.0,  170.0, 130.0, 15.0));
19     registerPerformanceData("ufo", new PerformanceData(
20         30.0, 30.0, 6000.0, 6000.0, 150.0, 150.0, 300.0, 430.0, 300.0, 170.0, 130.0, 15.0));
21
22 }
23
24
25 PerformanceDB::~PerformanceDB()
26 {}
27
28 void PerformanceDB::registerPerformanceData(const std::string& id, PerformanceData* data) {
29     //TODO if key exists already replace data "inplace", i.e. copy to existing PerfData instance
30     // this updates all aircraft currently using the PerfData instance.
31     _db[id] = data;
32 }
33
34 void PerformanceDB::registerPerformanceData(const std::string& id, const std::string& filename) {
35     registerPerformanceData(id, new PerformanceData(filename));
36 }
37
38 PerformanceData* PerformanceDB::getDataFor(const std::string& id) {
39     if (_db.find(id) == _db.end()) // id not found -> return jet_transport data
40         return _db["jet_transport"];
41
42     return _db[id];
43 }